You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@beehive.apache.org by "Carlin Rogers (JIRA)" <de...@beehive.apache.org> on 2006/02/03 23:15:03 UTC

[jira] Created: (BEEHIVE-1059) ClassCastException when InternalUtils.addActionError() casts ActionMessages for the Global.ERROR_KEY attribute to a sub class, ActionErrors

ClassCastException when InternalUtils.addActionError() casts ActionMessages for the Global.ERROR_KEY attribute to a sub class, ActionErrors
-------------------------------------------------------------------------------------------------------------------------------------------

         Key: BEEHIVE-1059
         URL: http://issues.apache.org/jira/browse/BEEHIVE-1059
     Project: Beehive
        Type: Bug
  Components: NetUI  
    Versions: V1, v.next, 1.0.1    
    Reporter: Carlin Rogers
 Assigned to: Carlin Rogers 
     Fix For: v.next


The implementaion of InternalUtils.addActionError() casts the org.apache.struts.action.ActionMessages for the Global.ERROR_KEY attribute to a sub class of org.apache.struts.action.ActionErrors. However, in all the other code paths where we set the attribute for Global.ERROR_KEY, we use the parent class, ActionMessages.

If a user implements @Jpf.ExceptionHandler method in a page flow and then calls FlowController.addActionError(), they will experience this ClassCastException. When an exception is thrown, the DefaultExceptionsHandler will set the attribute for Global.ERROR_KEY with a new instance ActionMessages that includes the ActionMessage with the exception message. Then it invokes the exception handler declared in the annotations of the page flow. When the FlowController.addActionError() is called, the internal code path will call InternalUtils.addActionError() and try to cast the ActionMessages to ActionErrors, giving a stack trace like this...

03 Feb 2006 14:55:19,987 ERROR DefaultExceptionsHandler []: Unhandled Page Flow Exception

Throwable: java.lang.ClassCastException: org.apache.struts.action.ActionMessages

Stack Trace:
java.lang.ClassCastException: org.apache.struts.action.ActionMessages
        at org.apache.beehive.netui.pageflow.internal.InternalUtils.addActionError(InternalUtils.java:415)
        at org.apache.beehive.netui.pageflow.FlowController.addActionError(FlowController.java:1439)
...

I will add a test to this shortly. To reproduce you really just need an implementation of an exception handler that calls addActionError(). Something like this...

    @Jpf.ExceptionHandler(
        forwards = {
            @Jpf.Forward(
                name = "handleError",
                path = "index.jsp")
        })
    protected Forward bogusExceptionHandler( Controller.BogusException ex,
                                           String actionName,
                                           String message, Object form ) {
        Object[] args = ex.getMessageArgs();
        addActionError("name", "messageKey_2", args);
        return new Forward( "handleError" );
    }


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


[jira] Resolved: (BEEHIVE-1059) ClassCastException when InternalUtils.addActionError() casts ActionMessages for the Global.ERROR_KEY attribute to a sub class, ActionErrors

