RE: App freeze problem

Steven Pannell <[email protected]> Thu, 16 Sep 2004 09:18:37 +0200
Newsgroups gmane.comp.web.webobjects.admin
Message-ID <[email protected]>
Hi,

Check the mailing list archive here:
http://www.omnigroup.com/developer/mailinglists/webobjects-dev/

You can look for DirectAction Exception or something like that.  But anyway
the general problem can be solved like this (I got this information from the
mailings in the archive. It's not my solution - but it works).

What happens is a call is made to a DirectAction for a method which does not
exist (happens all the time).  So WO throws and Exception which seems to
cause it to kinda crash - or at least you can never shut it down. WO Bug.

In the direct action overload the performAction method like:

    public WOActionResults performActionNamed(String actionName) {
      try {
        return super.performActionNamed(actionName);
      } catch(Exception e) {
        // handle the exception here...
        return (GeneralErrorPage)pageWithName("GeneralErrorPage");
      }
    } //-- performActionNamed


Then in your Application() class enter this to handle the DirectAction
errors:

    public WOResponse handleActionRequestError(WORequest aRequest, Exception
exception, String reason, WORequestHandler aHandler, String
        actionClassName, String actionName, Class actionClass, WOAction
actionInstance) {
        log.error("unhandled Action Request Error:"+reason+" actionClass="+
actionClassName+" actionName="+actionName);
        if(actionInstance == null) return null;
        GeneralErrorPage page =
(GeneralErrorPage)pageWithName("GeneralErrorPage",
actionInstance.context());
        return  page.generateResponse();
    }

public WOResponse handleException(Exception ex, WOContext ctx) {

		//NSMutableDictionary info = new NSMutableDictionary();
		StringBuffer info = new StringBuffer();
		if(ctx != null && ctx.page() != null) {
			info.append("currentPage="+ctx.page().toString());
			info.append ("uri="+ctx.request().uri());
		}
		log.error("An unexpected error occured.\n"+ info + "\n\n",
ex);
		GeneralErrorPage page =
(GeneralErrorPage)pageWithName("GeneralErrorPage", ctx);
		return page.generateResponse();
	}

Also the SessionRestore is usefull too:

	public WOResponse handleSessionRestorationErrorInContext(WOContext
ctx) {
		if (log.isDebugEnabled()) log.debug("Session could not be
restored. It might have timed out.");
		WOComponent page = pageWithName("SessionTimeoutErrorPage",
ctx);
		return page.generateResponse();
	}

I found by having all of this code in place the hanging problem was
resolved.


Hope that helps.

Regards,
Steve.



-----Original Message-----
From: Denis Stanton [mailto:[email protected]]
Sent: 15 September 2004 20:54
To: Steven Pannell
Cc: '[email protected]'
Subject: Re: App freeze problem


Hi Steve

This could be relevant to some problems I'm getting.  Can you help me 
out a bit by directing me to the details you mention below?

"You can find more details about this in the forum archive"
Which archive?  I have saved mail from six webobjects discussion lists 
(3 x apple, 3 x omni)  It this subject discussed in one of those 
mailing lists, or is there some other archive to consult.

Denis Stanton

On 16/09/2004, at 1:29 AM, Steven Pannell wrote:

>
> Found out the problem.  This has to do with a DirectAction bug in WO.  
> Best
> thing is to implement the performAction method in your direct action to
> handle any kind of exceptions.  An exception can happen if a call is 
> made to
> the direct action for an action that does not exist. And that happens 
> all
> the time!.  You can find more details about this in the forum archive.
>
> Steve.
>