• Post Reply Bookmark Topic Watch Topic
  • New Topic

Added one line of text to a single JSP (in notepad) in web app (while it was running)

 
Tommy Griffith
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't redeploy the war but thought I could just change one line of text "on the fly". Then I received the error below. The rest of the servlet works ok, I just can't figure out how a JSP is :compiled". In other words, it's looking for Java 4 (48.0) with this JSP while Tomcat is running on Java 5. Does anybody know how to get around this, it's not a java file, just a simple JSP. I thought JSP, you just save the file and that's it, there's no javac. Thank you.

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

An error occurred at line: -1 in the jsp file: null

Generated servlet error:
[javac] Compiling 1 source file

C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\Certification\org\apache\jsp\Hi_jsp.java:7: cannot access java.lang.Object
bad class file: C:\Program Files\Java\jre1.5.0_11\lib\rt.jar(java/lang/Object.class)
class file has wrong version 49.0, should be 48.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
public final class Hi_jsp extends org.apache.jasper.runtime.HttpJspBase
 
Stefan Evans
Bartender
Posts: 1822
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

With regards to JSP "just being saved - there is no javac".
There IS a javac/compile step - it just happens behind the scenes. The Servlet container takes your JSP, converts it into java code (a servlet) and then compiles that servlet.
If you take a look in the work directory of Tomcat, you can see the compiled class files and possibly (maybe you need to switch it on first?) the generated servlet .java files as well.


You're using Tomcat 5.0?

Tomcat 5 was when they started using the JDT compiler to compile JSP files by default rather than javac. (https://tomcat.apache.org/tomcat-5.5-doc/jasper-howto.html)
That meant you could run Tomcat on a JRE, and no longer required a JDK.
At the time of release however, the JDT compiler only supported java 1.4.

I think you can fix this in your current installation by tweaking the compiler parameter of the JSP Servlet in $CATALINA_BASE/conf/web.xml.
I can't remember the exact details of WHAT to set that parameter to unforunately, but there are some pointers on that page I linked.

Alternatively installing a newer version of Tomcat (5.5 minimum, and the latest version of Tomcat by preference) will probably resolve the issue.



 
Tommy Griffith
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Stefan. So, I have Tomcat 5 running on jre 5.0_11.

I save the simple JSP "on the fly" within the running web app (File-Save in Notepad) and it throws the version error.

This is because the "new" JDT compiler Tomcat 5 is attempting to compile with jre 1.4 but this Tomcat is configured for jre 5.0.11, right?


But what about before I made the "on the fly" change, the JSP was working in this Tomcat environment. All I did a few years ago (on a previous pc, probably running sdk 1.4) was save a JSP within a local war, jar -cvf on the war, and deployed the war to ~this~ Tomcat. When would that original JSP been compiled, wouldn't it throw the same error at deployment or was the original somehow compiled locally (by jar -cvf)??

I guess I'm not sure when the original JSP is compiled, I would think when it was deployed...but then I'm not sure why the original deploys ok (I would think it'd use the "new" JDT complier as well) but then the "on the fly" change throws the version error.

Thank you so much again.
 
Stefan Evans
Bartender
Posts: 1822
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess its a question of when it got compiled, and when the Jre5 got installed?
This post also has some suggestions: http://www.coderanch.com/t/375371/java/java/WRONG-CLASS-FILE-COMPILING-JSP
I'd forgotten about tools.jar - it's been so long since I had to deal with it :-)

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!