我首先安装jdk1.4.2,配置系统变量:
path=%path%;c:\jdk1.4.2\bin
classpath=.;c:\jdk1.4.2\lib\tools.jar
java_home=c:\jdk1.4.2安装tomcat5.0.8,安装完后启动tomcat,访问http://localhost:8080/出现tomcat主页,运行它本身的例子程序正常!我拷贝一个例子文件夹ch2到c:\tomcat5.0.8\webapps\目录下,它其中有test.jsp:
<html><head><title>测试JSP运行</title>
<body>
<center>当前的时间是:<%=new java.util.Date()%></center>
</body></html>
WEB-INF文件夹中有classes文件夹和web.xml文件:
<?xml version="1.0" encoding="ISO-8859-1"?><web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
version="2.4"> <display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>
</web-app>我访问http://localhost:8080/ch2/test.jsp
出现错误:
type Exception reportmessage
description The server encountered an internal error () that prevented it from fulfilling this request.
exception org.apache.jasper.JasperException: Unable to compile class for JSPNo 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:128)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:413)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:453)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:437)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:555)
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.错误中让我把c:\jdk1.4.2\lib\tools.jar拷贝到c:\tomcat5\common\lib中,我拷贝了,重启tomcat再访问test.jsp出现同样的错误提示!!!
请问大家这是怎么回事???
先谢谢了!!!
path=%path%;c:\jdk1.4.2\bin
classpath=.;c:\jdk1.4.2\lib\tools.jar
java_home=c:\jdk1.4.2安装tomcat5.0.8,安装完后启动tomcat,访问http://localhost:8080/出现tomcat主页,运行它本身的例子程序正常!我拷贝一个例子文件夹ch2到c:\tomcat5.0.8\webapps\目录下,它其中有test.jsp:
<html><head><title>测试JSP运行</title>
<body>
<center>当前的时间是:<%=new java.util.Date()%></center>
</body></html>
WEB-INF文件夹中有classes文件夹和web.xml文件:
<?xml version="1.0" encoding="ISO-8859-1"?><web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
version="2.4"> <display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>
</web-app>我访问http://localhost:8080/ch2/test.jsp
出现错误:
type Exception reportmessage
description The server encountered an internal error () that prevented it from fulfilling this request.
exception org.apache.jasper.JasperException: Unable to compile class for JSPNo 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:128)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:413)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:453)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:437)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:555)
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.错误中让我把c:\jdk1.4.2\lib\tools.jar拷贝到c:\tomcat5\common\lib中,我拷贝了,重启tomcat再访问test.jsp出现同样的错误提示!!!
请问大家这是怎么回事???
先谢谢了!!!
实在不行重装tomcat
set classpath=.;c:\jdk1.4.2\lib\tools.jar;c:\jdk1.4.2\lib\dt.jar
好像不用设置java_home=c:\jdk1.4.2吧。不行的话你装tomcat5.18
c:\jdk1.4.2\lib;c:\jdk1.4.2\lib\dt.jar;我也加到classpath中了,
重启tomcat还是一样,这不应该是版本的事阿!
郁闷!!!
CATALINA_HOME=tomcat安装目录
JAVA_HOME=JDK的安装目录
然后要将JDK目录下的tool.jar路径加到ClassPath环境变量中
再试一试了。
http://127.0.0.1:8080/ch2/test.jsp
http://127.0.0.1:8080/test.jsp
CATALINA_HOME=C:\Tomcat 5.0
JAVA_HOME=C:\j2sdk1.4.2CLASSPATH=.;C:\j2sdk1.4.2\lib\dt.jar;C:\j2sdk1.4.2\lib\tools.jar;c:\tomcat 5.0\common\lib\servlet-api.jar;C:\Tomcat 5.0\common\lib\jsp-api.jarpath=%path%;c:\j2sdk1.4.2\bin
这是我设的系统变量,我把ch2文件夹拷贝到root下,http://localhost:8080/ch2/test.jsp提示访问不到test.jsp,放到webapps下,错误提示一样!!!
我在server.xml中设置了虚拟路径,http://localhost:8080/test/test.jsp就可以访问了!
但书上说拷贝过去就可以了,真是搞不明白!
////////////////////////////////////////////////////////////////////////////////
<Context path="/test" docBase="ch2" debug="0" reloadable="true" />
我在server.xml中设置了虚拟路径,http://localhost:8080/test/test.jsp就可以访问了!
////////////////////////////////////////////////////////////////////////////////
设置虚拟目录和你的程序没有关系的。如果你的应用程序在别的盘符下,或者说不是在tomcat下的webapps下的话,你就需要设置虚拟目录!
而你的应用程序是在webapps下了,所以设不设都无所谓的!