10 Replies Latest reply on Jun 16, 2006 12:08 AM by gavin.king

    Seam 1.0.0.GA Booking App: RegisterAction - Injected User In

    rogerk

      currently trying to get Seam 1.0.0.GA booking app running on Glassfish.
      Seems to deploy ok...
      When I go to register a new user (filling in username/password, ...) and clicking
      "Register", I get a NPE in RegisterAction --- due to the fact that the injected User
      instance is null.....

      ??

        • 1. Re: Seam 1.0.0.GA Booking App: RegisterAction - Injected Use
          theute

          It seems like the Seam Interceptor doesn't intercept.

          Try to add @Interceptor(SeamInterceptor.class) at the class level and let us know.

          (It should be already defined in ejb-jar.xml though)

          • 2. Re: Seam 1.0.0.GA Booking App: RegisterAction - Injected Use
            jagoh

            Thomas,

            Do you mean if already defined in ejb-jar.xml, at class level don't need to declare? Thanks.

            JA

            • 3. Re: Seam 1.0.0.GA Booking App: RegisterAction - Injected Use
              gavin.king

               

              "jagoh" wrote:
              Do you mean if already defined in ejb-jar.xml, at class level don't need to declare? Thanks.


              You should not need to, according to the spec, but try it anyway.

              • 4. Re: Seam 1.0.0.GA Booking App: RegisterAction - Injected Use
                rogerk

                I've already done that. Here is what the class looks like:
                @Stateful
                @Scope(EVENT)
                @Name("register")
                @Interceptors(SeamInterceptor.class)
                public class RegisterAction implements Register
                {

                @In
                private User user;
                ......

                After pressing the "Register" button in the app, it appears that the SeamInterceptor is getting called. Here is the call sequence:

                SeamInterceptor.aroundInvoke method called.

                @AroundInvoke
                public Object aroundInvoke(InvocationContext invocation) throws Exception
                {
                if ( !getUnproxiedClass( invocation.getTarget() ).isAnnotationPresent(Name.class) )
                {
                //not a Seam component
                return invocation.proceed();
                }

                invocation.proceed called.

                eventually, RegisterAction.register method called, but "user" is null.

                SeamInterceptor is set up in ejb-jar.xml *and* I have also tried it with and without the
                @Interceptors(SeamInterceptor.class) in the RegisterAction class.

                Any help would be greatly appreciated. Thanks,

                • 5. Re: Seam 1.0.0.GA Booking App: RegisterAction - Injected Use
                  gavin.king

                  OK, please try setting a breakpoint in BijectionInterceptor and see what happens....

                  • 6. Re: Seam 1.0.0.GA Booking App: RegisterAction - Injected Use
                    rogerk

                    BijectionInterceptor is never getting called. I've done a comparison with the working 1.0beta version and the FCS version.

                    ---------------
                    FCS Version
                    ---------------

                    Register button pressed.

                    SeamInterceptor.aroundInvoke called
                    ----> if ( !getUnproxiedClass( invocation.getTarget() ).isAnnotationPresent(Name.class) )
                    is true. Looks like it can't find "@Name" annotation on
                    "org.jboss.seam.example.booking._RegisterAction_Serializable"
                    As a result, "invocation.proceed" is always called, and
                    "aroundInvokeInContexts" is not called.
                    As a result, SeamInvocationContext is never called and
                    BijectionInterceptor is never called.

                    I've tried making it so "aroundInvokeInContexts" is called in SeamInterceptor.
                    Here is the result of that:

                    SeamInterceptor.aroundInvoke called
                    ----> aroundInvokeInContexts called.
                    ----> getSeamComponent called.
                    ----> Seam.getComponentName("org.jboss.seam.example.booking._RegisterAction_Serializable") called.
                    **** return value is null ****
                    Therefore SeamInvocationContext.proceed is never getting called.

                    -------------------
                    1.0beta Version
                    -------------------

                    Register button pressed.

                    SeamInterceptor.aroundInvoke called
                    ----> aroundInvokeInContexts called.
                    ----> getSeamComponent called.
                    ----> Seam.getComponentName("org.jboss.seam.example.booking._RegisterAction_Serializable") called.
                    **** RETURNS A VALUE ****
                    **** SeamInvocationContext.proceed is called, and
                    **** BijectionInterceptor is called.
                    Values are injected properly.

                    • 7. Re: Seam 1.0.0.GA Booking App: RegisterAction - Injected Use
                      gavin.king

                      OK, so GlassFish is subclassing the session bean, and I should be searching up the class hierarchy for the @Name annotation.

                      I will get this one fixed.

                      • 8. Re: Seam 1.0.0.GA Booking App: RegisterAction - Injected Use
                        rogerk

                        Ok. Thanks for looking at this. So it sounds like your potential fix wlll make it so
                        the Name annotation will be found, and "aroundInvokeInContexts" will be called.
                        The other problem was that even when I forced a call to "aroundInvokeInContexts"
                        Seam.getComponentName("org.jboss.seam.example.booking._RegisterAction_Serializable")
                        returned null.

                        Wil your fix address that as well?

                        Thanks.

                        • 9. Re: Seam 1.0.0.GA Booking App: RegisterAction - Injected Use
                          gavin.king

                          Yes, it is the same underlying problem.

                          • 10. Re: Seam 1.0.0.GA Booking App: RegisterAction - Injected Use
                            gavin.king

                            Roger, I just committed an attempt at a fix to CVS. Would you try it out please? Thanks