3

I'm developing a simple web application in Java, but since I've changed my computer from win7 to mac os, i can't deploy my application. Before the SO change my compiled code/war from intellij was deployed to debian with no problem. Now I get this (anoying) error:

An error occurred at line: [1] in the generated java file: [/var/lib/tomcat8/work/Catalina/localhost/chat/org/apache/jsp/index_jsp.java]
The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files

Stacktrace:
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:199)
    org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:438)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:361)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:405)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:349)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

In both machines I have installed JDK8 and Tomcat8. Debian CPU is a ARMv6, a raspberry pi. My Mac OS is x64 from mid 2012. I already search over the web, try to update Tomca8, compile to java7 and deploy to a Tomcat7 instance, its driving me crazy!! I think this may be a cross platform problem, or something to do with class compilations, but I cannot find what!

Any help is much appreciated, Thanks

rmpt
  • 606
  • 1
  • 4
  • 24
  • 1
    possible duplicate of [Error when using LogManager (l4j2) with Java 8 (java.lang.reflect.AnnotatedElement cannot be resolved)](http://stackoverflow.com/questions/26102115/error-when-using-logmanager-l4j2-with-java-8-java-lang-reflect-annotatedeleme) – Holger Dec 08 '14 at 20:14
  • I saw Holger response about java.util.Map$Entry, but in my case, the IDE run just fine, with the same version of Tomcat and JDK (both 8) of the server. The problem is in the server (or on compilation time on IDE), the version that works on IDE doesn't work on the server. – rmpt Dec 09 '14 at 09:29
  • 2
    The type `JDTCompiler` that appears in the stack trace suggests that Tomcat/Jasper uses the eclipse compiler for compiling JSP sources (originating from the Eclipse module **JDT**). That compiler version doesn’t have to be the same as in your Eclipse IDE. So you have to either update the JDT used by Tomcat or reconfigure it to use ant/javac rather than jdt/ecj… – Holger Dec 09 '14 at 09:49
  • I'm using Intellij Idea, not Eclipse. But the compiled classes shouldn't work independently of the compiler? As I use the same version of the JDK in both sides, it should work right? – rmpt Dec 09 '14 at 10:08
  • 1
    look at your stack trace. It tries to compile JSP files (or something related) which are basically Html pages with embedded Java *Source Code*. And it does so using the `JDTCompiler` adapter which uses Eclipse JDT which is in no way related to the JRE/JDK you are using. So if you didn’t install it by hand, it has to be bundled with your tomcat and I don’t know whether you can update it. However, the existence of an adapter suggests that this behavior is pluggable, you *can* configure it to use `javac`. – Holger Dec 09 '14 at 10:13
  • In order to test that it seems that I have to change web.xml file and maybe remove some jars from CATALINE_HOME. Strange because I never had this problem before, always using Intellij Idea vs Tomcat. THe only difference is the version of Tomcat and JDK (I've updated to v8) and my IDE is running under Mac OS. Anyway, I'll give it a try later and let you know.Thanks for your help Holger – rmpt Dec 09 '14 at 10:19
  • 1
    As said, it’s not related to `Intellij`. It’s the Eclipse JDT bundled with Tomcat which can’t handle Java 8 class files. If you follow to the question I have linked and look at [its “Linked” section](http://stackoverflow.com/questions/linked/26102115?lq=1) you will see lots of similar questions. – Holger Dec 09 '14 at 10:23
  • Yes, I understood the problem, I was only saying that in many time I've never had to change any config about the compiler, with the exact same scenario. – rmpt Dec 09 '14 at 10:27
  • 1
    As said in the answer to the linked question: “Sometimes you can get away with an older compiler when it ignores the newer version number of the class files.” That’ll work as long as none of the referenced class files uses features over which the compiler stumbles. Regarding Java 8, only interfaces using `static` or `default` methods (or classes depending on them) have that potential. – Holger Dec 09 '14 at 10:32
  • I tryed to set javac compiler instead of JDT, but with no success... Getting same error. I've changed /etc/default/tomcat8 JSP_COMPILER property to javac, nothing changes. A part of that, I also set /etc/tomcat8/web.xml compilerSourceVM and compilerTargetVM to 1.8, no success... any sugestion? So frustrating... :( – rmpt Dec 09 '14 at 22:05
  • I only noticed now, that if I refresh the page, I get a different error! And if I refresh again, I get the preivous... java.lang.ClassNotFoundException: org.apache.jsp.index_jsp – rmpt Dec 09 '14 at 22:12
  • trying with Jetty8, same error... NO JSP Support for , did not find org.apache.jasper.servlet.JspServlet There's something missing here, that's for sure.... – rmpt Dec 09 '14 at 22:39
  • It would be useful to post that different error. Maybe you get the old error afterwards because it tries to recover by using an alternative compiler (which happens to be the former) after the error. I don’t know whether tomcat uses `javac` from the JDK or a bundled (then also outdated) `javac`. In the latter case there’s no way around replacing on of the bundled compilers. – Holger Dec 10 '14 at 09:13

2 Answers2

1

After many research and tests I couldn't solve this problem. My solution (that is not a real solution) for keep developing was replace all 8 version (jdk and tomcat) by version 7, both JDK and server (Tomcat). An important note is to use OpenJDK and NOT Oracle JDK. I know, it seems contradictory but in the end it seems that OpenJDK install the necessary and right compilers. I didn't test with OpenJDK version 8 because my project only requires version 7, but for someone with the same problem, it worth to give a try with OpenJDK 8.

Hope this help someone and if anyone has any suggestion for the real solution, just past it.

rmpt
  • 606
  • 1
  • 4
  • 24
0

For me, the solution was to use a later version of the ecj jar, version ecj-4.4.2.jar

webber55
  • 329
  • 4
  • 13