Issue
Related: href="https://stackoverflow.com/questions/73417710/jetty-upgrading-9-3-0-m1-to-9-3-0-m2-breaks-jsp-functionality-using-maven">Jetty - upgrading 9.3.0.M1 to 9.3.0.M2 breaks JSP functionality using Maven
I'm trying to migrate as above. Maven project.
My Jetty version is 9.2.23.v20171218 in my pom.xml.
I'm running the JDK11 from Ubuntu's official repos on Ubuntu 20.04.2 LTS.
I'm using a fat executable .jar with all dependencies included. NetBeans 11.
I compile on JDK1.8 with Netbeans 11 on Windows 10 and deploy to the Ubuntu server which is running JDK11.
Everything works on JDK11 EXCEPT Jetty - if I run the .jar in JDK1.8 on the Windows 10 machine, it can serve .JSP pages from Jetty.
If I run the .jar in JDK1.8 on the Linux machine, it can serve .JSP pages from Jetty.
If I run the .jar in JDK11 on the Linux machine, I get when trying to see a .JSP page in Chrome on the Ubuntu machine:
org.apache.jasper.JasperException: /index.jsp(1,68) PWC6188: The absolute uri: http://java.sun.com/jsp/jstl/fmt cannot be resolved in either web.xml or the jar files deployed with this application
Clearly there is a critical difference between JDK1.8 and JDK11 for Jetty's JSTL mechanics.
What can that be?
I have dug around extensively my problem is everybody else who gets this gets
org.apache.jasper.JasperException: /index.jsp(1,68) PWC6188: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
while I get
org.apache.jasper.JasperException: /index.jsp(1,68) PWC6188: The absolute uri: http://java.sun.com/jsp/jstl/fmt cannot be resolved in either web.xml or the jar files deployed with this application
"core" vs. "fmt" - no-one else I can find gets "fmt" - everybody gets "core" in the same error message.
Where can I start to look?
Salient issue is this works ONLY in JDK1.8 - if I try it in Windows with JDK11, I get the exact same error I get on Linux with JDK11.
So my issue is JDK1.8 Jetty code to serve JSP pages as I implement it is incompatible with JDK11.
Where can I begin to look?
The error literally is that ONLY under default JDK11
The absolute uri: http://java.sun.com/jsp/jstl/fmt cannot be resolved in either web.xml or the jar files deployed with this application
How do I resolve the absolute URI above in JDK11?
It looks like an environment / JDK setting.
I'm running the JAR in JDK11 via
/usr/lib/jvm/java-11-openjdk-amd64/bin/java -Djavax.net.ssl.trustStore=/usr/lib/jvm/java-11-openjdk-amd64/lib/security/cacerts -cp /usr/src/verdi/verdi-1.0-SNAPSHOT-jar-with-dependencies.jar verishare.App
Any ideas or basic conceptual errors here? (I'm very new to Java.)
Thanks!
EDIT: My output of mvn dependency:tree
as kindly suggested by Joakim Erdfelt:
[INFO] verishare:verdi:jar:1.0-SNAPSHOT
[INFO] +- org.slf4j:slf4j-simple:jar:1.7.21:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.21:compile
[INFO] +- org.apache.logging.log4j:log4j-api:jar:2.11.0:compile
[INFO] +- org.apache.logging.log4j:log4j-core:jar:2.11.0:compile
[INFO] +- junit:junit:jar:4.11:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.eclipse.jetty.websocket:websocket-client:jar:9.2.23.v20171218:compile
[INFO] | +- org.eclipse.jetty:jetty-util:jar:9.2.23.v20171218:compile
[INFO] | +- org.eclipse.jetty:jetty-io:jar:9.2.23.v20171218:compile
[INFO] | \- org.eclipse.jetty.websocket:websocket-common:jar:9.2.23.v20171218:compile
[INFO] | \- org.eclipse.jetty.websocket:websocket-api:jar:9.2.23.v20171218:compile
[INFO] +- org.eclipse.jetty:jetty-server:jar:9.2.23.v20171218:compile
[INFO] | +- javax.servlet:javax.servlet-api:jar:3.1.0:compile
[INFO] | \- org.eclipse.jetty:jetty-http:jar:9.2.23.v20171218:compile
[INFO] +- org.eclipse.jetty:jetty-servlet:jar:9.2.23.v20171218:compile
[INFO] | \- org.eclipse.jetty:jetty-security:jar:9.2.23.v20171218:compile
[INFO] +- com.google.code.gson:gson:jar:2.2.4:compile
[INFO] +- org.glassfish:javax.json:jar:1.0.4:compile
[INFO] +- org.apache.commons:commons-dbcp2:jar:2.5.0:compile
[INFO] | +- org.apache.commons:commons-pool2:jar:2.6.0:compile
[INFO] | \- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- postgresql:postgresql:jar:9.1-901-1.jdbc4:compile
[INFO] +- org.xerial:sqlite-jdbc:jar:3.8.6:compile
[INFO] +- org.eclipse.jetty:jetty-webapp:jar:9.2.23.v20171218:compile
[INFO] | \- org.eclipse.jetty:jetty-xml:jar:9.2.23.v20171218:compile
[INFO] +- org.eclipse.jetty:jetty-jsp:jar:9.2.23.v20171218:compile
[INFO] | +- org.eclipse.jetty.toolchain:jetty-schemas:jar:3.1.M0:compile
[INFO] | +- javax.servlet.jsp:javax.servlet.jsp-api:jar:2.3.1:compile
[INFO] | +- org.glassfish.web:javax.servlet.jsp:jar:2.3.2:compile
[INFO] | +- org.eclipse.jetty.orbit:javax.servlet.jsp.jstl:jar:1.2.0.v201105211821:compile
[INFO] | +- org.glassfish.web:javax.servlet.jsp.jstl:jar:1.2.2:compile
[INFO] | +- org.glassfish:javax.el:jar:3.0.0:compile
[INFO] | \- org.eclipse.jetty.orbit:org.eclipse.jdt.core:jar:3.8.2.v20130121:compile
[INFO] +- Microsoft:MSSQL:jar:4.0:compile
[INFO] +- org.mariadb.jdbc:mariadb-java-client:jar:1.1.8:compile
[INFO] | +- net.java.dev.jna:jna:jar:3.3.0:compile
[INFO] | +- net.java.dev.jna:jna:jar:platform:3.3.0:compile
[INFO] | \- commons-dbcp:commons-dbcp:jar:1.4:compile
[INFO] | \- commons-pool:commons-pool:jar:1.5.4:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.5.1:compile
[INFO] | +- org.apache.httpcomponents:httpcore:jar:4.4.3:compile
[INFO] | \- commons-codec:commons-codec:jar:1.9:compile
[INFO] +- org.glassfish.jersey.core:jersey-server:jar:2.22.1:compile
[INFO] | +- org.glassfish.jersey.core:jersey-common:jar:2.22.1:compile
[INFO] | | +- org.glassfish.jersey.bundles.repackaged:jersey-guava:jar:2.22.1:compile
[INFO] | | \- org.glassfish.hk2:osgi-resource-locator:jar:1.0.1:compile
[INFO] | +- org.glassfish.jersey.core:jersey-client:jar:2.22.1:compile
[INFO] | +- javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile
[INFO] | +- org.glassfish.jersey.media:jersey-media-jaxb:jar:2.22.1:compile
[INFO] | +- javax.annotation:javax.annotation-api:jar:1.2:compile
[INFO] | +- org.glassfish.hk2:hk2-api:jar:2.4.0-b31:compile
[INFO] | | +- org.glassfish.hk2:hk2-utils:jar:2.4.0-b31:compile
[INFO] | | \- org.glassfish.hk2.external:aopalliance-repackaged:jar:2.4.0-b31:compile
[INFO] | +- org.glassfish.hk2.external:javax.inject:jar:2.4.0-b31:compile
[INFO] | +- org.glassfish.hk2:hk2-locator:jar:2.4.0-b31:compile
[INFO] | \- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] +- org.glassfish.jersey.containers:jersey-container-servlet-core:jar:2.22.1:compile
[INFO] +- org.glassfish.jersey.media:jersey-media-multipart:jar:2.22.1:compile
[INFO] | \- org.jvnet.mimepull:mimepull:jar:1.9.6:compile
[INFO] +- org.glassfish.jersey.media:jersey-media-json-jackson:jar:2.22.1:compile
[INFO] | +- org.glassfish.jersey.ext:jersey-entity-filtering:jar:2.22.1:compile
[INFO] | +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.5.4:compile
[INFO] | \- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.5.4:compile
[INFO] | \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.5.4:compile
[INFO] +- org.glassfish.jersey.containers:jersey-container-jetty-http:jar:2.22.1:compile
[INFO] | \- org.eclipse.jetty:jetty-continuation:jar:9.1.1.v20140108:compile
[INFO] +- org.reflections:reflections:jar:0.9.10:compile
[INFO] | +- com.google.guava:guava:jar:15.0:compile
[INFO] | +- org.javassist:javassist:jar:3.19.0-GA:compile
[INFO] | \- com.google.code.findbugs:annotations:jar:2.0.1:compile
[INFO] +- com.jcraft:jsch:jar:0.1.53:compile
[INFO] +- ie.corballis:sox-java:jar:1.0.1:compile
[INFO] +- com.sun.mail:javax.mail:jar:1.5.0:compile
[INFO] | \- javax.activation:activation:jar:1.1:compile
[INFO] +- org.springframework:spring-web:jar:5.3.0:compile
[INFO] | +- org.springframework:spring-beans:jar:5.3.0:compile
[INFO] | \- org.springframework:spring-core:jar:5.3.0:compile
[INFO] | \- org.springframework:spring-jcl:jar:5.3.0:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.11.3:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-core:jar:2.11.3:compile
[INFO] \- com.fasterxml.jackson.core:jackson-annotations:jar:2.11.3:compile
EDIT: Have spent some time and worked through every Maven artifact I can find referring to "JSTL" and also modified my pom.xml to include every single Jetty 9.2.23.v20171218 artifact I can find that seems to even remotly refer to any web or JSP functionality, but running the above mentioned .jar under JDK11 still results in the original error. Now working through the Jakarta and Apache artifacts (searching for the strings "FMT", "JSTL", "web", "jetty" etc. on the Maven pages) and adding all the artifacts and I can find, then iterating. - add, compile, test, remove, add, compile, test, remove. So far nothing added seems to provide what is expected at
The absolute uri: http://java.sun.com/jsp/jstl/fmt
EDIT: My full exception for this is
[qtp1591916281-28] WARN org.eclipse.jetty.servlet.ServletHandler -
org.apache.jasper.JasperException: /index.jsp(1,64) PWC6188: The absolute uri: http://java.sun.com/jsp/jstl/fmt cannot be resolved in either web.xml or the jar files deployed with this application
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:92)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:378)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:172)
at org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:431)
at org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:240)
at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:502)
at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:582)
at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1657)
at org.apache.jasper.compiler.Parser.parse(Parser.java:185)
at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:244)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:145)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:212)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:625)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:377)
at org.eclipse.jetty.jsp.JettyJspServlet.service(JettyJspServlet.java:103)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:553)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:499)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:258)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
at java.base/java.lang.Thread.run(Thread.java:829)
So... is my problem in Eclipse, Jetty, Jasper, or Apache? Totally confused.
EDIT: I have no "web.xml" file anywhere in my project tree in Netbeans 11 for this project. Do I need one? Is it only required for JDK11 for Jetty / Eclipse / Jasper?
EDIT: I've been extensively working through every SO post I can find on this, and I've discovered I have no WEB-INF folder either, anywhere in my project source tree. Problem / not a problem? Legacy app I did not write and which is several years old, and it is totally unusable in JDK11 due to the above PWC6188.
EDIT: Still nowhere on this, have also tried upgrading the Jetty version slightly, issue remains the same as above. It appears impossible to run Jetty 9.2.23.v20171218 with JSTL in a working state in Java 11? Am I wasting time trying to do this? I'm considering abandoning the entire project and rewriting from scratch, and have to justify this - given the weeks of full time dev spent on this single issue already - it is the law of diminishing returns starting to be felt. Am I wasting time and should rather abandon Jetty entirely?
Solution
This was eventually kind-of solved today by me - see these links for some more details and the exact artifacts I discovered I needed in my Maven project pom.xml:
Jetty - upgrading 9.3.0.M1 to 9.3.0.M2 breaks JSP functionality using Maven
Effectively the step to solve this questions is
- Upgrade to JDK 17.
- Drop jetty-jsp artifact from pom.xml
- Add jetty-annotations artifact to pom.xml
- Add jaxb-api artifact to pom.xml
- Add jetty-webapp artifact to pom.xml
- Add Apache-JSP and Apache-JSTL artifacts to pom.xml
- Take the Jetty version in pom.xml up to at least 9.4.48.v20220622 (don't know if a higher version will still work with my setup, this one does... still checking.)
I also upgraded my Netbeans from NetBeans 11 to NetBeans 14, not sure if that also had a positive effect to get this working. Only tested so far inside NetBeans itself, haven't tried deploying the .jar yet to the operational server involved.
Anyway, see the above two links for details.
This is now solved, I have managed to upgrade Jetty 9 to a newer version of Jetty 9 while taking the JDK it runs in up from 1.8 to 17 - while preserving JSP functionality - which is what I wanted to do and why I posted this question last year.
Hope this helps someone.
EDIT: I forgot I also had to do this to my WebappContext whens starting jetty to make PWC6188 exception above go away when starting Jetty:
.
.
.
WebAppContext waContext = new WebAppContext(webDir, "/");
waContext.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
waContext.setSecurityHandler(basicSecurity);
waContext.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/[^/]*taglibs.*\\.jar$");
server.setHandler(waContext);
.
.
.
e.g. I had to add
waContext.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/[^/]*taglibs.*\\.jar$");
or else in Jetty 9.3.0.M2 I again had the same exception.
Answered By - Stefan
Answer Checked By - Willingham (JavaFixing Volunteer)