4 Replies Latest reply on Dec 1, 2009 11:27 PM by Arbi Sookazian

    Injection and Outjection

    Sinbad Kim Newbie

      Sometimes i meet some exceptions on use of @In and @Out, because i don't know exact meaning of those and attributes.
      The common exception is:
         *javax.ejb.EJBTransactionRolledbackException: could not set field value: XXX.service*
      I declared like this:

              public Class Service {

              public Class XXX {
                private Service service;

      What is the problem in this code?
      And maybe, you can explain me the difference between @In and @Out including their attributes such as "create", "required".

      Thanks for you help!!!
        • 1. Re: Injection and Outjection
          Adrien Orsier Newbie

          As far as I know you can't do injection an Entity bean, it simply doesn't work.
          About the explanation, I doubt I can do it better than in the docs, I'd advice you to read carefully those and maybe ask your questions afterward.

          • 2. Re: Injection and Outjection
            Pawel Wrzeszcz Novice

            You mix 2 things, so don't be surprised it does not work :) Stateless session beans (@Stateless) and JPA entities (@Entity) should be different objects. Maybe you ought to read a bit about ejb3 or have a look at the examples :)


            • 3. Re: Injection and Outjection
              Victor Cherkassky Newbie

              For anyone who wants to know what exactly is wrong with the code.
              @Stateless is EJB annotation which marks EJB bean as statefull.
              @Entity is a JPA annotation which marks POJO as DB Entity. Seam manages all @Entity marked objects as entities, so you don't need any further configuration like adding some AnnotationConfigurator (which was needed in spring).

              @In and @Out annotations can only be applied to Seam managed beans (POJO or EJB). It is also wrong to use @Entity as Seam bean (by adding @Name annotation) as in (for example) hibernate entity has its own lifecycle.

              • 4. Re: Injection and Outjection
                Arbi Sookazian Master

                Sorry, the last post has a couple of mistakes in it.

                @Stateless denotes a SLSB, not SFSB.

                You can use @Entity with @Name: http://java.dzone.com/articles/magic-jboss-seam.  If you want to refer directly to a JPA entity from a JSF EL method, then you must use @Name with @Entity (see SiA book for examples).

                AFAIK bijection interceptors are not active/available with JPA entity classes, but are active with session beans and JavaBeans.