6 Replies Latest reply on Aug 24, 2007 3:34 PM by Matt Drees

    @Create not called 100% of the time

    Chris Hane Novice

      I have the following SFSB:

      @Name("finder")
      @Stateful
      @Scope(ScopeType.EVENT)
      @LoggedIn
      public class ActivityGenericFinder implements IActivityGenericFinder {
      
       public ActivityGenericFinder(){
       log.fatal("CONSTRUCTING");
       }
      
       @Create
       public void initialize(){
       init();
       }
      
       protected void init(){
       AppUtils.LOG.fatal("INITING");
       }
      
       public String find(){
       ..do stuff for find...
       }
      
       public String next(){
       ... change offset ...
       find();
       }
      
       ........
      
      }


      What I have noticed is the the @Create method is not always called. Here is the sequence:

      - initial call to find (remember this is an Event scoped component)
      * component is constructed and then @create called

      - call next
      * component is constructed and then @Create called

      - wait for session to timeout (set to 1 minute in web.xml for testing)

      - call next
      * component is constructed
      * component @Create is NOT called
      !! Exception occurs since important stuff happens in @Create (e.g., initialize variables)

      If I move my important stuff to the constructor, everything works as I expect - so I have a workaround. I just don't like it and wondering if I am doing something wrong

      I am using 1.2.1p1 on JBoss 4.0.4.

      Has anyone else seen this? Thoughts on what to do next?

      Chris....

        • 1. Re: @Create not called 100% of the time
          Matt Drees Master

          Just to clarify, find() and next() are not called in the same request, right?

          • 2. Re: @Create not called 100% of the time
            Matt Drees Master

            oops. duh. Read your post wrong. Sorry.

            • 3. Re: @Create not called 100% of the time
              Chris Hane Novice

               

              "matt.drees" wrote:
              Just to clarify, find() and next() are not called in the same request, right?



              Correct. Each call is in a separate request (click from the GUI).

              Chris...

              • 4. Re: @Create not called 100% of the time
                Chris Hane Novice

                I have been able to track it down to a specific place in the Seam code; but now I'm stuck as to how to debug next.....

                In Component.callComponentMethod the following is being executed:

                public Object callComponentMethod(Object instance, Method method, Object... parameters) {
                 Class[] paramTypes = method.getParameterTypes();
                 String methodName = method.getName();
                 if("bo.activity.finder".equals(name))
                 log.fatal("1 CALLING CREATE METHOD["+methodName+"]");
                 try
                 {
                 Method interfaceMethod = instance.getClass().getMethod(methodName, paramTypes);
                 if ( paramTypes.length==0 || interfaceMethod.getParameterTypes().length==0 )
                 {
                 if("bo.activity.finder".equals(name))
                 log.fatal("2 CALLING CREATE METHOD["+methodName+"] interfaceMethod["+interfaceMethod+"]");
                 return Reflections.invokeAndWrap(interfaceMethod, instance);
                 }
                 else if ( parameters.length>0 )
                 {interfaceMethod["+interfaceMethod+"]");
                 return Reflections.invokeAndWrap(interfaceMethod, instance, parameters);
                 }
                 else
                 {interfaceMethod["+interfaceMethod+"]");
                 return Reflections.invokeAndWrap(interfaceMethod, instance, this);
                 }
                 }
                 catch (NoSuchMethodException e)
                 {
                 String message = "method not found: " + method.getName() + " for component: " + name;
                 if ( getType().isSessionBean() )
                 {
                 message += " (check that it is declared on the session bean business interface)";
                 }
                 throw new IllegalArgumentException(message, e);
                 }
                 }


                The
                 if("bo.activity.finder".equals(name))
                 log.fatal("2 CALLING CREATE METHOD["+methodName+"]
                 return Reflections.invokeAndWrap(interfaceMethod, instance);


                Is not being executed correctly. When the session has not expired I get this stack trace:


                13:20:26,937 FATAL [Component] NEW COMPONENT[bo.activity.finder] STATE[EVENT] !STATELESS[true] hasCreate[true]
                13:20:26,937 FATAL [Component] 1 CALLING CREATE METHOD[initialize]
                13:20:26,937 FATAL [Component] 2 CALLING CREATE METHOD[initialize] interfaceMethod[public final void com.itsolut.backoffice.actions.contact.activity.inf.IActivityGenericFinder$$EnhancerByCGLIB$$5d882077.initialize()]
                13:20:26,937 FATAL [AppUtils] INITING
                java.lang.Exception
                 at com.itsolut.backoffice.actions.contact.activity.ActivityGenericFinder.init(ActivityGenericFinder.java:49)
                 at com.itsolut.core.action.Finder.initialize(Finder.java:80)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                


                When I execute the next() after the session is expired I get:
                13:22:46,609 FATAL [Component] NEW COMPONENT[bo.activity.finder] STATE[EVENT] !STATELESS[true] hasCreate[true]
                13:22:46,609 FATAL [Component] 1 CALLING CREATE METHOD[initialize]
                13:22:46,609 FATAL [Component] 2 CALLING CREATE METHOD[initialize] interfaceMethod[public final void com.itsolut.backoffice.actions.contact.activity.inf.IActivityGenericFinder$$EnhancerByCGLIB$$5d882077.initialize()]
                 ... and then nothing...the LOG message for INIT is not here like above
                


                Seam looks like it is trying to invoke the @Create method. It just is never actually invoked.

                Thoughts? Is this a CGLIB issue?

                Chris....

                • 5. Re: @Create not called 100% of the time
                  Chris Hane Novice

                  I'm not sure what was happening as I had compiled/deployed several times. However, I did a "clean" dist and that seems to have cleared up the issue.

                  Strange....

                  At least I learned a little more about the internals of Seam.

                  Chris....

                  • 6. Re: @Create not called 100% of the time
                    Matt Drees Master

                    Yeah, I've had experiences like that. Definitely frustrating.

                    It is kinda cool learning how Seam works, though.
                    Glad it's working for you.