[ 
http://www.stripesframework.org/jira/browse/STS-527?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=11425#action_11425
 ] 

Jarek Lipski commented on STS-527:
----------------------------------

I think this bug still exists in newest stripes 1.5rc1. The exception is thrown 
when error message is displayed on the page inside <stripes:errors/> tag.

Here's my exception handler code (not finished, I know that I shouldn't return 
null at the end):
        public Resolution handle(Exception exception, HttpServletRequest 
request,
                        HttpServletResponse response) {
                
            logger.warn("Exception. Message: " + exception.getMessage(), 
exception);
        
            ActionBean action = (ActionBean)request.getAttribute(
                        StripesConstants.REQ_ATTR_ACTION_BEAN);
        
            if (action != null)
            {
                    action.getContext().getValidationErrors().addGlobalError(
                                new 
LocalizableError("myproject.myerror.exception"));
                    return action.getContext().getSourcePageResolution();
            }
        
            return null; 
        }


Here's part of the stacktrace:
java.lang.NullPointerException
        at 
net.sourceforge.stripes.validation.LocalizableError.getMessageTemplate(LocalizableError.java:91)
        at 
net.sourceforge.stripes.action.SimpleMessage.getMessage(SimpleMessage.java:91)
        at 
net.sourceforge.stripes.validation.SimpleError.getMessage(SimpleError.java:102)
        at net.sourceforge.stripes.tag.ErrorsTag.doEndTag(ErrorsTag.java:349)

Looks like first line in LocalizableError.getMessageTemplate is causing 
problems, because beanclass is null.
        String template = LocalizationUtility.getErrorMessage(locale, 
getBeanclass().getName() + "." + messageKey);


> NPE when using LocalizableError in AutoExceptionHandler
> -------------------------------------------------------
>
>                 Key: STS-527
>                 URL: http://www.stripesframework.org/jira/browse/STS-527
>             Project: Stripes
>          Issue Type: Bug
>          Components: ActionBean Dispatching
>    Affects Versions: Release 1.5
>            Reporter: Frederic Daoud
>            Assignee: Frederic Daoud
>             Fix For: Release 1.5
>
>
> When using a LocalizableError in AutoExceptionHandler, a NPE is thrown 
> because of trying to access the beanclass, which has not been set at this 
> point.
> More details: http://permalink.gmane.org/gmane.comp.java.stripes.user/7225
> Using beanclass was introduced in Stripes 1.5, so this is a bug.
> The fix is to guard against null and move on to other keys for localizable 
> errors.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://www.stripesframework.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to