3 Replies Latest reply on Sep 1, 2008 12:49 PM by blabno

    Using @In and @Stateful-Stateless

    nimo22

      I have a EJB-Component and it is declared as follows:



      @Stateless
      @Name("hello")
      public class HelloEJBBean implements HelloEJBLocal {
      
              public HelloEJBBean() {
              }
      
      @PostConstruct
      public void init() {
      ..
      }
      ..
      }



      Now, I have a POJO in my WAR-File, which works well:


      @Name("pojo")
      public class POJO  {
      
       @In (create=true)
       HelloEJBLocal hello;



      So I do not know, for what do I need the @Stateful/Stateless-Annotations, as all SEAM-Components seems to be stateful via @In. I that right? Makes the extra @Stateful/Stateless-Annotations sense by using @In?


      Why does this not work?


      @Name("pojo")
      public class POJO  {
      
       @EJB
       HelloEJBLocal hello;


      ..
      }





        • 1. Re: Using @In and @Stateful-Stateless
          blabno

          Component is not statefull because it is injected via @In. @Stateful/Stateless-Annotations tell container to make EJB from POJO.


          As to @EJB ... I don't know.

          • 2. Re: Using @In and @Stateful-Stateless
            nimo22

            Really?


            I have this in my EJB-Component:


            @PostConstruct
            public void initialize() {
            log.info(This is called immediately after the EJB-Component is created !!!);
                 }


            and create a instance of my EJB-Component via @In in my POJO stored in my Client (WAR).


            The log shows, that the EJB-Component is instantiated via @In. So I assume, the annotation @PostConstruct is embeeded in an EJB-Component. However, I cannot use @EJB in SEAM. Should I ? For what when I have @In?

            • 3. Re: Using @In and @Stateful-Stateless
              blabno

              You do not need @EJB if those ejbs are @Name annotated seam components. I they are not then you need @EJB.