tomcat烦忧于心

04-11-14 axs

jdk环境变量通过,编译执行java文件都好用,http://localhost:8080这个也能显示tomcat的首页,但为什么我编译的jsp就提示错误呢??

error:

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:127)

org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)

org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:415)

org.apache.jasper.compiler.Compiler.compile(Compiler.java:458)

org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)

org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:553)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)

javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

note The full stack trace of the root cause is available in the Tomcat logs.

banq
2004-11-14 21:42

No Java compiler

配置JAVA_HOME环境或编译环境

mornlee
2004-11-14 21:54

Tomcat配置

如果出现

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

...

而你的JAVA_HOME已经配置了,这时候是因为这个原因,如下:

Tomcat ClassPath配置如下:

C:\Program Files\Apache Software Foundation\Tomcat 5.0\bin\bootstrap.jar;C:\Program Files\Java\jdk1.5.0\lib\tools.jar

这个问题也曾折腾了我一下,把经验记下来了(Confluence不错,是个好东西)