-
Notifications
You must be signed in to change notification settings - Fork 762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to compile class for JSP #1303
Comments
Tomcat is running on Oracle Java 8 tomcat7 22236 1 11 02:50 ? 00:00:17 /usr/lib/jvm/java-8-oracle/bin/java -Djava.util.logging.config.file=/var/lib/tomcat7/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.awt.headless=true -Xmx128m -XX:+UseConcMarkSweepGC -Djava.endorsed.dirs=/usr/share/tomcat7/endorsed -classpath /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar -Dcatalina.base=/var/lib/tomcat7 -Dcatalina.home=/usr/share/tomcat7 -Djava.io.tmpdir=/tmp/tomcat7-tomcat7-tmp org.apache.catalina.startup.Bootstrap start |
Oooks like you are compiling with jsva older than 1.8. We should check for java version in early stages of build. |
Only Tomcat8 + java8 |
Java is 1.8 for compile using ANT and running on Java 1.8. Both Oracle instance. I update the a couple lines like projects = new TreeSet<>(); and now everything works. |
I just forked the code and updated the file to be more compatible. |
Let's keep this open to track the addition of Java version check for ant/maven. |
Actually, ant/maven check will not help here - this is about JSP compilation in Tomcat, sorry for the confusion. Not sure if it is possible to check Java version in Tomcat when deploying the war. Still, this looks like Tomcat misconfiguration. Even though it seems to be running Java 8, it tries to compile with Java 7. |
Maybe you could check all available Java versions on the machine and if Java 7 (JDK or JRE) is installed, try to uninstall, restart Tomcat and see what happens (with the original unmodified files containing the diamond operator). |
Exactly my thoughts, this is not compiled with java 8. |
I just re-run Ant in verbose mode and got Java-8, is there any other settings I should look for? I got it working on my fork Apache Ant(TM) version 1.9.6 compiled on July 8 2015 |
Is there some other stuff under Also, what Tomcat 7 version are you running exactly ? |
Any chance of trying Tomcat 8 ? |
Thinking aloud: I wonder if there is a way how to check Tomcat version (and incidentally Java version the Tomcat is using) from within the webapp when it is being deployed. |
/usr/share/tomcat7/bin @ IRVOpenGrok(procon): ./catalina.sh version |
Okay. I was asking because saw some reports of Tomcat 7 not working properly with Java 8 up to some minor version (7.0.50). Anyway. your safest bet is to try Tomcat 8. |
Additional measure would be to tune the |
I tried getting Tomcat8 up but I have too many configurations to play with, so I just forked and updated the one file and recompiled. Seems to work great now. Plus I wanted to add support for Groovy via the Java Analyzer. https://github.com/bnortman/OpenGrok-Groovy |
I was hoping to get to the bottom of this. Clearly, the Java version Tomcat is running under does not have direct bearing on the JSP compiler in the same Tomcat. Either, the compiler somehow prefers Java 1.7 which is present on the system (otherwise there would be no complaint about the diamond operator which is native in Java 1.8) or it is configured to use Java 1.7 directly in the As for the Groovy support, feel free to create pull req. |
Hello,
I first purged everything that wasn't java-8-oracle but that was not sufficient!
I solved the JSP compile issues by adding the following to glassfish4/glassfish/domains/domain1/config/default-web.xml
|
It's possible to override the default tomcat7 1.6 value with 1.7 (or 1.8) in our <servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>compilerSourceVM</param-name>
<param-value>1.7</param-value>
</init-param>
<init-param>
<param-name>compilerTargetVM</param-name>
<param-value>1.7</param-value>
</init-param>
</servlet> |
I was getting the same error, I solved it with just changing an ArrayList declaration from this "new ArrayList<>();" to this "new ArrayList(); " |
HTTP Status 500 - Unable to compile class for JSP:
type Exception report
message Unable to compile class for JSP:
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 55 in the jsp file: /menu.jspf
'<>' operator is not allowed for source level below 1.7
52: ProjectHelper ph = ProjectHelper.getInstance(cfg);
53: Set projects = ph.getAllProjects();
54: if (projects == null) {
55: projects = new TreeSet<>();
56: }
57: int projectsSize = ph.getAllUngrouped().size();
58: if (ph.getGroups().size() > 0 && ph.getAllUngrouped().size() > 0)
An error occurred at line: 64 in the jsp file: /menu.jspf
'<>' operator is not allowed for source level below 1.7
61: projectsSize++;
62: projectsSize += ph.getAllGrouped(group).size();
63: }
64: TreeMap<String, String> pMap = new TreeMap<>();
65: QueryBuilder queryParams = cfg.getQueryBuilder();
66: if (projects.size() != 0) {
67: for (Project p : projects) {
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:104)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:366)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:490)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:379)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:341)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:662)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:364)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.opensolaris.opengrok.web.AuthorizationFilter.doFilter(AuthorizationFilter.java:60)
The text was updated successfully, but these errors were encountered: