开发者

java.lang.ClassCastException cannot be cast to javax.servlet.ServletException

开发者 https://www.devze.com 2022-12-11 10:44 出处:网络
I\'m trying to deploy a java application to appspot (google appengine). I\'m new to java, so bear with me. When I run the application locally from eclipse, it runs fine.

I'm trying to deploy a java application to appspot (google appengine). I'm new to java, so bear with me. When I run the application locally from eclipse, it runs fine. After uploading it to google appspot, I get an error开发者_如何转开发 (only in one of the .jsp pages, other .jsp pages work fine). The error log says:

   Uncaught exception from servlet

java.lang.ClassCastException: java.lang.ClassCastException cannot be cast to javax.servlet.ServletException
    at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:754)

Can somebody shed some light on this issue? What could be wrong in this particular page? If you would like to see the page code, let me know.


It looks like something in your code is throwing an exception that does not derive from ServletException. A handler upstream is catching that exception and (possibly) trying to do something intelligent with it.

There is probably another underlying issue causing the exception to be thrown in the first place, but that might be revealed by seeing first what the exception is.

If you aren't sure where this exception is, try wrapping you entire page handler in a try ... catch block, looking for all Throwable's. When you find one, rethrow it inside of a ServletException:

try {
    // handle page request
} catch (Throwable t) {
    throw new ServletException(t);
}

This should allow the web server to display the exception so you can continue tracking down the problem. Note that this should probably be temporary code.


Look for instances of javax.servlet.ServletException.class in your WEB-INF/lib. Contents for servler.jar or servlet.api.jar should be provided bye the container and should not appear in your WAR file.

0

精彩评论

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