my dog learned polymorphism*
The moose likes Tomcat and the fly likes Unable to find java compiler for compiling JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Unable to find java compiler for compiling JSP" Watch "Unable to find java compiler for compiling JSP" New topic
Author

Unable to find java compiler for compiling JSP

Ramaprasad Kolla
Greenhorn

Joined: Oct 22, 2008
Posts: 23

Hi,
Howdy all,

I have to work on JSPs using Tomcat 5.0. I have set the below environment variables
1. JAVA_HOME = C:\Program Files\Java\jdk1.6.0_10
2. CATALINA_HOME = C:\Program Files\Apache Software Foundation\Tomcat 5.0\binC:\Program Files\Apache Software
Foundation\Tomcat 5.0
3. PATH = C:\Program Files\Java\jdk1.6.0_10\bin

When I am accesing a JSP with the below code:

Error message is:

exception:

org.apache.jasper.JasperException: Unable to compile class for JSP
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:97)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:346)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:414)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause:

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
org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.java:106)
org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:935)
org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:764)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:382)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

Even though I have set the JAVA_HOME variable, the error reports about JAVA_HOME
Please let me know the reason.

Thanks in Advance,
Ram


Thanks,
Ramaprasad K
In Love with Java -@
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

Please be sure to ask Tomcat questions in the Tomcat forum. I have moved this post there for you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Kees Jan Koster
JavaMonitor Support
Rancher

Joined: Mar 31, 2009
Posts: 251
    
    5
Dear Ram,

Just a shot in the dark: make sure JAVA_HOME is quoted properly, because the is a space in it. Use the silly 8.3 notation if you are not sure (.i.e. progra~1 instead of Program Files).

On a general note: installing Tomcat in places that have spaces in the names gives strange problems. I try to avoid such names.

Java-monitor, JVM monitoring made easy <- right here on Java Ranch
Eli Wood
Ranch Hand

Joined: Sep 04, 2008
Posts: 37

Is Tomcat installed as a Windows service?

Running Tomcat as a service, I've had trouble getting it to recognize my settings in configuration files before. I have never found an explanation for this behavior.

This is a terrible practice to get into, but what worked for me was changing settings directly in the windows registry.

1)Start->run->type in "regedit" and hit enter
2)Find the parameters for your tomcat instance (mine are under HKEY_LOCAL_MACHINE->SOFTWARE->Apache Software Foundation->Procrun 2.0->{Tomcat instance name}->Parameters)
3)Change the jvm setting to point to a valid jdk (mine is D:\Program Files\Java\jdk1.5.0_16\jre\bin\server\jvm.dll)

Hope this helps!
Ramaprasad Kolla
Greenhorn

Joined: Oct 22, 2008
Posts: 23
Hi Kees,

It didnot work

Eli,
Same with your suggestion too..
Kalyan Ram
Greenhorn

Joined: Dec 29, 2003
Posts: 14
Ramaprasad Kolla wrote:
2. CATALINA_HOME = C:\Program Files\Apache Software Foundation\Tomcat 5.0\binC:\Program Files\Apache Software Foundation\Tomcat 5.0

According to the above setting, Tomcat is residing at two places. That doesn't make sense.

C:\Program Files\Apache Software Foundation\Tomcat 5.0\bin should be in the PATH, because the bin directory (by convention) points to the executable files.
C:\Program Files\Apache Software Foundation\Tomcat 5.0 is the correct CATALINA_HOME

I don't know if its a typo or something else, but file paths should be separated by a semi-colon.

FWIW, I don't even have the CATALINA_HOME setting on my XP PRO SP3 PC.

I would definitely try out the Koster's advise regarding paths with spaces. Uninstall JDK and Tomcat from current locations. Re-install them into locations with no spaces like c:\jdk1.6.0_10 & c:\Tomcat-5.0

This link might have suggestions - http://wiki.apache.org/tomcat/FAQ/Miscellaneous#Q1
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Kalyan Ram wrote:
FWIW, I don't even have the CATALINA_HOME setting on my XP PRO SP3 PC.

It is only required when you run Tomcat standalone (and thus not from within some external tool like an IDE or so).
Kalyan Ram
Greenhorn

Joined: Dec 29, 2003
Posts: 14
Bauke Scholtz wrote:
Kalyan Ram wrote:
FWIW, I don't even have the CATALINA_HOME setting on my XP PRO SP3 PC.

It is only required when you run Tomcat standalone (and thus not from within some external tool like an IDE or so).

Please elucidate.

I am using Tomcat with Notepad++ as my code editor.

I have a shortcut to tomcat5w.exe on my desktop for situations needing a server restart.

regards
/k
Ramaprasad Kolla
Greenhorn

Joined: Oct 22, 2008
Posts: 23

Hi Kalyan,

That was a typo mistake. I have even tried installing the things in no-space named folders but still of no use.

Thanks,
Ramaprasad Kolla

Kalyan Ram
Greenhorn

Joined: Dec 29, 2003
Posts: 14
Ramaprasad Kolla wrote:
Hi Kalyan,

That was a typo mistake. I have even tried installing the things in no-space named folders but still of no use.

Thanks,
Ramaprasad Kolla


Couple of quick questions -
* what is the path to your JSP file?
For instance, if your JSP is put in TC_HOME\webapps\jsp-examples and accessed via http://localhost:8080/jsp-examples/your_jsp.jsp does it still fail?
* What did you use to install tomcat, the installer or the archive?
* try acidjnk's work around @ http://forums.sun.com/thread.jspa?threadID=494649
Does that too fail?
* did you find any clues in the logs @ TC_HOME\logs

regards
/k
Ramaprasad Kolla
Greenhorn

Joined: Oct 22, 2008
Posts: 23
My jsp path is:

http://localhost:8080/MyWebApp/index.jsp
It is at the context root.

I have installed tomcat afresh in C Drive as C:\tomcat5.0 (non-spaced) and now I'm getting a new error as below:
exception

javax.servlet.ServletException: Wrapper cannot find servlet class org.apache.jsp.index_jsp or a class it depends on
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
java.lang.Thread.run(Thread.java:619)


root cause

java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1340)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
java.lang.Thread.run(Thread.java:619)

Now my environment variables are:
CATALINA_HOME=C:\Tomcat5.0
JAVA_HOME=C:\Progra~1\Java\jdk1.6.0_10 (As suggested by one of the ranchers)
CLASSPATH=C:\Tomcat5.0\common\lib\servlet-api.jar

Web Application:
Tomcat5.0
|__webapps
|__MyWebApp
|__index.jsp (trying to access this jsp)
|__WEB-INF
|__classes
|__web.xml
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to find java compiler for compiling JSP