8 Replies Latest reply on Oct 10, 2009 9:01 AM by josdaniel

    Stateless and Create exception

    monkeyden

      Using 2.0.3.CR1, I get the following error on start up.  I'm pretty sure the error isn't actually what it says.  I don't define a @Create in my bean, though I'd like to.  I question the presence of the @Create on Query.validate(), but that may have been designed for the components.xml configuration and not extension.


      Only JavaBeans and stateful session beans support @Create methods: participantList




      @Stateless - GlobalUsersQueryController is a subclass of EntityQuery.  I have multiple SMPC and use it to override getPersistenceContextName()


      @Stateless
      @Scope(ScopeType.PAGE)
      @Name("participantList")
      public class ParticipantListBean extends GlobalUsersQueryController<UserView> implements ParticipantList {
          @In
          FacesMessages facesMessages;
      



      @Local


      @Local
      public interface ParticipantList {
      
          public void search();
      
          public UserView getCriteria();
      
          public void setCriteria(UserView criteria);
      
          public Prefix getPrefix();
      
          public void setPrefix(Prefix prefix);
      }

        • 1. Re: Stateless and Create exception
          monkeyden

          So looking at Component.scanMethod() I see the error being thrown:


          if (type!=JAVA_BEAN && type!=STATEFUL_SESSION_BEAN)
          {
              throw new IllegalArgumentException("Only JavaBeans and stateful session beans support @Create methods: " + name);
          }
          



          I assume there is good reason for this, I just can't imagine why.  I would expect that ALL Seam components could have a @Create.

          • 2. Re: Stateless and Create exception
            swd847

            You are trying to bind a stateless session bean to the page context. This is not possible, if it is stateless it should be bound to the stateless context (which it will be by default). If it really has to be PAGE scoped use a Java Bean or SFSB (incidentally page scope is generally a bad idea, but that is a matter for another thread).


            If you need to run logic on stateless bean creation use the @PostContruct ejb3 annotation.

            • 3. Re: Stateless and Create exception
              spaceyoyo.spaceyoyo.neuf.fr

              Hello,


              I have the same issue.
              I want to use SLSB which extends EntityHome. Like this :


              @Stateless
              @Name("userDAO")
              public class UserDAOImp extends EntityHome<User> implements
                   IUserDAOLocal, IUserDAORemote {



              But EntityHome have a @Create annotation so my application fail to start, and i obtain this exception :


              java.lang.IllegalArgumentException: Only JavaBeans and stateful session beans support @Create methods: userDAO



              Why ? And how to use SLSB with EntityHome ?


              Thanks fo your future help

              • 4. Re: Stateless and Create exception
                pedrosena

                @lionel meroni:


                Your problem is related to another thing.


                The EntityHome itself already has a method with @Create annotation, for this reason you cannot declare other method with this annotation(annotations are inherited).


                Take a look at documentation and try to override the method that is annotated with create, but do not forget to call the parent method before your code, just to avoid weird behavior.


                Regards,


                Pedro Sena

                • 5. Re: Stateless and Create exception
                  spaceyoyo.spaceyoyo.neuf.fr

                  Hello Pedro,


                  As I wrote, the exception say :



                  Only JavaBeans and stateful session beans support @Create methods



                  So a stateless session bean could not have a method with @Create annotation.
                  So a stateless session bean could not extends EntityHome !!!


                  BUT in the documentation here :
                  My Link
                  There is an example of a Stateless bean which extends EntityHome.


                  Actualy this is not possible ? Is the documentation up to date or wrong ??


                  • 6. Re: Stateless and Create exception
                    pedrosena

                    Lionel,


                    Use a Seam component(stateless scoped) instead of a EJB in this case. In this case they can be switched if no cost.



                    Is what I'm doing here.


                    Regards,


                    PS

                    • 7. Re: Stateless and Create exception
                      spaceyoyo.spaceyoyo.neuf.fr

                      Thanks Pedro, with


                      @Scope(ScopeType.STATELESS)



                      It work !

                      • 8. Re: Stateless and Create exception
                        josdaniel

                        I am a little confused here, does this mean it is not possible to expose seam components as stateless session beans (as mentioned in the reference docs). I get the same IllegalArgumentException mentioned in this thread above.


                        What would be the suggested practice to expose the seam components as stateless session beans?