English 中文(简体)
java.lang.ClassCastException cannot be cast to javax.servlet.ServletException
原标题:

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.





相关问题
How to make logging.debug work on Appengine?

I m having a tough time getting the logging on Appengine working. the statement import logging is flagged as an unrecognized import in my PyDev Appengine project. I suspected that this was just an ...

gqlQuery returns object, want list of keys

Is there a way to convert the GqlQuery object to an array of keys, or is there a way to force the query to return an array of keys? For example: items = db.GqlQuery("SELECT __key__ FROM Items") ...

Integrating Google AppEngine with a Thick Client

I want to make a multi-user client-server solution with Java Swing thick client as a front-end and Google AppEngine (Java one) as a back-end. The problem is that GAE provides only web-based forms for ...

sorl.thumbnail : thumbnail is not a valid tag library?

I am trying to install sorl.thumbnail but am getting the following error message: thumbnail is not a valid tag library: Could not load template library from django.templatetags.thumbnail, No module ...

热门标签