当前位置: 代码迷 >> Java Web开发 >> java.lang.ClassNotFoundException解决思路
  详细解决方案

java.lang.ClassNotFoundException解决思路

热度:211   发布时间:2016-04-17 00:48:43.0
java.lang.ClassNotFoundException

servlet的问题

前台报错

HTTP Status 500 - 
javax.servlet.ServletException: Wrapper cannot find servlet class org.gl.ListServlet or a class it depends on
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)

java.lang.ClassNotFoundException: org.gl.ListServlet
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)


Tomcat报错

可以进入网页,然后点查询出现下面的错误

org.gl.ListServlet
java.lang.ClassNotFoundException: org.gl.ListServlet
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1095)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:809)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

[ERROR]http-8080-1-org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/ch08].[ListServlet]-Allocate exception for servlet ListServlet
java.lang.ClassNotFoundException: org.gl.ListServlet
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1095)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:809)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)

org.gl下面有ListServlet文件,这是怎么回事,为什么说找不到类


web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  version="2.5"> 
<context-param>
<param-name>driverClass</param-name>
<param-value>com.mysql.jdbc.Driver</param-value>
</context-param>
<context-param>
<param-name>url</param-name>
<param-value>jdbc:mysql://localhost:3306/mysql</param-value>
</context-param>
<context-param>
<param-name>user</param-name>
<param-value>root</param-value>
</context-param>
<context-param>
<param-name>password</param-name>
<param-value>root</param-value>
</context-param>

<servlet>
<servlet-name>ListServlet</servlet-name>
<servlet-class>org.gl.ListServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ListServlet</servlet-name>
<url-pattern>/list</url-pattern>
</servlet-mapping>
</web-app>






------解决方案--------------------
org.gl


这个包是你新建的包么?


最好改一下名字,再试试


------解决方案--------------------
我以前碰到过一个新建了 包名为 java.*.* 的 写的东西都是对的,但是就是报错,后来发现是报名不能这么写 



你换个包名试试
  相关解决方案