Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Jasper Exception when using Tomcat 9 but works with Tomcat 5.5

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been tasked with migrating a site from one institution to another. As part of the process we are attempting to update the versions the site uses.

Initially I was asked to use Java 8 with Tomcat 5.5 (on Linux), which led to issues - not to mention Tomcat 5 being 'out of support'.

I have since tried to deploy the webapps to Tomcat 9 with Java 8. Some of the webapps appear to run fine (and resolve the issues I was having with Tomcat5). However, the main app (and 2 similar/smaller web apps) throws a JasperException when I go to the index.jsp - the same web apps deployed to Tomcat 5.5 load without issue.

Most of the similar issues I have found have suggested this would be related to the jar files and possibly some sort of conflict. However, the lib structure for tomcat 9 is different to tomcat5 and I'm not sure which jars could be causing this.
e.g. https://stackoverflow.com/questions/22552244/tomcat-7-fails-to-compile-jsp-pages

I've also tried changing the index.jsp into a simpler (HelloWorld) form - removing any code. And tried deleting the 'work' directory before restarting Tomcat (http://grokbase.com/t/tomcat/users/072v2kf60h/java-permission-denied-error-in-tomcat).  In both cases the exception is still thrown.

Has anyone experienced a similar problem and/or have any advice?

Thanks.
 
Sean Brett
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The exception is:

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: [15] in the generated java file: [/opt/tomcat9/work/Catalina/localhost/home/org/apache/jsp/index_jsp.java]
The type index_jsp must implement the inherited abstract method JspSourceImports.getPackageImports()

An error occurred at line: [15] in the generated java file: [/opt/tomcat9/work/Catalina/localhost/home/org/apache/jsp/index_jsp.java]
The type index_jsp must implement the inherited abstract method JspSourceImports.getClassImports()

An error occurred at line: [15] in the generated java file: [/opt/tomcat9/work/Catalina/localhost/home/org/apache/jsp/index_jsp.java]
The type index_jsp must implement the inherited abstract method JspSourceDependent.getDependants()

An error occurred at line: [22] in the generated java file: [/opt/tomcat9/work/Catalina/localhost/home/org/apache/jsp/index_jsp.java]
The type Map is not generic; it cannot be parameterized with arguments <String, Long>

An error occurred at line: [24] in the generated java file: [/opt/tomcat9/work/Catalina/localhost/home/org/apache/jsp/index_jsp.java]
The type Set is not generic; it cannot be parameterized with arguments <String>

An error occurred at line: [26] in the generated java file: [/opt/tomcat9/work/Catalina/localhost/home/org/apache/jsp/index_jsp.java]
The type Set is not generic; it cannot be parameterized with arguments <String>

An error occurred at line: [29] in the generated java file: [/opt/tomcat9/work/Catalina/localhost/home/org/apache/jsp/index_jsp.java]
_jspx_imports_packages cannot be resolved to a variable

...
...
...

Stacktrace:
   org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
   org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:213)
   org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:458)
   org.apache.jasper.compiler.Compiler.compile(Compiler.java:389)
   org.apache.jasper.compiler.Compiler.compile(Compiler.java:361)
   org.apache.jasper.compiler.Compiler.compile(Compiler.java:345)
   org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:603)
   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
   org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
   edu.purdue.cybercenter.ionomics.servlet.PiiMS.doGet(PiiMS.java:83)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
   org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
 
Saloon Keeper
Posts: 22248
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A very rough guess is that you are trying to copy over pre-compiled JSPs and the pre-compiled code isn't compatible. You should be able to delete the offending files and have Tomcat rebuild them. To do this:

1. Stop Tomcat
2. Remove all files and directories under TOMCAT_HOME/temp and TOMCAT_HOME/work.
3. Restart Tomcat

I am not a big fan of pre-compiling JSPs. Tomcat's normal Just-in-Time approach usually works well enough, especially on today's faster processors and JVMs. It would take a very unusual set of circumstances for me to recommend pre-compiling.

Of course, if your app-building process does pre-compile JSPs, make sure that you're using the Tomcat9 Jasper compiler, not an old (Tomcat 5) one!
 
Sean Brett
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your assistance Tim.  Following some pointers on the Tomcat Mailing List, it looks like the cause of this case was rt.jar in the webapps WEB-INF/lib directory.  Removing that, recreating the war and deploying the issue went away.
 
Tim Holloway
Saloon Keeper
Posts: 22248
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. Don't copy anything from the JDK/JRE or J2EE directories into your WAR files. They are already where they need to be.
 
If you're gonna buy things, buy this thing and I get a fat kickback:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic