*
The moose likes Tomcat and the fly likes Run jsp: Unable to find a javac compiler Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Run jsp: Unable to find a javac compiler" Watch "Run jsp: Unable to find a javac compiler" New topic
Author

Run jsp: Unable to find a javac compiler

Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 666
I always get this error when I run simple jsp files in my Tomcat 5.0.19/win2000.
These jsp files run on other versions of Tomcat on the same PC.
Any ideas?
Complete console messages. You can see tools.jar IS in the classpath.
========================================================================
Apr 15, 2004 9:26:06 AM org.apache.jasper.compiler.Compiler generateClass
SEVERE: Javac exception
Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK
at org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCom
piler(CompilerAdapterFactory.java:139)
at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:835)
at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:682)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:390)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:458)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext
.java:553)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:291)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
01)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:284)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:204)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:257)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:567)
at org.apache.catalina.core.StandardContextValve.invokeInternal(Standard
ContextValve.java:245)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:199)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:509)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:567)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:184)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:164)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:567)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:156)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:567)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:20
6)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:833)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:732)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
:619)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:688)
at java.lang.Thread.run(Thread.java:534)
Apr 15, 2004 9:26:06 AM org.apache.jasper.compiler.Compiler generateClass
SEVERE: Env: Compile: javaFileName=/C:/tomcat5019/work/Catalina/localhost/jsp-ex
amples//org/apache/jsp/dates\date1_jsp.java
classpath=/C:/tomcat5019/webapps/jsp-examples/WEB-INF/classes/;/C:/tomcat501
9/webapps/jsp-examples/WEB-INF/lib/jstl.jar;/C:/tomcat5019/webapps/jsp-examples/
WEB-INF/lib/standard.jar;C:\tomcat5019\work\Catalina\localhost\jsp-examples;/C:/
tomcat5019/webapps/jsp-examples/WEB-INF/classes/;/C:/tomcat5019/webapps/jsp-exam
ples/WEB-INF/lib/jstl.jar;/C:/tomcat5019/webapps/jsp-examples/WEB-INF/lib/standa
rd.jar;C:/tomcat5019/shared/classes/;C:/tomcat5019/common/classes/;C:/tomcat5019
/common/endorsed/xercesImpl.jar;C:/tomcat5019/common/endorsed/xmlParserAPIs.jar;
C:/tomcat5019/common/lib/ant.jar;C:/tomcat5019/common/lib/commons-collections.ja
r;C:/tomcat5019/common/lib/commons-dbcp-1.1.jar;C:/tomcat5019/common/lib/commons
-el.jar;C:/tomcat5019/common/lib/commons-pool-1.1.jar;C:/tomcat5019/common/lib/j
asper-compiler.jar;C:/tomcat5019/common/lib/jasper-runtime.jar;C:/tomcat5019/com
mon/lib/jmx.jar;C:/tomcat5019/common/lib/jsp-api.jar;C:/tomcat5019/common/lib/na
ming-common.jar;C:/tomcat5019/common/lib/naming-factory.jar;C:/tomcat5019/common
/lib/naming-java.jar;C:/tomcat5019/common/lib/naming-resources.jar;C:/tomcat5019
/common/lib/servlet-api.jar;/C:/j2sdk1.4.2/lib/tools.jar;/C:/tomcat5019/bin/boot
strap.jar;/C:/j2sdk1.4.2/jre/lib/ext/mrcjs11.jar;/C:/j2sdk1.4.2/jre/lib/ext/ant.
jar;/C:/j2sdk1.4.2/jre/lib/ext/jt400.jar;/C:/j2sdk1.4.2/jre/lib/ext/mrcextobj.ja
r;/C:/j2sdk1.4.2/jre/lib/ext/dnsns.jar;/C:/j2sdk1.4.2/jre/lib/ext/ldapsec.jar;/C
:/j2sdk1.4.2/jre/lib/ext/sunjce_provider.jar;/C:/j2sdk1.4.2/jre/lib/ext/localeda
ta.jar
cp=C:\j2sdk1.4.2\lib\tools.jar;..\bin\bootstrap.jar
cp=C:\tomcat5019\webapps\jsp-examples\WEB-INF\classes
cp=C:\tomcat5019\webapps\jsp-examples\WEB-INF\lib\jstl.jar
cp=C:\tomcat5019\webapps\jsp-examples\WEB-INF\lib\standard.jar
cp=C:\tomcat5019\work\Catalina\localhost\jsp-examples
cp=C:\tomcat5019\webapps\jsp-examples\WEB-INF\classes
cp=C:\tomcat5019\webapps\jsp-examples\WEB-INF\lib\jstl.jar
cp=C:\tomcat5019\webapps\jsp-examples\WEB-INF\lib\standard.jar
cp=C:\tomcat5019\shared\classes
cp=C:\tomcat5019\common\classes
cp=C:\tomcat5019\common\endorsed\xercesImpl.jar
cp=C:\tomcat5019\common\endorsed\xmlParserAPIs.jar
cp=C:\tomcat5019\common\lib\ant.jar
cp=C:\tomcat5019\common\lib\commons-collections.jar
cp=C:\tomcat5019\common\lib\commons-dbcp-1.1.jar
cp=C:\tomcat5019\common\lib\commons-el.jar
cp=C:\tomcat5019\common\lib\commons-pool-1.1.jar
cp=C:\tomcat5019\common\lib\jasper-compiler.jar
cp=C:\tomcat5019\common\lib\jasper-runtime.jar
cp=C:\tomcat5019\common\lib\jmx.jar
cp=C:\tomcat5019\common\lib\jsp-api.jar
cp=C:\tomcat5019\common\lib\naming-common.jar
cp=C:\tomcat5019\common\lib\naming-factory.jar
cp=C:\tomcat5019\common\lib\naming-java.jar
cp=C:\tomcat5019\common\lib\naming-resources.jar
cp=C:\tomcat5019\common\lib\servlet-api.jar
cp=C:\j2sdk1.4.2\lib\tools.jar
cp=C:\tomcat5019\bin\bootstrap.jar
cp=C:\j2sdk1.4.2\jre\lib\ext\mrcjs11.jar
cp=C:\j2sdk1.4.2\jre\lib\ext\ant.jar
cp=C:\j2sdk1.4.2\jre\lib\ext\jt400.jar
cp=C:\j2sdk1.4.2\jre\lib\ext\mrcextobj.jar
cp=C:\j2sdk1.4.2\jre\lib\ext\dnsns.jar
cp=C:\j2sdk1.4.2\jre\lib\ext\ldapsec.jar
cp=C:\j2sdk1.4.2\jre\lib\ext\sunjce_provider.jar
cp=C:\j2sdk1.4.2\jre\lib\ext\localedata.jar
work dir=C:\tomcat5019\work\Catalina\localhost\jsp-examples
extension dir=C:\j2sdk1.4.2\jre\lib\ext
srcDir=C:\tomcat5019\work\Catalina\localhost\jsp-examples
include=org/apache/jsp/dates/date1_jsp.java
Apr 15, 2004 9:26:06 AM org.apache.jasper.compiler.Compiler generateClass
SEVERE: Error compiling file: /C:/tomcat5019/work/Catalina/localhost/jsp-example
s//org/apache/jsp/dates\date1_jsp.java [javac] Compiling 1 source file


