java.lang.ClassCastException cannot be cast to javax.servlet.ServletException - google-app-engine

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.

Related

I could not finish a watson studio setup , I keep getting error messages "can not read property 'language_info' undefined

I was trying to set up a watson studio , but I keep getting error message that says 'can not read property 'language_info' undefined'
Same issue for a course project. No one else has seemed to encounter it.
I changed the URL I was using to http from https and it worked. This could be the solution, or I just needed to back up and try it again.
In case it saves someone a bit of time:
I ran into the same issue in the Assignment 2 of the class "Fundamentals of Scalable Data Science". The reason is that the URL we had to import as Notebook is not the first one that appears in the instructions, as it was in Assignment 1. The URL to be imported was lower on the page.
Long story short: You may be importing the wrong URL.

ErrorHandler for threads different from EDT

For any uncaught exception that occurs in EDT, I show an informative Dialog (useful during the development), I send a crash report to the developer account and, when the user press "OK" in the Dialog, I kill the app. This logic prevents testers from testing the app in an invalid state, that's why I don't use the default crash report functionality of Codename One, but I reimplemented that according to my needs.
To do that, I used Display.getInstance().addEdtErrorHandler(...), that works fine.
Is there any similar API to automatically handle uncaught exceptions in custom threads, like my EasyThread instances? Even better, to automatically handle uncaught exceptions of all threads with few code in the init()?
We don't have thread groups so there is no uncaught exception handlers. But something like that should probably be available for easy thread. It could be pretty powerful as it could allow for a retry of a failed task.
So we'll add new methods: addErrorListener, removeErrorListener, addGlobalErrorListener and removeGlobalErrorListener to the coming update of Codename One.

Handling DocumentClosedError for Google Drive Realtime JS app

Google Drive Realtime API has a nice set of errorTypes that you can listen for, so you can handle each case individually:
https://developers.google.com/drive/realtime/reference/gapi.drive.realtime.ErrorType
Unfortunately, this list doesn't include the DocumentClosed error. For some reason, that error is its own object in the API.
https://developers.google.com/drive/realtime/reference/gapi.drive.realtime.DocumentClosedError
For the life of me, I cannot figure out how to handle this error. I have an onError listener function set up on my realtime.load, but that only catches Errors, which are different than the DocumentClosedError.
Is there any way to handle/listen for this particular type of error? I have also tried document.addEventListener but that was a desperate attempt and didn't work
For anyone else wondering about this, it was related to binding between angular and google drive.
The document was closed for google but the angular binding were still there.
We handled this by intercepting the angular error based on this.
http://odetocode.com/blogs/scott/archive/2014/04/21/better-error-handling-in-angularjs.aspx
The DocumentClosedError is a different type of error as it is only thrown when you are accessing an invalid document. The only times that that Realtime Document should be invalid are: 1) after one of the fatal errors defined in ErrorType is handled by your error function, or 2)after you call .close() yourself on the document.
Tracking whether you hit one of these two conditions on the client and ensuring you don't access the Document afterwards is how to prevent the error from firing. Ideally if you get into a state where your document is closed, the app should teardown its references to the realtime models and reconnect to reduce the number places that you will throw exceptions.
TL;DR: If you're hitting DocumentClosedErrors you should change the way that you handle fatal errors defined in ErrorType.

Strange, isolated errors "$compile:tpload"

We're having strange, sporadic JavaScript error messages in our production log files (JavaScript errors are logged in the backend):
Uncaught Error: [$compile:tpload] http://errors.angularjs.org/1.2.16/$compile/tpload?p0=modules%2Fsome%2valid-directive-path.tpl.html
The error occurs only with directives. I'm not able to reproduce the errors locally. The templateUrl for the directives are all valid.
The only possible scenario that came to my mind was if the user presses the cancel/stop button in the browser while the page is loading (then i'm able to reproduce the error).
Does anyone have another idea or explanation? Or even a solution :-)
Cheers
Michael
We resolved the issue like this:
Since we are caching our HTML templates with $templateCache using the grunt ngTemplate plugin (https://www.npmjs.com/package/grunt-angular-templates) we do not have the above issues anymore.
Out of interest I was able to recreate this issue. By adding logging to angular I established that when the template load fails it does so with a status of 0 which made me think that the request was actually cancelled. This theory was backed up by the fact that we see no server side errors.
If I emulate a device that cannot support html5 routing and then add an arbitrary query string to the end of the route, it causes an infinite digest loop and in the end the whole page reloads a few times. This in turn was causing the outstanding template requests to be cancelled leading to exactly the errors I was seeing in the logs.
So, for me at least, this is really nothing to do with the loading of the templates, it's just an angular bug (which hopefully is going to be fixed in angular 1.3.8)

Cakephp Custom Error pages

I am referring to the problem that has already been asked. CakePHP 2.0 - How to make custom error pages?
It gives me a lot idea of solving out the problem but instead of thowing exception I want to use it for all of my controller and actions. It suggested me to do where ever at particular location I want throw new NotFoundException(); I want it everywhere I mean where so ever controller or action is missing.
With debug turned off all your error are converted to either 400 or 500 errors. So you just need to customize your app/View/Errors/error400.ctp and app/View/Errors/error500.ctp as required.

Resources