Bean放到ROOT/WEB-INF/classes下JSP报告找不到类,怎么办?(50分)

  • 主题发起人 主题发起人 donyad
  • 开始时间 开始时间
.class文件不是jvm直接能跑?
小弟土人了
愿闻其详
 
建一个Package
 
对不起,但十万火急:
http://www.delphibbs.com/delphibbs/dispq.asp?lid=2288008
http://www.delphibbs.com/delphibbs/dispq.asp?lid=2292702
请各位DFW帮忙,万分感谢
 
Java文件不编译成Class 累死你也找不到指定类啊!
 
---------------------------------
来自:donyad, 时间:2003-8-17 14:05:00, ID:2114502 | 编辑
原来我的Bean是放到
Tomcat/classes里的
但是调试的时候每次都要重起Tomcat烦得要死
听说放到发布的目录下的WEB-INF里面也能用
但是我的为什么就找不到呢?
web.xml要怎么设置么?
---------------------------------
来自:donyad, 时间:2003-11-13 9:19:00, ID:2290673 | 编辑
class还要编译么?
要得话也是jvm的事情了
----------------------------------
来自:donyad, 时间:2003-11-13 18:45:00, ID:2292556 | 编辑
.class文件不是jvm直接能跑?
小弟土人了
愿闻其详
----------------------------------
to YFeral
请问您有看清我问的问题么?
 
我也碰到相同的问题,
工程名叫"HelloWorld",在"webapps/ROOT"下,
在HelloWorld目录下有"WEB-INF/classes/com/taxi/helloworld/utils"目录,该目录下有一个"Person.class",但我在index.jsp用该类的时候老是说"package com.taxi.helloworld.utilsdo
es not exist"
下面是"index.jsp"代码:
<%@ page import="java.io.PrintWriter"%><HEAD>
<TITLE>Hello World</TITLE>
</HEAD>
<BODY>
<%
out.println("<CENTER><H1>Hello World</H1></CENTER>");
%>
<jsp:useBean id = "taxi" class="com.taxi.helloworld.utils.Person" scope="page" />
<%
out.println("下面是taxi的信息/n");
out.println("姓名:" + taxi.getName() + "/n");
out.println("年龄:" + taxi.getAge());
%>
</BODY>

tomcat的报错信息
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: -1 in the jsp file: null
Generated servlet error:
[javac] Since fork is true, ignoring compiler setting.
[javac] Compiling 1 source file
[javac] Since fork is true, ignoring compiler setting.
[javac] D:/Applications/Tomcat4.1/work/Standalone/localhost/_/HelloWorld/index_jsp.java:51: package com.taxi.helloworld.utilsdo
es not exist
[javac] com.taxi.helloworld.utils.Person taxi = null;
[javac] ^
[javac] D:/Applications/Tomcat4.1/work/Standalone/localhost/_/HelloWorld/index_jsp.java:53: package com.taxi.helloworld.utilsdo
es not exist
[javac] taxi = (com.taxi.helloworld.utils.Person) pageContext.getAttribute("taxi", PageContext.PAGE_SCOPE);
[javac] ^
[javac] D:/Applications/Tomcat4.1/work/Standalone/localhost/_/HelloWorld/index_jsp.java:56: package com.taxi.helloworld.utilsdo
es not exist
[javac] taxi = (com.taxi.helloworld.utils.Person) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "com.taxi.helloworld.utils.Person");
[javac] ^
[javac] 3 errors

at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:130)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:353)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:370)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:473)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:190)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:534)

不知是哪里错了?
 
下面是改动后的jsp文件
<%@ page import="com.taxi.helloworld.utils.*" contentType="text/html charset=gb2312" %>
<HEAD>
<TITLE>Hello World</TITLE>
</HEAD>
<BODY>
<%
out.println("<CENTER><H1>Hello World</H1></CENTER>");
%>
<jsp:useBean id = "taxi" class="com.taxi.helloworld.utils.Person" scope="page" />
<%
out.println("下面是taxi的信息/n");
out.println("姓名:" + taxi.getName() + "/n");
out.println("年龄:" + taxi.getAge());
%>
</BODY>

在WebLogic中运行正常,但在tomcat下会说找不到包。
 
我也试了一下,报错。很费解????是不是tomcat的问题。奇怪呀
 
不过,把.class放到webapps/ROOT/WEB-INF就没事了,我试过了。
 
呵呵
真的么?
我试过Tomcat报错找不到类
XML里面要怎么配置的么?
 
不需要怎么配置啊,把相关的class文件放到webapps/ROOT/WEB-INF/classes就可以了,当然有使用包,必须建立相关的目录。
 
建议你用resin,把类文件拷贝到web-inf/classes/..即可,比如你的index.jsp在c:/aaa下,则将类文件拷贝到c:/aaa/WEB-INF/classes/即可,当然你也可以在classes目录下在建目录
 
我也遇到这问题了。已经折腾一晚上了。恨不能把计算机砸了。放到/ROOT/WEB-INF/classes底下还是不认。
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 8 in the jsp file: /test.jsp
Generated servlet error:
[javac] Compiling 1 source file
 
嘿嘿。这个问题终于在今天自己搞定了。
这不是明摆着浪费我精力么。
 
后退
顶部