关于web.xml 里面的web-app 3.0问题

娃娃也郁闷 发布于 2013/07/02 19:59
阅读 15K+
收藏 0

我是新手,想学习下servlet,希望各位帮帮忙,我找了好久也没找到错误在哪

我用的jdk1.7, tomcat7.0 eclipse4.2

报的错误信息

SEVERE: サーブレット learn に例外を割り当てます
java.lang.ClassNotFoundException: com.servlet.FirstServlet
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
	at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:527)
	at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:509)
	at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:137)
	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1137)
	at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:858)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:136)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1822)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
	at java.lang.Thread.run(Thread.java:722)

 

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>LearnServlet</display-name>

	<servlet>
		<servlet-name>learn</servlet-name>
		<servlet-class>com.servlet.FirstServlet</servlet-class>
	</servlet>
	
	<servlet-mapping>
		<servlet-name>learn</servlet-name>
		<url-pattern>/learn</url-pattern>
	</servlet-mapping>
</web-app>

FirstServlet.java

package com.servlet;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class FirstServlet extends HttpServlet{
	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException,ServletException{
		PrintWriter out = res.getWriter();
		out.println("Hello");
		out.flush();
		out.close();
	}
}

 

 

 

加载中
0
南湖船老大
南湖船老大
很明显,没部署对 WEB-INF下你确认有class 文件?
娃娃也郁闷
回复 @好大的凶兆 : 我生产的class文件在build下面,我手动拷过去就好了,我应该怎么办?
南湖船老大
南湖船老大
回复 @娃娃也郁闷 : 先手动拷过去
娃娃也郁闷
果然没有,改怎么办? tomcat下我也写东西了啊? <Context path="/ls" reloadable="true" docBase="D:\workspace\LearnServlet\WebContent" />
0
我已经报警了
我已经报警了

ClassNotFoundException: com.servlet.FirstServlet


class文件没找到

0
JerrySu
JerrySu
没部署吧,感觉lib目录没东西啊,更好奇你的编辑器是日文还是韩文呀
娃娃也郁闷
日文 部署??是在tomcat里面配置嘛??能简单的给我说一下嘛
0
娃娃也郁闷

多谢各位的提醒,这个问题我已经解决了

编译的时候,生成的classes没有在web-inf下面,在build下面,发布的目录是\WebContent下面,所有找不到类,把.classpath配置文件里面的目录改成\WebContent\web-inf\classes就好了,如果还不行,在.settings文件夹下面org.eclipse.wst.common.component文件里面的路径也改掉

返回顶部
顶部