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

Issue when there are spaces in filenames #22

Closed tbertrand1 closed 6 years ago

tbertrand1 commented 6 years ago

Hi,

I upgrade from version 2.2.0 to 2.4.4 and I have errors during compilation because of spaces in folder names (Jenkins project name). Spaces are converted and appears as %20 in the error messages.

java.io.FileNotFoundException: /home/data/jenkins-data/jobs/Release%20Eu%20instant/TDUtils/target/TDUtils-3.18.04.0.6-Eu-SNAPSHOT.jar (No such file or directory) at java.util.zip.ZipFile.open(Native Method) at java.util.zip.ZipFile.(ZipFile.java:225) at java.util.zip.ZipFile.(ZipFile.java:155) at java.util.jar.JarFile.(JarFile.java:166) at java.util.jar.JarFile.(JarFile.java:130) at org.apache.tomcat.util.scan.JarFileUrlJar.(JarFileUrlJar.java:60) at org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:48) at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:338) at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:288) at org.apache.jasper.servlet.TldScanner.scanJars(TldScanner.java:262) at org.apache.jasper.servlet.TldScanner.scan(TldScanner.java:104) at org.apache.jasper.JspC.initServletContext(JspC.java:1540) at io.leonard.maven.plugins.jspc.JspCContextAccessor.initServletContext(JspCContextAccessor.java:21) at io.leonard.maven.plugins.jspc.JspcMojo.initJspc(JspcMojo.java:374) at io.leonard.maven.plugins.jspc.JspcMojo.initJspcWorkers(JspcMojo.java:338) at io.leonard.maven.plugins.jspc.JspcMojo.compile(JspcMojo.java:317) at io.leonard.maven.plugins.jspc.JspcMojo.execute(JspcMojo.java:272)

After trying different versions, the problem appears between version 2.3.0 and 2.4.1. This comes from the change in method JspcMojo.setUpClassPath(...) in the commit https://github.com/leonardehrenfried/jspc-maven-plugin/commit/9771b4e7430b286445f7a91d9786f0c99479a299 File.toURL() has been replaced by File.toURI().toURL(), so space character is encoded as %20.

Thanks

leonardehrenfried commented 6 years ago

This should be easy to fix.

@tcollignon Could you add test for this and then fix the problem! Thanks!

tcollignon commented 6 years ago

Sure I Will, but for this week im on vacation , I do it when I return. Thx for the diagnostic @tbertrand1

tcollignon commented 6 years ago

hi @tbertrand1 , can you provide your POM or part of it to help me reproduce with an IT please ? thank you

tcollignon commented 6 years ago

I have tried a PR with a test but without failure, is passing on my mac and on travis CI. I need more informations of your case I wait for it

Thx

tbertrand1 commented 6 years ago

Hi @tcollignon,

I have tried your PR and it has passed without problem. I have edited it quickly, but I couldn't reproduce the error for the moment. My pom and my project are quite big, so I need to reproduce on a simpler example before getting back to you. I try to do it before the end of the week.

I have several maven modules and JSP fragments are distributed in those modules, so the error could come from an import of a JSP from another module.

Thank you

tcollignon commented 6 years ago

Ok thx @tbertrand1 , I wait for your small project, if you can do it, it will be very good

tbertrand1 commented 6 years ago

I have reproduced the problem on this little project : https://github.com/tbertrand1/jspc-plugin-example

The problem appears when the plugin tries to scan a dependency jar with a space in its path. In my example, I have a module "moduleA" with an index.jsp and a taglib that use a class of "moduleB". To reproduce the problem, the project needs to be in a folder with a space: "/home/thomas/dev/JSPC Example/" for example.

In these conditions, with a version of jspc-maven-plugin >= 2.4.1, I have the following error:

[INFO] --- jspc-maven-plugin:2.4.1:compile (jspc) @ moduleA --- [INFO] Includes=/*.jsp, */.jspx, /*.jspf [INFO] Number of jsps for thread 1 : 1 mars 07, 2018 9:00:48 PM org.apache.tomcat.util.scan.StandardJarScanner scan AVERTISSEMENT: Failed to scan [file:/home/thomas/dev/JSPC%2520Example/moduleB/target/moduleB-1.0.0-SNAPSHOT.jar] from classloader hierarchy java.io.FileNotFoundException: /home/thomas/dev/JSPC%20Example/moduleB/target/moduleB-1.0.0-SNAPSHOT.jar (No such file or directory) at java.util.zip.ZipFile.open(Native Method) at java.util.zip.ZipFile.(ZipFile.java:225) at java.util.zip.ZipFile.(ZipFile.java:155) at java.util.jar.JarFile.(JarFile.java:166) at java.util.jar.JarFile.(JarFile.java:130) at org.apache.tomcat.util.scan.JarFileUrlJar.(JarFileUrlJar.java:60) at org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:48) at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:338) at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:288) at org.apache.jasper.servlet.TldScanner.scanJars(TldScanner.java:262) at org.apache.jasper.servlet.TldScanner.scan(TldScanner.java:104) at org.apache.jasper.JspC.initServletContext(JspC.java:1540) at org.apache.jasper.JspC.execute(JspC.java:1383) at io.leonard.maven.plugins.jspc.JspcWorker.call(JspcWorker.java:27) at io.leonard.maven.plugins.jspc.JspcWorker.call(JspcWorker.java:9) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

mars 07, 2018 9:00:48 PM org.apache.jasper.servlet.TldScanner scanJars INFOS: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. [INFO] Number total of jsps : 1 [ERROR] org.apache.jasper.JasperException: file:/home/thomas/dev/JSPC%20Example/moduleA/src/main/webapp/index.jsp (line: 4, column: 0) Unable to load tag handler class "com.example.plugin.jspc.tag.HelloTag" for tag "ex:Hello"

tcollignon commented 6 years ago

Thx @tbertrand1 with your precious help, I have reproduce the bug here : https://github.com/leonardehrenfried/jspc-maven-plugin/pull/23/commits/3e36d18da37b38cbd86c0e7368e0a6bc4ce3f839

tcollignon commented 6 years ago

I have fix this by rollback code, like you said in your first comment. That's not satisfy me but for now I don't have other idea. If you have one I'm will be happy to know, otherwise we can merge PR as is, and roll another release

tbertrand1 commented 6 years ago

Sadly I don't have a better solution. When I saw the problem I have tried to find a solution but it's not so easy.

tcollignon commented 6 years ago

Yes it needs to rewrite a part of the plugin to avoid using both File.toUrl and URLClassloader. I don't have time to do this actually. @leonardehrenfried can you merge the PR and release please? Can you bump to 2.5.0-SNAPSHOT after that ?

Thx

leonardehrenfried commented 6 years ago

Yes, will merge and release today.

Am 12.03.2018 21:21 schrieb "COLLIGNON Thomas" notifications@github.com:

Yes it need to rewrite a part of the plugin to avoid using both File.toUrl and URLClassloader. I don't have time to do this actually. @leonardehrenfried https://github.com/leonardehrenfried can you merge the PR and release please? Car you bump to 2.5.0-SNAPSHOT after that ?

Thx

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/leonardehrenfried/jspc-maven-plugin/issues/22#issuecomment-372449413, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJPMjupp46m27Oj5ExZ72GZ6ibIgFPNks5tdtjHgaJpZM4STW-Y .

leonardehrenfried commented 6 years ago

2.4.5 has been released. Will be available on Maven Central in ~ 15 minutes.

tbertrand1 commented 6 years ago

I just upgraded the version to 2.4.5 on my project and it works fine. @leonardehrenfried @tcollignon Thank you!