[ https://issues.apache.org/jira/browse/CXF-7203?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Dmitry Murashenkov updated CXF-7203: ------------------------------------ Description: I want to achieve following set of calls to ease configuration management: Endpoint.publish("/user/soap/userService", userService); Endpoint.publish("/admin/soap/adminService", adminService); ServletContextHandler userContext = new ServletContextHandler(); userContext.setContextPath("/user"); userContext.addServlet(new ServletHolder(cxf), "/soap/*"); ServletContextHandler adminContext = new ServletContextHandler(); adminContext.setContextPath("/admin"); adminContext.addServlet(new ServletHolder(cxf), "/soap/*"); Currently it is not possible since ServletController.invoke() takes request.getPathInfo() and that would be "/userService". So CXFServlet can only be mapped to root context, which may be impossible if I have other servlets in "/user" context and Jetty would first call more specific user context for that URI. Current workaround is to extend CXFNonSpringServlet and rewrite pathInfo, servletContext and contextPath in the invoke() as if servlet is deployed in server root "/*": @Override protected void invoke(HttpServletRequest request, HttpServletResponse response) throws ServletException { String fullPath = request.getContextPath() + "/" + request.getServletPath() + "/" + request.getPathInfo(); fullPath = fullPath.replaceAll("//", "/"); ((Request)request).setPathInfo(fullPath); ((Request)request).setContextPath("/"); ((Request)request).setServletPath("/"); super.invoke(request, response); } Also having single CXFServlet mapped several times in Jetty causes NPE in CXFNonSpringServlet.destroy() since it is called multiple times and destinationRegistry is set to null after first invocation. Same problem exists for CXFNonSpringJaxrsServlet and can be worked around the same way. Additionally it fails during several init() invocations - attempting to start several endpoints for same address. was: I want to achieve following set of calls to ease configuration management: Endpoint.publish("/user/soap/userService", userService); Endpoint.publish("/admin/soap/adminService", adminService); ServletContextHandler userContext = new ServletContextHandler(); userContext.setContextPath("/user"); userContext.addServlet(new ServletHolder(cxf), "/soap/*"); ServletContextHandler adminContext = new ServletContextHandler(); adminContext.setContextPath("/admin"); adminContext.addServlet(new ServletHolder(cxf), "/soap/*"); Currently it is not possible since ServletController.invoke() takes request.getPathInfo() and that would be "/userService". So CXFServlet can only be mapped to root context, which may be impossible if I have other servlets in "/user" context and Jetty would first call more specific user context for that URI. Current workaround is to extend CXFNonSpringServlet and rewrite pathInfo in the invoke(). Also having single CXFServlet mapped several times in Jetty causes NPE in CXFNonSpringServlet.destroy() since it is called multiple times and destinationRegistry is set to null after first invocation. > Multiple servlet mappings for CXFNonSpringServlet > ------------------------------------------------- > > Key: CXF-7203 > URL: https://issues.apache.org/jira/browse/CXF-7203 > Project: CXF > Issue Type: Improvement > Reporter: Dmitry Murashenkov > > I want to achieve following set of calls to ease configuration management: > Endpoint.publish("/user/soap/userService", userService); > Endpoint.publish("/admin/soap/adminService", adminService); > ServletContextHandler userContext = new ServletContextHandler(); > userContext.setContextPath("/user"); > userContext.addServlet(new ServletHolder(cxf), "/soap/*"); > ServletContextHandler adminContext = new ServletContextHandler(); > adminContext.setContextPath("/admin"); > adminContext.addServlet(new ServletHolder(cxf), "/soap/*"); > Currently it is not possible since ServletController.invoke() takes > request.getPathInfo() and that would be "/userService". So CXFServlet can > only be mapped to root context, which may be impossible if I have other > servlets in "/user" context and Jetty would first call more specific user > context for that URI. > Current workaround is to extend CXFNonSpringServlet and rewrite pathInfo, > servletContext and contextPath in the invoke() as if servlet is deployed in > server root "/*": > @Override > protected void invoke(HttpServletRequest request, HttpServletResponse > response) throws ServletException > { > String fullPath = request.getContextPath() + "/" + > request.getServletPath() + "/" + request.getPathInfo(); > fullPath = fullPath.replaceAll("//", "/"); > ((Request)request).setPathInfo(fullPath); > ((Request)request).setContextPath("/"); > ((Request)request).setServletPath("/"); > super.invoke(request, response); > } > Also having single CXFServlet mapped several times in Jetty causes NPE in > CXFNonSpringServlet.destroy() since it is called multiple times and > destinationRegistry is set to null after first invocation. > Same problem exists for CXFNonSpringJaxrsServlet and can be worked around the > same way. Additionally it fails during several init() invocations - > attempting to start several endpoints for same address. -- This message was sent by Atlassian JIRA (v6.3.4#6332)