leonardehrenfried / jspc-maven-plugin

Maven JSP precompilation plugin
https://leonardehrenfried.github.io/jspc-maven-plugin/compile-mojo.html
Apache License 2.0
30 stars 20 forks source link

javax.servlet dependency not compatible with tomcat 10 #114

Open siropa opened 1 year ago

siropa commented 1 year ago

The pom includes a dependency for javax.servlet-api version 4.0.1. When compiling for target of tomcat 10, getting errors about missing javax.servlet.jsp.tagext.BodyTagSupport. It should be using jakarta.servlet.jsp.tagext.BodyTagSupport which is in jakarta.servlet-api version 6.0.0. Can this old dependency be updated please?

leonardehrenfried commented 1 year ago

Sure, could you please send a pull request?

leonardehrenfried commented 1 year ago

I just released version 4.1.0 which upgrades a bunch of dependencies including the one you mention. Can you check if it solves your problem?

siropa commented 1 year ago

I see it pulling the 6.0.0 version of the servlet-api now, but i'm still having the issue. here is what i'm getting: SEVERE: Compilation error java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/BodyTagSupport at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) at org.apache.jasper.JspC.execute(JspC.java:1498) at io.leonard.maven.plugins.jspc.JspcWorker.call(JspcWorker.java:27) at io.leonard.maven.plugins.jspc.JspcWorker.call(JspcWorker.java:9) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) at java.base/java.lang.Thread.run(Thread.java:1589) Caused by: java.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/BodyTagSupport at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1013) at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150) at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:524) at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:427) at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:421) at java.base/java.security.AccessController.doPrivileged(AccessController.java:712) at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:420) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) at org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1236) at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1469) at org.apache.jasper.compiler.Parser.parse(Parser.java:138) at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:245) at org.apache.jasper.compiler.ParserController.parse(ParserController.java:106) at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:211) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:396) at org.apache.jasper.JspC.processFile(JspC.java:1343) at org.apache.jasper.JspC$ProcessFile.call(JspC.java:1858) at org.apache.jasper.JspC$ProcessFile.call(JspC.java:1849) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577) ... 4 more Caused by: java.lang.ClassNotFoundException: javax.servlet.jsp.tagext.BodyTagSupport at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ... 26 more

I used the debug flag with the maven command and don't see any of the old versions of the servlet jars being pulled anymore.

leonardehrenfried commented 1 year ago

To be honest, I have no idea how this should work correctly since I haven't touched JSP in over 10 years. If you could send a PR with the correct pom.xml I'm happy to merge it in.

The thing is, there isn't any code in this repo that is referencing javax/servlet/jsp/tagext/BodyTagSupport.

Do you maybe write some custom tags like these https://github.com/leonardehrenfried/jspc-maven-plugin/blob/master/src/it/project_multimodule_with%20space/moduleB/src/main/java/com/example/plugin/jspc/tag/HelloTag.java and have an import on the javax namespace there?

siropa commented 1 year ago

We do have custom tags like that, but they are all using jakarta references. I even cleaned out my maven repo and then searched everything that was imported with a fresh build for old javax references and didn't find any. I have no idea where that is coming from.

If I had a fix, i'd gladly submit it, but i'm stumped at this point. When i've got some time i'll keep looking it to. thanks for the help.

leonardehrenfried commented 1 year ago

Ah, I remembered something from last night. I had to change some namespace definition when moving from javax to jakarta in the test projects.

https://github.com/leonardehrenfried/jspc-maven-plugin/commit/c25931fae083af6a1acde4ec1d858d10909f848c

Do you have old URIs in your JSPs somewhere?

siropa commented 1 year ago

Good idea, but no. to test, I created a fake javax.servlet.jsp.tagext.BodyTagSupport.java file in my project. Ran the jsp compiler and found the issue. We use this old pdf library and apparently that has some imbedded references to the old version. So my fix is dealing with that 12year old out of data lib.

thanks for your help and getting the project updated with the newer versions.

leonardehrenfried commented 1 year ago

Good detective work!