原来我使用 jetty 9.2.17,一直都很正常;最近想使用标准的 websocket,先将 jetty 升级到 9.3.10。原来 JSP 支持使用 jetty-jsp,升级后改为 jetty 的 apache-jsp (版本与其他 jetty 组件相同,官方换了包名而已,依赖 apache 的 apache-jsp 8.0.33),Servlet 一切正常,但 JSP 都无法使用了,报错:
java.lang.NullPointerException
at org.apache.jasper.compiler.Validator$ValidateVisitor.<init>(Validator.java:515)
at org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1853)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:217)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:585)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:363)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:837)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1180)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
at org.eclipse.jetty.server.Server.handle(Server.java:524)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:319)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:253)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)
at java.lang.Thread.run(Thread.java:745)
搜了一圈,也看了 jetty 官方的文档,尝试了 web.xml 中设置 jsp servlet,设置其他属性,增加额外的包,均无效。请问有遇到过类似问题的朋友吗?你是如何解决的。
드디어 이 문제를 해결했습니다. https://github.com/jetty-proj를 참조하세요...
jetty 버전이 9.2.17에서 9.3.1x로 업그레이드된 후 원래 WebAppContext는 ContextPath 및 ResourceBase만 설정하면 됩니다. 이제 apache-jsp에 의존하는 것 외에도 몇 가지 추가 속성을 설정해야 합니다. 패키지의 경우 ContainerInitializer를 얻으려면 jetty-plus 패키지도 도입해야 합니다. 다음은 예시를 참고하여 작성한 코드입니다.
으아악