Can not generate Java 11 JSP
UNMLMS opened this issue · 21 comments
Can not generate Java 11 JSP class files.
Using 11 generates Java 1.8 (major number 52) JSP class files.
Also get:
WARNING: Unknown source VM 11 ignored.
Mar 19, 2019 10:30:27 AM org.apache.jasper.compiler.JDTCompiler generateClass
WARNING: Unknown target VM 11 ignored.
Mar 19, 2019 10:30:30 AM org.apache.jasper.JspC execute
INFO: Generation completed with [0] errors in [11827] milliseconds
Firstly, are you using the latest version of the plugin?
Secondly, do you need to generate java 11 files? Java is strongly backwards compatible and java 11 can use java 8 source and class files just fine, isn't it?
Using version 3.0.0
Using 11
Using compilerVersion 11 in plugin configuration
Hello,
Ok I will try to reproduce your case to understand the problem
The problem is in Tomcat. It not already handle Java 11 (only Java10 and lower).
See this in https://github.com/apache/tomcat/blob/master/java/org/apache/jasper/compiler/JDTCompiler.java
See PR #40
I will try to fix this in Tomcat.
Other solution is to make your own JdtCompiler specific class who redefine generateClass method to add Java 11 mapping.
And I have put a new compiler in PR #40 who handle all Java version : org.apache.jasper.compiler.JspcMojoJDTCompiler
So with this configuration it works :
<plugin> <groupId>io.leonard.maven.plugins</groupId> <artifactId>jspc-maven-plugin</artifactId> <configuration> <compilerVersion>11</compilerVersion> <compilerClass>org.apache.jasper.compiler.JspcMojoJDTCompiler</compilerClass> </configuration> </plugin>
I have open this PR in Tomcat project : apache/tomcat#150
With compilerVersion 11 and compilerClass org.apache.jasper.compiler.JspcMojoJDTCompiler get:
Mar 20, 2019 11:05:52 AM org.apache.jasper.JspC execute
SEVERE: org.apache.jasper.JasperException: java.lang.IllegalStateException: No Java compiler available for configuration options compilerClassName: [org.apache.jasper.compiler.JspcMojoJDTCompiler] and compiler: [null]
Mar 20, 2019 11:05:52 AM org.apache.jasper.JspC execute
SEVERE: org.apache.jasper.JasperException: java.lang.IllegalStateException: No Java compiler available for configuration options compilerClassName: [org.apache.jasper.compiler.JspcMojoJDTCompiler] and compiler: [null]
Mar 20, 2019 11:05:52 AM org.apache.jasper.JspC execute
SEVERE: org.apache.jasper.JasperException: java.lang.IllegalStateException: No Java compiler available for configuration options compilerClassName: [org.apache.jasper.compiler.JspcMojoJDTCompiler] and compiler: [null]
Mar 20, 2019 11:05:52 AM org.apache.jasper.JspC execute
SEVERE: org.apache.jasper.JasperException: java.lang.IllegalStateException: No Java compiler available for configuration options compilerClassName: [org.apache.jasper.compiler.JspcMojoJDTCompiler] and compiler: [null]
Error Count: 4
[INFO] Number total of jsps : 4
[ERROR] Generation completed with [4] errors in [325] milliseconds
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
Using version 3.0.0 -- Please confirm version to use.
No this new compiler os only on the pull request #40, not actually merged, so the plugin is not release with it.
Next version will be 3.1.0 .
Version 3.1.0 is now available : http://repo1.maven.org/maven2/io/leonard/maven/plugins/jspc-maven-plugin/3.1.0/
Tell us if it fix your problem
Note : PR on tomcat project is still open
Sorry - get BUILD SUCCESS
But JSP class files Java 1.8 (major number 52)
Sorry - get BUILD SUCESS and JSP class files Java 11 (major number 55)
Thank You
Good !
thx for the feedback @UNMLMS
Hi,
I have issues, when I use this plugin, I get an error related to switch case, my object is an enum and it looks like it is not recognizing, I'm using jdk11, in the past this error never throwed but with a different jspc plugin:
Compilation error message:
Cannot switch on a value of type MyEnum. Only convertible int values, strings or enum variables are permitted
I need to specify which tomcat version should use? I didn't.
Here my pom.xml plugin:
<plugin>
<groupId>io.leonard.maven.plugins</groupId>
<artifactId>jspc-maven-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<compilerVersion>11</compilerVersion>
<compilerClass>org.apache.jasper.compiler.JspcMojoJDTCompiler</compilerClass>
<generatedClasses>${basedir}/target/jsp-source/</generatedClasses>
</configuration>
<executions>
<execution>
<?m2e execute onConfiguration?>
<id>jspc</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
Hi @lizgamarra
Please attach a small project to reproduce your issue
I will take a look if I can
Hi,
Sure, attached is a JSP with the same approach where I was also able to see the same compilation error
test.zip
Hi @tcollignon did you have the chance to replicate? Looks like it is not allowing switch case strings either.
Hello, I try to take a look à this next week
Hello @lizgamarra ,
please provide a small project, with structure and minimal pom to reproduce, its easy for me
thx