[jboss-user] [JBoss Seam] - Re: Re-working EJB Extended Context To Use SMPC - Need Help

curtney do-not-reply at jboss.com
Wed Oct 10 15:20:30 EDT 2007


Sorry for having to rehash this again, but I am still getting wierd results. I have tripple check my configuration, looked at all the examples applications and still not working.

Pete and et al, please read the following perhaps my reasoning/understanding is way off.

I have tried three different scenarios (getting desparate here):

Scenario One:

I am using @EJB annotation to inject my ejb components, instead of Seam's @In annotation. My ejb components are injected successfully, but the entity manager is not injected on subsequent ejb components (The first ejb component, MyStatefulBean, does get the entity manager injected).

Scenario Two:

All ejb components are injected using Seam's @In annotation (Switched from @EJB to @In annotation). Why the switch? I am assumming the swith will solve my problem of the entity manager not being injected. Seam now has controll of the creation and injection of the ejb components, thus proper injection of the entity manager. However, that is not the case injection fails on both ejb components and entity manager. Before, it was only the entity manager that did not get injected.

Scenario Three:

Remove all ejb annotations (Just POJOS) and have Seam do all injections. It works! All injections works, except that I get an exception on my generic dao object. But hey, injection works!!


  | java.lang.ClassCastException java.lang.Class 
  | 
  | //Implementation was taken from Hibernate persistence book
  | public MyGenericDAO () {
  | 	this.bean = (Class<T>) ((ParameterizeType)getClass().getGenericSuperclass()).getActualTypeArguments()[0];
  | }
  | 

See below for ejb component setup:

I have a Stateful bean with @Name annotation I can inject an entity manager instance,
using @In (It works, entityManager is not null). In this same stateful bean I have a stateless bean(MyStatlessBean) that is being inject via @EJB annotation. The injection works.


  | @Stateful
  | @Name("myStateful")
  | public MyStatefulBean implements SomeInterface {
  | 
  | @In
  | EntityManager entityManager; //Injected (not null)
  | 
  | @EJB
  | MyStatelessBean myStatlessBean;//Injected (not null)
  | 
  | 

MyStatelessBean has another stateless bean (MyStatlessDAO) that is also being injected with @EJB.
However, the declared entity manager is not injected. I am assumming it fails because Seam does not have control of the creation and injection of the ejb (myStatlessDAO)???


  | public MyStatelessBean implements SomeInterface {
  | 
  | @In
  | private EntityManager entityManager; //Not injected (null)
  | 
  | @EJB
  | private MyStatelessDAO myStatelessDAO;//Injected (not null)
  | 
  | }
  | 

Again, MyStatelessDAO entity manager is not injected (It inherits this from MyGenericDAO). It fails because Seam does not have control of the creation and injection of the ejb?


  | @Stateless
  | @Name("myStateless")
  | public MyStatlessDAO extends MyGenericDAO <MyObject, Its Type) implements SomInterface {
  | 
  | //Super class entity manager is null, not injected.
  | 
  | }
  | 
  | 
  | public abstract class MyGenericDAO <T, ID> implements MyGenericInterfce <T, ID> {
  | 
  | @In
  | protected EntityManager entityManager; //Not injected (null)
  | 
  | }
  | 





View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4093687#4093687

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4093687



More information about the jboss-user mailing list