Solved

Unable to compile class for JSP

Posted on 2004-10-19
11
956 Views
Last Modified: 2008-04-12
Hi,

I'm new to jsp and when I tried to create a jsp page w/ ejb.  After I deployed the app, I get this error message when I'm trying to access the page from IE:

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

No Java compiler was found to compile the generated source for the JSP.

Also where is the tomcat server located?  What exe does tomcat run?  I need this to copy the tools.jar file to the tomcat server directory.

Thanks.

entire error message:
-----------------------------------------------------------------
org.apache.jasper.JasperException: Unable to compile class for JSP

No Java compiler was found to compile the generated source for the JSP.
This can usually be solved by copying manually $JAVA_HOME/lib/tools.jar from the JDK
to the common/lib directory of the Tomcat server, followed by a Tomcat restart.
If using an alternate Java compiler, please check its installation and access path.

      org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:87)
      org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:311)
      org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:378)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:421)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:402)
      org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:512)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:262)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:263)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:210)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:861)
      sun.reflect.GeneratedMethodAccessor72.invoke(Unknown Source)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      java.lang.reflect.Method.invoke(Method.java:324)
      org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:246)
      java.security.AccessController.doPrivileged(Native Method)
      javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
      org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:268)
      org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:162)

0
Comment
Question by:skip1000
  • 6
  • 5
11 Comments
 
LVL 19

Accepted Solution

by:
ramazanyich earned 500 total points
ID: 12346733
To compile JSP pqges you need java compiler. It is bundled with JDK (you can download it from java.sun.com). So you need point Tomcat' s JAVA_HOME variable to the JDK directory.
For example if you installed JDK into c:/j2sdk1.4.2
then in startup.bat of Tomcat put at the beginning of bat file:
set JAVA_HOME=c:/j2sdk1.4.2
0
 

Author Comment

by:skip1000
ID: 12346912
That did not work and I tried a whole bunch of other things also.  Where is common/lib directory of Tomcat server?
0
 
LVL 19

Expert Comment

by:ramazanyich
ID: 12346978
Then  copy $JAVA_HOME/lib/tools.jar to $TOMCAT_HOME/common/lib directory
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:skip1000
ID: 12347100
what is $TOMCAT_HOME directory?  I have no idea what the directory is named by default.  I don't see any directory called tomcat per se.  Any suggestions?
0
 
LVL 19

Expert Comment

by:ramazanyich
ID: 12347121
it can be called jakarta-tomcat-x.x.xx where x.x.xx should be substituted by tomcat version number
0
 
LVL 19

Expert Comment

by:ramazanyich
ID: 12347140
Do you know where startup.bat file of Tomcat is ???
then you will find common:lib directory easily:
$Tomcat_home
    bin
       startup.bat
    common
         lib
0
 

Author Comment

by:skip1000
ID: 12347707
I should mention I'm using J2ee 1.4 and the command for "start default server" is
"C:\Sun\AppServer\lib\asadmin-pause.bat start-domain domain1".  I've search high and low for any directory named common and the only ones found are in the sample directories (which can't be right).  I've copied the file in several lib directories w/in AppServer directory and that did not do the trick.
0
 
LVL 19

Expert Comment

by:ramazanyich
ID: 12347857
then check your c:\sun\appserver\config\asenv.bat file. Find AS_JAVA variable and check that it points correctly to your JDKhoem directory. On ly PC it is:
set AS_JAVA=C:\j2sdk1.4.2
0
 

Author Comment

by:skip1000
ID: 12348808
I've changed it from
set AS_JAVA=C:\Sun\AppServer\jdk
to
set AS_JAVA=C:\j2sdk1.4.2_05

I'm wondering if it could be a problem w/ the jsp file I am testing.  The tutorial example all worked, but my first attempt to create a jsp test app gave the error you saw earlier.  I don't know if the J2EE tutorial example even requires compiling the JSP's before running them.  I was able to deploy my project files earlier, but now I can't b/c I overwrote the ear file accidentally.  I need to retrace my steps.
0
 

Author Comment

by:skip1000
ID: 12359262
I managed to get past that error, and a few things happened along the way.  I can't quite remember exactly what happened.  Among the errors encountered, I was missing package in my bean, resource ref for my ejb, and I think that the log viewer in admin console actually displayed the correct jsp error message.  

The message I first displayed was bogus.  It was not the real error.  The real error was something else.  Look at the log viewer and you will see all the messages logged.  Look at the detail message of the severe errors.  I believe they will show compile errors.  They should be the 2nd or 3rd error message in the log viewer that's the real source of the problem.  The error I printed above is the topmost error message in the log viewer that is why it is displayed.  It's deceiving b/c there is nothing wrong w/ my environment variable settings.
0
 

Author Comment

by:skip1000
ID: 12359285
I am awarding points, but pls read my last comment.  It is important.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How To Remove a Principal from HttpServletRequest 4 44
trouble with PDF encryption using itext-1.3.1 17 84
jdbc error in jsp application 20 44
jsp login check 12 28
One of the biggest threats facing all high-value targets are APT's.  These threats include sophisticated tactics that "often starts with mapping human organization and collecting intelligence on employees, who are nowadays a weaker link than network…
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now