• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Application.dispatchRequest does not catch InvocationTargetException
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Application.dispatchRequest does not catch InvocationTargetException


  • Subject: Re: Application.dispatchRequest does not catch InvocationTargetException
  • From: Zak Burke <email@hidden>
  • Date: Thu, 26 May 2005 12:20:36 -0400

Kaj Hejer wrote on 5/26/05 11:57 AM:

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

[...]

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) {
            [...]
        }
    }

I don't remember the details, but I recall that excpetions thrown from DirectActions are not handled well and the solution is to trap all exceptions in the DA dispatch method performActionNamed(String name) and then explicitly call an exception-handling method. Here is the method I use; the method Application.handleException(...) does the same things as your catch block (above).


zak.


/**
* Override performActionNamed(String) for a couple reasons:
*
* 1. don't choke on errors in DA methods
* Don't deadlock when a DirectAction throws an exception. From
* http://www.wodev.com/cgi-bin/WebObjects/WODev.woa/wa/Main?wikiPage=DirectActionDeadlocks
* "If the session has been referenced it is not checked back in
* and the application will deadlock immediately if it is not
* dispatching requests concurrently. If it is dispatching
* concurrently, just that one session will deadlock."
*
* Basically, catch all exceptions locally and directly return
* the error pages here instead of relying on Application's methods
* to handle them.
*
*
* 2. make sure the session is awake early in the request-response loop.
* In DAs, the session is not automatically woken up until it is
* referenced, so we reference it here to make sure it's available
* later. See Chuck Hill's _Practical Web Objects_ Apress, 2004, 87-88
* for details.
*
* @param name action to peform
*/
public WOActionResults performActionNamed(String name)
{
try
{
return super.performActionNamed(name);
}


    // page content not found
    catch (I3pkbPageNotFoundException e)
    {
        NSLog.out.appendln(e);
        return error404(this.request.headerForKey("script_uri"));
    }

    // key-value coding exception on destination page
    catch (NSKeyValueCoding.UnknownKeyException  e)
    {
        return WOApplication.application().handleException(e, context());
    }

    // NSFE wraps NoSuchMethodException, i.e. request for non-existent page
    catch (NSForwardException e)
    {
        NSLog.out.appendln(e);
        return error404(this.request.headerForKey("script_uri"));
    }

    catch (Exception e)
    {
        return WOApplication.application().handleException(e, context());
    }

catch (Throwable t)
{
return WOApplication.application().handleException(new NSForwardException(t), context());
}
}
_______________________________________________
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
References: 
 >Application.dispatchRequest does not catch InvocationTargetException (From: Kaj Hejer <email@hidden>)

  • Prev by Date: Re: Application.dispatchRequest does not catch InvocationTargetException
  • Next by Date: Re: Application.dispatchRequest does not catch InvocationTargetException
  • Previous by thread: Re: Application.dispatchRequest does not catch InvocationTargetException
  • Next by thread: Applet upload
  • Index(es):
    • Date
    • Thread