• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unable to compile class for JSP

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can someone help me with this error? The only thing I can figure out from it is that Tomcat is having trouble compiling one of my JSPs. Not where or why.
 
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Easiest way is to check out the java source file it's generated... You'll probalby spot it almost immediately.
The generated java files live in the tomcat work directory.
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
usually a "compiler" error of "-1 in the jsp file: null" means that Tomcat is unhappy with CATALINA_HOME, JAVA_HOME or the JVM/JRE/JDK

Make sure there are no spaces in the *_HOME variables, and that you are using a JDK, not just JRE. If you're running Tomcat as a service on Windows, ensure that the service is being started with an appropriate VM.
 
Michael Brewer
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mike Curwen:
usually a "compiler" error of "-1 in the jsp file: null" means that Tomcat is unhappy with CATALINA_HOME, JAVA_HOME or the JVM/JRE/JDK

Make sure there are no spaces in the *_HOME variables, and that you are using a JDK, not just JRE. If you're running Tomcat as a service on Windows, ensure that the service is being started with an appropriate VM.


I made sure that my CATALINA_HOME and JAVA_HOME vars are pointing to the correct locations and they are: D:\ALM\Java\Apache_Group\Tomcat_4.1 and D:\ALM\Java\j2sdk1.4.2_01 respectively. My path contains the following Java-related paths (CRs for legibility):
D:\ALM\Java\Apache_Group\Tomcat_4.1\bin;
D:\ALM\Java\j2sdk1.4.2_01\bin;
D:\ALM\Java\j2sdk1.4.2_01\jre\bin;
D:\ALM\Java\j2sdk1.4.2_01\jre\bin\server;
D:\ALM\Java\j2sdk1.4.2_01\jre\bin\client;
I'm stuck. I'd appreciate any additional pointers.
[ November 24, 2003: Message edited by: Michael Brewer ]
 
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Michael, try the following workaround:
* Add an entry to the CLASSPATH: D:\ALM\Java\j2sdk1.4.2_01\jre\lib
* Copy jsp-api.jar (or whatever you have for your Tomcat implementation) from $tomcat_dir\common\lib into D:\ALM\Java\j2sdk1.4.2_01\jre\lib\ext and add D:\ALM\Java\j2sdk1.4.2_01\jre\lib\ext to your CLASSPATH.
Sometimes, this works.
 
Michael Brewer
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Vad Fogel:
Hi Michael, try the following workaround:
* Add an entry to the CLASSPATH: D:\ALM\Java\j2sdk1.4.2_01\jre\lib
* Copy jsp-api.jar (or whatever you have for your Tomcat implementation) from $tomcat_dir\common\lib into D:\ALM\Java\j2sdk1.4.2_01\jre\lib\ext and add D:\ALM\Java\j2sdk1.4.2_01\jre\lib\ext to your CLASSPATH.
Sometimes, this works.


I don't have jsp-api.jar in my implementation, but I do have jasper-common.jar and jasper-runtime.jar, so I copied those as you said, but I'm still getting the same error.
[ November 24, 2003: Message edited by: Michael Brewer ]
 
Vad Fogel
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm, that doesn't feel like ClassNotFoundException or can't-resolve-symbol errors. Maybe, you have an error in your source code? Can you drop it here if it's not too large?
 
Michael Brewer
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just reinstalled Tomcat with examples this time and even the examples won't compile. It must be a problem with my J2SE environment. I'm using 1.4.2_01. I'm going to see what I can do there. Thanks for the help guys, I may be back with more questions, but hopefully I'll be back with the solution.
 
Michael Brewer
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, after I got back from vacation and re-installed my environment I was able to get a root cause error to why the JSP can't be compiled. And it's puzzling me. I just moved this code from JRun to Tomcat and it worked under JRun.

Is throwing a NullPointerException when Tomcat tries to compile my JSP. This line is in a class that is called by my JSP. The odd thing is that when I run javac to compile the class, no NullPointerException is thrown. Connection.html#createStatement() doesn't say that this method will throw a NullPointerException.
If anyone has any ideas what I should, I'd greatly appreciate it.
 
Michael Brewer
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I RETURN WITH THE SOLUTION!
I discovered the cause of my problems. Looking at the stdoutlog revealed a ClassNotFoundException when trying to load the MS SQL Server 2000 JDBC driver. After making sure the paths were in both the CLASSPATH environment variable and the setclasspath.bat file as well as uninstalling the SQL Server JDBC drivers and reinstalling them to a folder hierarchy that didn't have any spaces in it, I finally found this discussion which introduced me to the solution to my problem: move the three MS SQL JDBC JAR files into %TOMCAT_HOME%/common/lib/.
Unfortunately, that discussion doesn't say why this step is required. Can someone explain to me why I needed to put those three JAR files in /common/lib/ when they were already sepcified in the classpath?
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's because Tomcat doesn't use a system CLASSPATH to setting.

If you mean that you set it in the CLASSPATH settings used in the Tomcat startup script... then that won't really help either.

So because it's in system CLASSPATH, it will probably compile, but when your web-app actually wants to use it, it must be found somewhere in the Tomcat classloader heirarchy:

http://jakarta.apache.org/tomcat/tomcat-4.1-doc/class-loader-howto.html
 
Michael Brewer
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now I just finished reading http://jakarta.apache.org/tomcat/tomcat-4.1-doc/printer/class-loader-howto.html and come back here and see someone posted a pointer to it. (why isn't reply notification working?)
The how-to does say "however, the standard Tomcat 4 startup scripts $CATALINA_HOME/bin/catalina.sh or %CATALINA_HOME%\bin\catalina.bat) totally ignore the contents of the CLASSPATH environment variable itself". I would think the use of the phrase "standard Tomcat 4 startup scripts" would mean that you could have Tomcat load everything from setclasspath.bat while the System classloader is loading which would seem to me to be the only purpose for the setclasspath.bat file.
However, now after reading it I see that I probably shouldn't be loading JDBC drivers with the System classloader and in fact shouldn't be loading them with the Common classloader as the linked discussion recommends. I should put the SQL Server JDBC JARs into the %CATALINA_HOME%/shared/lib/ folder instead.
[ January 14, 2004: Message edited by: Michael Brewer ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic