在 pax-web (pax-web 6.0.3, jetty 9.3.14) 的 jetty.xml 中,我定义了这样的 RewriteHandler:
<Get name="handler">
<Call name="addHandler">
<Arg>
<Ref id="Rewrite"/>
</Arg>
</Call>
</Get>
问题是每个 URL 都重写得很好,但是我得到了一个 404。我认为 ServletHandler 在链中的 Rewrite 之前,但是“insertHandler”调用会导致这个错误:
org.apache.cxf.cxf-rt-transports-http - 3.1.11 | Error registering CXF OSGi servlet STARTED
java.lang.IllegalStateException: STARTED
at org.eclipse.jetty.server.handler.HandlerCollection.setHandlers(HandlerCollection.java:83) [166:org.eclipse.jetty.server:9.3.14.v20161028]
at org.eclipse.jetty.server.handler.HandlerCollection.addHandler(HandlerCollection.java:154) [166:org.eclipse.jetty.server:9.3.14.v20161028]
at org.eclipse.jetty.servlet.ServletContextHandler.<init>(ServletContextHandler.java:168) [167:org.eclipse.jetty.servlet:9.3.14.v20161028]
at org.eclipse.jetty.servlet.ServletContextHandler.<init>(ServletContextHandler.java:128) [167:org.eclipse.jetty.servlet:9.3.14.v20161028]
at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.<init>(HttpServiceContext.java:116) [179:org.ops4j.pax.web.pax-web-jetty:6.0.3]
at org.ops4j.pax.web.service.jetty.internal.JettyServerWrapper.addContext(JettyServerWrapper.java:290) [179:org.ops4j.pax.web.pax-web-jetty:6.0.3]
at org.ops4j.pax.web.service.jetty.internal.JettyServerWrapper.getOrCreateContext(JettyServerWrapper.java:209) [179:org.ops4j.pax.web.pax-web-jetty:6.0.3]
at org.ops4j.pax.web.service.jetty.internal.JettyServerWrapper.getOrCreateContext(JettyServerWrapper.java:190) [179:org.ops4j.pax.web.pax-web-jetty:6.0.3]
at org.ops4j.pax.web.service.jetty.internal.JettyServerImpl.addServlet(JettyServerImpl.java:324) [179:org.ops4j.pax.web.pax-web-jetty:6.0.3]
at org.ops4j.pax.web.service.jetty.internal.ServerControllerImpl$Started.addServlet(ServerControllerImpl.java:289) [179:org.ops4j.pax.web.pax-web-jetty:6.0.3]
at org.ops4j.pax.web.service.jetty.internal.ServerControllerImpl.addServlet(ServerControllerImpl.java:110) [179:org.ops4j.pax.web.pax-web-jetty:6.0.3]
at org.ops4j.pax.web.service.internal.HttpServiceStarted.registerServlet(HttpServiceStarted.java:239) [180:org.ops4j.pax.web.pax-web-runtime:6.0.3]
at org.ops4j.pax.web.service.internal.HttpServiceStarted.registerServlet(HttpServiceStarted.java:215) [180:org.ops4j.pax.web.pax-web-runtime:6.0.3]
at org.ops4j.pax.web.service.internal.HttpServiceStarted.registerServlet(HttpServiceStarted.java:199) [180:org.ops4j.pax.web.pax-web-runtime:6.0.3]
at org.ops4j.pax.web.service.internal.HttpServiceProxy.registerServlet(HttpServiceProxy.java:65) [180:org.ops4j.pax.web.pax-web-runtime:6.0.3]
at org.apache.cxf.transport.http.osgi.ServletExporter.updated(ServletExporter.java:108) [58:org.apache.cxf.cxf-rt-transports-http:3.1.11]
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServiceTracker.java:189) [7:org.apache.felix.configadmin:1.8.14]
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:152) [7:org.apache.felix.configadmin:1.8.14]
at org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85) [7:org.apache.felix.configadmin:1.8.14]
at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.provide(ConfigurationManager.java:1463) [7:org.apache.felix.configadmin:1.8.14]
at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.run(ConfigurationManager.java:1419) [7:org.apache.felix.configadmin:1.8.14]
at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:141) [7:org.apache.felix.configadmin:1.8.14]
at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:109) [7:org.apache.felix.configadmin:1.8.14]
at java.lang.Thread.run(Thread.java:745) [?:?]
如何使 RewriteHandler 工作?