1 Reply Latest reply on Oct 5, 2010 2:15 PM by Leo van den berg

    Is Seam supposed to manage SLSB components injected by @EJB?

    Xiubo Zhang Newbie

      Hi everyone,

      I am facing a problem when building a Seam enabled web application upon a pure EJB module.

      Simply put, I'd like to employ SMPC and manual flushing when the EJBs are used in the web tier while leave them as standard EJBs when accessed by other parts of the system (e.g. MDBs).

      I have some of the EJBs defined as Seam components for web tier use, but as described above I was expecting those beans injected by @EJB to be managed by EJB containers rather than Seam. However, this is not the case:

      @Name("seamEJB")    // This is the EJB the web tier will have access to.
      public class SeamEJB implements SeamEJBLocal {
          @In    // I am expecting Seam to ignore this when the EJB is injected to other beans using @EJB
          EntityManager entityManager;
          public void someMethod(SomeEntity someEntity) {

      // This is a standard EJB used in the back-end only
      public class ClientEJB impelments ClientEJBLocal, ClientEJBRemote {
          @EJB SeamEJBLocal seamEJB;    // Shouldn't seamEJB be managed by EJB container rather than Seam?
                                                (thus entityManager is injected by @PersistenceContext)
          public void clientMethod() {
              seamEJB.someMethod(entity);  // This call may cause detached entity exception,
                                                  since SMPC is injected in seamEJB

      I think is a fairly logical expectation since I can always inject seamEJB as Seam component using:

      @In SeamEJBLocal seamEJB;

      So my question is:

      Is this behaviour a bug in Seam? If not, then what would be the best way to share Seam components with a pure EJB module without suffering detached entity exceptions/LIEs ?

      Any suggestion is appreciated! Thanks in advance!