i am writing some junit tests, using an EJBContainer. All works fine, except getting the EJBContext within the stateless beans. I need this context to obtain user role information. Tried to get the context both ways:
@Resource private javax.ejb.EJBContext ctx;
This leads to an EXCEPTION_ACCESS_VIOLATION.
InitialContext ic = new InitialContext(props);
EJBContext ctx = (EJBContext) ic.lookup("java:comp/EJBContext");
Fails to look up the context (javax.naming.NamingException).
I followed the recommendations given here for adding the jndi.properties. According to procmon the file is red. Any ideas why this happens? The bean works within a real environment.
Some more information about my setup:
- Windows 7 x64
- Current Java 6 SDK x32
- JUnit 4.10
- glassfish-embedded-all 3.1.1
The problem wasn’t Glassfish related. I copied the file “javaee-endorsed-api-6.0.jar” into my sdk endorsed folder a while ago to get use of the
annotation in my Eclipse IDE. After the removal of it, all worked.