Re: Application.dispatchRequest does not catch InvocationTargetException
Re: Application.dispatchRequest does not catch InvocationTargetException
- Subject: Re: Application.dispatchRequest does not catch InvocationTargetException
- From: Kaj Hejer <email@hidden>
- Date: Thu, 26 May 2005 20:22:14 +0200
Aha! I see! Thanks for answering!
After playing a little with an implementation of
handleActionRequestError we have used earlier that let our custom
handleException method handle the error (since we already have all
our error handling logic in this method):
public WOResponse handleActionRequestError(WORequest aRequest,
java.lang.Exception exception,
java.lang.String reason, WORequestHandler aHandler,
java.lang.String actionClassName,
java.lang.String actionName, java.lang.Class
actionClass, WOAction actionInstance) {
System.err.println(new NSTimestamp() +
":UIOApplication.handleActionRequestError: " + exception);
if (actionInstance != null) {
return handleException(exception, actionInstance.context
());
} else {
return handleException(exception,
createContextForRequest(aRequest));
}
}
We are on WO5.2.4.
I realized that it don't seems to work so well to use
actionInstance.context() so I refactored handleActionRequestError to
return
handleException(exception, createContextForRequest(aRequest));
even when actionInstance is not null. When using
actionInstance.context() the app seems to hang after 2 requests that
triggers the handleActionRequestError method. I tried I kill -QUIT
and the output is available on http://folk.uio.no/kajh/tmp/
dump20050526.txt for those who like to dig :)
But... after changing this method as described above this seem to
work just fin!
Thanks again!
-Kaj :)
On 26. mai 2005, at 18.13, Chuck Hill wrote:
The WODirectActionRequestHandler handles that one. You can either
catch it in DirectAction.performActionNamed (in which case it will
be a NoSuchMethodException wrapping in an NSForwardException or (I
think) handle it in Application:
"public WOResponse handleActionRequestError(WORequest aRequest,
Exception exception,
String reason,
WORequestHandler aHandler,
String actionClassName,
String actionName,
Class actionClass,
WOAction actionInstance)
Invoked when an action handler throws an exception in
handleRequest. Action handlers are subclasses of the
WOActionRequestHandler, and include the WODirectActionRequestHandler."
Chuck
On May 26, 2005, at 8:57 AM, Kaj Hejer wrote:
Hi!
If I try to go
http://myserver.myhost.no/cgi-bin/WebObjects/myapp.woa/wa/
justgarabage
I get the following in my log:
[2005-05-26 17:50:19 MEST] <WorkerThread2>
<com.webobjects.appserver._private.WODirectActionRequestHandler>:
Exception while handling action named "dsadf" on action class
"null" :java.lang.reflect.InvocationTargetException
[2005-05-26 17:50:19 MEST] <WorkerThread2>
java.lang.reflect.InvocationTargetException
at
com.webobjects.appserver._private.WOActionRequestHandler._handleReque
st(WOActionRequestHandler.java:250)
at
com.webobjects.appserver._private.WOActionRequestHandler.handleReques
t(WOActionRequestHandler.java:142)
at com.webobjects.appserver.WOApplication.dispatchRequest
(WOApplication.java:1306)
at UIOApplication.dispatchRequest(UIOApplication.java:119)
at Application.dispatchRequest(Application.java:134)
at com.webobjects.appserver._private.WOWorkerThread.runOnce
(WOWorkerThread.java:173)
at com.webobjects.appserver._private.WOWorkerThread.run
(WOWorkerThread.java:254)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.lang.NoSuchMethodException: DirectAction.
justgarabageAction()
at
com.webobjects.appserver.WODirectAction.performActionNamed
(WODirectAction.java:125)
at
com.webobjects.appserver._private.WOActionRequestHandler._handleReque
st(WOActionRequestHandler.java:240)
... 7 more
even when I have the following method in my Application (or in
UIOApplication which is the superclass foor my Application):
public WOResponse dispatchRequest(WORequest request) {
try {
return super.dispatchRequest(request);
} catch (Exception e) {
System.err.println("dispatchRequest: " + e);
e.printStackTrace();
WOContext context = createContextForRequest(request);
return handleException(e, context);
}
}
From what I can understand it is thrown a
InvocationTargetException inside super.dispatchRequest(request)
but this exception isn't catched by my try/catch block.
Why?
TIA for any comments!
-Kaj :)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40global-village.net
This email sent to email@hidden
--
Practical WebObjects - a book for intermediate WebObjects
developers who want to increase their overall knowledge of
WebObjects, or those who are trying to solve specific application
development problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden