gpt4 book ai didi

java - Pax-web、jetty和RewriteHandler导致404

转载 作者:太空宇宙 更新时间:2023-11-04 10:50:51 25 4
gpt4 key购买 nike

在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 工作?

最佳答案

在启动 Jetty 服务器之前添加处理程序。

该错误是因为一旦服务器启动,处理程序列表就不可变。

关于java - Pax-web、jetty和RewriteHandler导致404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47882396/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com