1

我有 ubuntu 13.04 并且我已经安装了 openjdk-6。在 tomcat 上运行我的一个 Web 应用程序(直接,不使用任何 IDE)并加载任何页面时,我收到以下错误:

8 Jul, 2013 2:32:55 PM org.apache.catalina.core.StandardWrapperValve invoke
INFO: org.apache.jasper.JasperException: Unable to compile class for JSP
    at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:97)
    at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:346)
    at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:414)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.arvind.filters.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:46)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.arvind.filters.SessionFilter.doFilter(SessionFilter.java:73)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
    at java.lang.Thread.run(Thread.java:679)
Caused by: 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.getCompiler(CompilerAdapterFactory.java:106)
    at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:935)
    at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:764)
    at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:382)
    ... 31 more

我在 ~/.bashrc 中设置了以下变量。

export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-i386
export PATH=$PATH:/usr/lib/jvm/java-6-openjdk-i386/bin

我为 jdk 添加了 java 替代品并将其设置为默认值

  Selection    Path                                           Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java   1061      auto mode
  1            /usr/bin/gij-4.7                                1047      manual mode
* 2            /usr/lib/jvm/java-6-openjdk-i386/bin/java       1         manual mode
  3            /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java   1061      manual mode

在运行java -version我得到以下

java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.5) (6b27-1.12.5-1ubuntu1)
OpenJDK Server VM (build 20.0-b12, mixed mode)

在运行javac -version我得到以下

javac 1.6.0_27

在启动tomcat时,它显示正在使用这些变量。

Using CATALINA_BASE:   /home/arvind/tomcat1
Using CATALINA_HOME:   /home/arvind/tomcat1
Using CATALINA_TMPDIR: /home/arvind/tomcat1/temp
Using JRE_HOME:       /usr/lib/jvm/java-6-openjdk-i386

有人可以告诉我如何解决这个问题吗?

4

1 回答 1

4

我终于找到了问题。我不得不将 tools.jar 放在我的 tomcat 的 lib 目录中。

于 2013-07-08T12:23:45.653 回答