BJ - SCJP and SCWCD
We love Java programming. It is contagious, very cool, and lot of fun. - Peter Coad, Java Design

Crazy Bikes created by m-Power
Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 666
And the log file contains these lines:
Thanks.
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.
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:127)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:415)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:458)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:553)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:284)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:257)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:245)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:199)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:509)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:184)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:156)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:833)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:732)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:619)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:688)
at java.lang.Thread.run(Thread.java:534)
2004-03-17 16:52:50 StandardContext[/servlets-examples]SessionListener: contextDestroyed()
2004-03-17 16:52:50 StandardContext[/servlets-examples]ContextListener: contextDestroyed()
2004-03-17 16:52:50 StandardContext[/jsp-examples]SessionListener: contextDestroyed()
2004-03-17 16:52:50 StandardContext[/jsp-examples]ContextListener: contextDestroyed()
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
What are you doing to start Tomcat 5?
I ask this question, because I recently (as in yesterday) discovered that different versions of Tomcat need different directories endorsed at startup. If a needed directory isn't endorsed, then the error you're experiencing might appear, as happed for me.
If you're using the included batch/sh scripts to start Tomcat, and if you're properly specifying the CATALINA_HOME environment variable, then I'd not expect the error you're getting.
By chance, did you try the fix suggested in your log file, as seen in your second post?
[ April 16, 2004: Message edited by: Dirk Schreckmann ]

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
N Nanda
Ranch Hand

Joined: Feb 09, 2004
Posts: 62
Hi Bruce,
Simply open you Java installation folder and browse the lib folder (in my case it is C:\j2sdk1.4.2_03\lib) and copy the tools.jar file and paste it in your <Tomcat-Install-Dir>\common\lib folder. Now restart the Tomcat and njoy programming....


Regards<br />--<br />Niranjan Nanda<br />Consultant<br />Capgemini Consulting India <br />Mumbai<br />Phone: 9324951476
Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 666
> Tomcat needs different directories endorsed at startup.
How to do this? Thanks.
After unzip the downloaded zip to a folder I used startup.bat to start Tomcat. I could see from console that JAVA_HOME etc. were correctly setup.
I did try to copy tools.jar into common/lib but it did not help.
Interestingly my co-worker had the same problem (but he�s got Tomcat 5.0.19 on XP and I am on win2000) and he could make jsp compile by dropping tools.jar in commom/lib.
Thanks.
[ April 23, 2004: Message edited by: Bruce Jin ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Run jsp: Unable to find a javac compiler