Posted by "Carlin Rogers (JIRA)" <de...@beehive.apache.org>.
     [ http://issues.apache.org/jira/browse/BEEHIVE-1059?page=all ]
     
Carlin Rogers resolved BEEHIVE-1059:
------------------------------------

    Resolution: Fixed
     Assign To: Julie Zhuo  (was: Carlin Rogers)

Fixed with revision 378760.  See http://svn.apache.org/viewcvs?rev=378760&view=rev

A test to cover this scenario was added to the BVT.

> ClassCastException when InternalUtils.addActionError() casts ActionMessages for the Global.ERROR_KEY attribute to a sub class, ActionErrors
> -------------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: BEEHIVE-1059
>          URL: http://issues.apache.org/jira/browse/BEEHIVE-1059
>      Project: Beehive
>         Type: Bug
>   Components: NetUI
>     Versions: V1, 1.0.1, v.next
>     Reporter: Carlin Rogers
>     Assignee: Julie Zhuo
>      Fix For: v.next
>  Attachments: j1059-repro.zip
>
> The implementaion of InternalUtils.addActionError() casts the org.apache.struts.action.ActionMessages for the Global.ERROR_KEY attribute to a sub class of org.apache.struts.action.ActionErrors. However, in all the other code paths where we set the attribute for Global.ERROR_KEY, we use the parent class, ActionMessages.
> If a user implements @Jpf.ExceptionHandler method in a page flow and then calls FlowController.addActionError(), they will experience this ClassCastException. When an exception is thrown, the DefaultExceptionsHandler will set the attribute for Global.ERROR_KEY with a new instance ActionMessages that includes the ActionMessage with the exception message. Then it invokes the exception handler declared in the annotations of the page flow. When the FlowController.addActionError() is called, the internal code path will call InternalUtils.addActionError() and try to cast the ActionMessages to ActionErrors, giving a stack trace like this...
> 03 Feb 2006 14:55:19,987 ERROR DefaultExceptionsHandler []: Unhandled Page Flow Exception
> Throwable: java.lang.ClassCastException: org.apache.struts.action.ActionMessages
> Stack Trace:
> java.lang.ClassCastException: org.apache.struts.action.ActionMessages
>         at org.apache.beehive.netui.pageflow.internal.InternalUtils.addActionError(InternalUtils.java:415)
>         at org.apache.beehive.netui.pageflow.FlowController.addActionError(FlowController.java:1439)
> ...
> I will add a test to this shortly. To reproduce you really just need an implementation of an exception handler that calls addActionError(). Something like this...
>     @Jpf.ExceptionHandler(
>         forwards = {
>             @Jpf.Forward(
>                 name = "handleError",
>                 path = "index.jsp")
>         })
>     protected Forward bogusExceptionHandler( Controller.BogusException ex,
>                                            String actionName,
>                                            String message, Object form ) {
>         Object[] args = ex.getMessageArgs();
>         addActionError("name", "messageKey_2", args);
>         return new Forward( "handleError" );
>     }

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


[jira] Closed: (BEEHIVE-1059) ClassCastException when InternalUtils.addActionError() casts ActionMessages for the Global.ERROR_KEY attribute to a sub class, ActionErrors

Posted by "Julie Zhuo (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/BEEHIVE-1059?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julie Zhuo closed BEEHIVE-1059.
-------------------------------


Based on Russ's verification, close this out.

> ClassCastException when InternalUtils.addActionError() casts ActionMessages for the Global.ERROR_KEY attribute to a sub class, ActionErrors
> -------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: BEEHIVE-1059
>                 URL: https://issues.apache.org/jira/browse/BEEHIVE-1059
>             Project: Beehive
>          Issue Type: Bug
>          Components: NetUI
>    Affects Versions: 1.0, 1.0.1, 1.0.2
>            Reporter: Carlin Rogers
>            Assignee: Julie Zhuo
>             Fix For: 1.0.2
>
>         Attachments: j1059-repro.zip
>
>
> The implementaion of InternalUtils.addActionError() casts the org.apache.struts.action.ActionMessages for the Global.ERROR_KEY attribute to a sub class of org.apache.struts.action.ActionErrors. However, in all the other code paths where we set the attribute for Global.ERROR_KEY, we use the parent class, ActionMessages.
> If a user implements @Jpf.ExceptionHandler method in a page flow and then calls FlowController.addActionError(), they will experience this ClassCastException. When an exception is thrown, the DefaultExceptionsHandler will set the attribute for Global.ERROR_KEY with a new instance ActionMessages that includes the ActionMessage with the exception message. Then it invokes the exception handler declared in the annotations of the page flow. When the FlowController.addActionError() is called, the internal code path will call InternalUtils.addActionError() and try to cast the ActionMessages to ActionErrors, giving a stack trace like this...
> 03 Feb 2006 14:55:19,987 ERROR DefaultExceptionsHandler []: Unhandled Page Flow Exception
> Throwable: java.lang.ClassCastException: org.apache.struts.action.ActionMessages
> Stack Trace:
> java.lang.ClassCastException: org.apache.struts.action.ActionMessages
>         at org.apache.beehive.netui.pageflow.internal.InternalUtils.addActionError(InternalUtils.java:415)
>         at org.apache.beehive.netui.pageflow.FlowController.addActionError(FlowController.java:1439)
> ...
> I will add a test to this shortly. To reproduce you really just need an implementation of an exception handler that calls addActionError(). Something like this...
>     @Jpf.ExceptionHandler(
>         forwards = {
>             @Jpf.Forward(
>                 name = "handleError",
>                 path = "index.jsp")
>         })
>     protected Forward bogusExceptionHandler( Controller.BogusException ex,
>                                            String actionName,
>                                            String message, Object form ) {
>         Object[] args = ex.getMessageArgs();
>         addActionError("name", "messageKey_2", args);
>         return new Forward( "handleError" );
>     }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (BEEHIVE-1059) ClassCastException when InternalUtils.addActionError() casts ActionMessages for the Global.ERROR_KEY attribute to a sub class, ActionErrors

Posted by "Carlin Rogers (JIRA)" <de...@beehive.apache.org>.
     [ http://issues.apache.org/jira/browse/BEEHIVE-1059?page=all ]

Carlin Rogers updated BEEHIVE-1059:
-----------------------------------

    Attachment: j1059-repro.zip

This zip file includes a simple test to repro this issue. It can also be used as a test for the future.

> ClassCastException when InternalUtils.addActionError() casts ActionMessages for the Global.ERROR_KEY attribute to a sub class, ActionErrors
> -------------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: BEEHIVE-1059
>          URL: http://issues.apache.org/jira/browse/BEEHIVE-1059
>      Project: Beehive
>         Type: Bug
>   Components: NetUI
>     Versions: V1, v.next, 1.0.1
>     Reporter: Carlin Rogers
>     Assignee: Carlin Rogers
>      Fix For: v.next
>  Attachments: j1059-repro.zip
>
> The implementaion of InternalUtils.addActionError() casts the org.apache.struts.action.ActionMessages for the Global.ERROR_KEY attribute to a sub class of org.apache.struts.action.ActionErrors. However, in all the other code paths where we set the attribute for Global.ERROR_KEY, we use the parent class, ActionMessages.
> If a user implements @Jpf.ExceptionHandler method in a page flow and then calls FlowController.addActionError(), they will experience this ClassCastException. When an exception is thrown, the DefaultExceptionsHandler will set the attribute for Global.ERROR_KEY with a new instance ActionMessages that includes the ActionMessage with the exception message. Then it invokes the exception handler declared in the annotations of the page flow. When the FlowController.addActionError() is called, the internal code path will call InternalUtils.addActionError() and try to cast the ActionMessages to ActionErrors, giving a stack trace like this...
> 03 Feb 2006 14:55:19,987 ERROR DefaultExceptionsHandler []: Unhandled Page Flow Exception
> Throwable: java.lang.ClassCastException: org.apache.struts.action.ActionMessages
> Stack Trace:
> java.lang.ClassCastException: org.apache.struts.action.ActionMessages
>         at org.apache.beehive.netui.pageflow.internal.InternalUtils.addActionError(InternalUtils.java:415)
>         at org.apache.beehive.netui.pageflow.FlowController.addActionError(FlowController.java:1439)
> ...
> I will add a test to this shortly. To reproduce you really just need an implementation of an exception handler that calls addActionError(). Something like this...
>     @Jpf.ExceptionHandler(
>         forwards = {
>             @Jpf.Forward(
>                 name = "handleError",
>                 path = "index.jsp")
>         })
>     protected Forward bogusExceptionHandler( Controller.BogusException ex,
>                                            String actionName,
>                                            String message, Object form ) {
>         Object[] args = ex.getMessageArgs();
>         addActionError("name", "messageKey_2", args);
>         return new Forward( "handleError" );
>     }

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


[jira] Commented: (BEEHIVE-1059) ClassCastException when InternalUtils.addActionError() casts ActionMessages for the Global.ERROR_KEY attribute to a sub class, ActionErrors

Posted by "Carlin Rogers (JIRA)" <de...@beehive.apache.org>.
    [ http://issues.apache.org/jira/browse/BEEHIVE-1059?page=comments#action_12365148 ] 

Carlin Rogers commented on BEEHIVE-1059:
----------------------------------------

The fix for this bug is a two liner... famous last words. Once v1.0.1 is out the door and the flood gates open, I'll check this into the trunk.

In src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalUtils, look for the method addActionError() and change...

    ActionErrors errors = ( ActionErrors ) request.getAttribute( Globals.ERROR_KEY );
    if ( errors == null ) request.setAttribute( Globals.ERROR_KEY, errors = new ActionErrors() );

to...

    ActionMessages errors = ( ActionMessages ) request.getAttribute( Globals.ERROR_KEY );
    if ( errors == null ) request.setAttribute( Globals.ERROR_KEY, errors = new ActionMessages() );


> ClassCastException when InternalUtils.addActionError() casts ActionMessages for the Global.ERROR_KEY attribute to a sub class, ActionErrors
> -------------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: BEEHIVE-1059
>          URL: http://issues.apache.org/jira/browse/BEEHIVE-1059
>      Project: Beehive
>         Type: Bug
>   Components: NetUI
>     Versions: V1, v.next, 1.0.1
>     Reporter: Carlin Rogers
>     Assignee: Carlin Rogers
>      Fix For: v.next
>  Attachments: j1059-repro.zip
>
> The implementaion of InternalUtils.addActionError() casts the org.apache.struts.action.ActionMessages for the Global.ERROR_KEY attribute to a sub class of org.apache.struts.action.ActionErrors. However, in all the other code paths where we set the attribute for Global.ERROR_KEY, we use the parent class, ActionMessages.
> If a user implements @Jpf.ExceptionHandler method in a page flow and then calls FlowController.addActionError(), they will experience this ClassCastException. When an exception is thrown, the DefaultExceptionsHandler will set the attribute for Global.ERROR_KEY with a new instance ActionMessages that includes the ActionMessage with the exception message. Then it invokes the exception handler declared in the annotations of the page flow. When the FlowController.addActionError() is called, the internal code path will call InternalUtils.addActionError() and try to cast the ActionMessages to ActionErrors, giving a stack trace like this...
> 03 Feb 2006 14:55:19,987 ERROR DefaultExceptionsHandler []: Unhandled Page Flow Exception
> Throwable: java.lang.ClassCastException: org.apache.struts.action.ActionMessages
> Stack Trace:
> java.lang.ClassCastException: org.apache.struts.action.ActionMessages
>         at org.apache.beehive.netui.pageflow.internal.InternalUtils.addActionError(InternalUtils.java:415)
>         at org.apache.beehive.netui.pageflow.FlowController.addActionError(FlowController.java:1439)
> ...
> I will add a test to this shortly. To reproduce you really just need an implementation of an exception handler that calls addActionError(). Something like this...
>     @Jpf.ExceptionHandler(
>         forwards = {
>             @Jpf.Forward(
>                 name = "handleError",
>                 path = "index.jsp")
>         })
>     protected Forward bogusExceptionHandler( Controller.BogusException ex,
>                                            String actionName,
>                                            String message, Object form ) {
>         Object[] args = ex.getMessageArgs();
>         addActionError("name", "messageKey_2", args);
>         return new Forward( "handleError" );
>     }

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


[jira] Updated: (BEEHIVE-1059) ClassCastException when InternalUtils.addActionError() casts ActionMessages for the Global.ERROR_KEY attribute to a sub class, ActionErrors

Posted by "Russ Baker (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/BEEHIVE-1059?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Russ Baker updated BEEHIVE-1059:
--------------------------------


Verified that Jpf.ExceptionHandler does not throw a ClassCastException when using the 'FlowController.addActionError()' method in the implementation of the ExceptionHandler. Verified using Carlin's attached repro against SVN 549584. I recommend that this bug be closed.

> ClassCastException when InternalUtils.addActionError() casts ActionMessages for the Global.ERROR_KEY attribute to a sub class, ActionErrors
> -------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: BEEHIVE-1059
>                 URL: https://issues.apache.org/jira/browse/BEEHIVE-1059
>             Project: Beehive
>          Issue Type: Bug
>          Components: NetUI
>    Affects Versions: 1.0, 1.0.1, 1.0.2
>            Reporter: Carlin Rogers
>            Assignee: Julie Zhuo
>             Fix For: 1.0.2
>
>         Attachments: j1059-repro.zip
>
>
> The implementaion of InternalUtils.addActionError() casts the org.apache.struts.action.ActionMessages for the Global.ERROR_KEY attribute to a sub class of org.apache.struts.action.ActionErrors. However, in all the other code paths where we set the attribute for Global.ERROR_KEY, we use the parent class, ActionMessages.
> If a user implements @Jpf.ExceptionHandler method in a page flow and then calls FlowController.addActionError(), they will experience this ClassCastException. When an exception is thrown, the DefaultExceptionsHandler will set the attribute for Global.ERROR_KEY with a new instance ActionMessages that includes the ActionMessage with the exception message. Then it invokes the exception handler declared in the annotations of the page flow. When the FlowController.addActionError() is called, the internal code path will call InternalUtils.addActionError() and try to cast the ActionMessages to ActionErrors, giving a stack trace like this...
> 03 Feb 2006 14:55:19,987 ERROR DefaultExceptionsHandler []: Unhandled Page Flow Exception
> Throwable: java.lang.ClassCastException: org.apache.struts.action.ActionMessages
> Stack Trace:
> java.lang.ClassCastException: org.apache.struts.action.ActionMessages
>         at org.apache.beehive.netui.pageflow.internal.InternalUtils.addActionError(InternalUtils.java:415)
>         at org.apache.beehive.netui.pageflow.FlowController.addActionError(FlowController.java:1439)
> ...
> I will add a test to this shortly. To reproduce you really just need an implementation of an exception handler that calls addActionError(). Something like this...
>     @Jpf.ExceptionHandler(
>         forwards = {
>             @Jpf.Forward(
>                 name = "handleError",
>                 path = "index.jsp")
>         })
>     protected Forward bogusExceptionHandler( Controller.BogusException ex,
>                                            String actionName,
>                                            String message, Object form ) {
>         Object[] args = ex.getMessageArgs();
>         addActionError("name", "messageKey_2", args);
>         return new Forward( "handleError" );
>     }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.