开发者

Trouble calling servlet

I am getting this message: SEVERE: Error loading WebappClassLoader.

Many people have posted this problem online, I haven't found yet a good solution for this problem.

What I am trying to do is simply call a servlet from a JSP page (using AJAX). problem is I am getting an Internal server error. Anyone have any idea?

In case it makes a difference, I'm using eclipse and Tomcat6.

Full error:

SEVERE: Error loading WebappClassLoader
  context: /Shaot
  delegate: false
  repositories:
    /WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@f11404
 controller.UserController
java.lang.ClassNotFoundException: controller.UserController
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
    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)
    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:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Unknown Source)
12/07/2011 02:29:14 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet UserController
java.lang.ClassNotFoundException: controller.UserController
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
    at org.apache.catalina.loader.WebappClassLoa开发者_如何学Pythonder.loadClass(WebappClassLoader.java:1526)
    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)
    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:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Unknown Source)

Called with AJAX using (JQuery) when the url of the AJAX call is /NameOfTheProject/UserController


I think your problem is that the JVM doesn't know anything about controller.UserController. For whatever reason, it would appear as though the classloader hasn't loaded the controller you are trying to invoke.

Try and test the invocation of the servlet via a browser first (even if you just create a simple HelloWorld Servlet to ensure that it is being correctly loaded for use.

Take a look at the classloader docs for Tomcat to get an idea of what goes on behind the scenes; Tomcat 6.0 class loader how to

Tomcat 5.5 class loader how to

Also, maybe put a breakpoint in your servlets init() method to see if it is ever actually invoked either when it is accessed via the browser or via AJAX.

Best of luck.


java.lang.ClassNotFoundException: controller.UserController

The exception is telling that the class controller.UserController is missing in the classpath. To fix the problem, just put the in the message mentioned class in the classpath.

In your specific case, you need to ensure that you have a /WEB-INF/classes/controller/UserController.class file in the deployment folder of your webapp.


Here are possible solutions

  1. Try to clean the project and re-compile it.

  2. How you are calling servlet, I mean can you post the code which calls the servlet


The problem was in the web.xml file. Something was configured wrong over there. My solution was to delete all things to do with the servlet and then add the servlet to the Deployment manually.


The problem is with the web.xml If your app is supporting jsf and for the same you do entry for faces servlet then the jars may be missing so it will say no class found.

This kinda problem is always linked with web.xml

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