-
1. Re: EntityManager in EJB not injected in overloaded method
aslak Aug 23, 2011 6:30 AM (in response to pedrokowalski)1 of 1 people found this helpfulI suspect this is a GlassFish issue. Arquillian is only involed in looking up the Bean, not creating it.
-
2. Re: EntityManager in EJB not injected in overloaded method
pedrokowalski Aug 23, 2011 7:28 PM (in response to aslak)Yup, it isn't an arquillian problem.
The above (as well as the below) code works fine on JBoss AS7.
In the matter of fact the problem occurs when you're using generics, so the following example can be simplified to the following form:
@Stateless public class CRUDBean<T> { @PersistenceContext private EntityManager em; public void find(Object e) { System.out.println("!!!!!!!!!!!!!!! find(Object e) em: " + em); } public void find(T id) { System.out.println("!!!!!!!!!!!!!!! find(T id) em: " + em); } }
Then:
1. find(Object e) will have the em injected properly.
2. find(T id) will not have the em injected.
Interestingly:
- if you remove the arguments from find(Object e), both find methods will have em injected properly,
- if you will change the signature of find(T id) to find(String id), both find methods will have em injected properly (the String class is just an example of non-generic used as an argument).
I just posted it here, because it was so friggin' hidden thing that caused me a day of wondering why my tests were failing...
Cheers!
Message was edited by: Pedro Kowalski (java syntax highlighter and further simplification (no extends in generics)
-
3. Re: EntityManager in EJB not injected in overloaded method
pedrokowalski Aug 27, 2011 9:42 AM (in response to pedrokowalski)Just for information purposes - following issue has been created in glassfish JIRA: http://java.net/jira/browse/GLASSFISH-17235
Cheers