text: Reuse stateless services built with SeamGuillaume Jeudy Sep 24, 2008 4:40 PM
  Hi,
  I'm using Seam 2.0.1.GA and I would like to know if I can reuse my stateless service layer for remote EJB calls issued by other applications.
  I'm using SMPC so the EntityManager gets injected through @In annotation. I realize that if I access my stateless EJB through traditional JNDI lookup the EntityManager will not get injected.
  Has anyone found a solution where I can still get the EntityManager injected? I guess I would need somehow to pass through Seam context to get hold of my stateless EJB.
  Another alternative I guess is to inject both
  @Stateless @Local(MyLocalInterface.class) @Remote(MyRemoteInterface.class) public class MyStatelessServiceImpl implements MyLocalInterface, MyRemoteInterface { @In EntityManager em; @PersistenceContext(unit="MyPU") EntityManager em2; ... }
  and use @In EntityManager if populated otherwise fallback to @PersistenceContext injected one. This workaround appears a little messy though..
  Thanks,
  -Guillaume
  1. Re: Reuse stateless services built with SeamBen Moore Sep 24, 2008 9:36 PM (in response to Guillaume Jeudy)
  I am also interested in a solution to this besides using @PersistenceContext.
  2. Re: Reuse stateless services built with SeamAlex Savitsky Sep 25, 2008 6:30 PM (in response to Guillaume Jeudy)
  If your EJB executes locally, then I guess the manual lookup Component.getInstance(
  em) should work - just place it in your getEm() as a fallback to when em is null.
  3. Re: Reuse stateless services built with SeamGuillaume Jeudy Sep 25, 2008 7:31 PM (in response to Guillaume Jeudy)
  Not a bad idea, I should give this a try and see how it goes.
  4. Re: Reuse stateless services built with SeamGuillaume Jeudy Oct 23, 2008 5:44 PM (in response to Guillaume Jeudy)
  Reviving this thread. I don't know what I was thinking when I first replied. I'm not reusing the stateless services in a local context but a remote context where no Seam conversation or Seam session is available, therefore bye bye SMPC.
  Anyone got a way to solve this problem without injecting both @In entityManager and @PersistenceContext entityManager to my stateless service EJB?