My question based on Can't get SessionContext on EJB, I want to inject EJBContext into my code
My code is:
import javax.ws.rs.core.Context;
public class EjbContextTest {
@Resource
private EJBContext ejbContext;
@Resource
private SessionContext sessionContext;
......
}
I have a simple testing in activator, just want to verify if I can get an EJBContext by using CDI:
public void start(BundleContext context) throws Exception {
EjbContextTest test = new EjbContextTest();
if (test.getEjbContext() == null) {
System.out.println("ejbContext is: null" );
} else
System.out.println("ejbContext rollback only is: " +
test.getEjbContext().getRollbackOnly());
}
When deploying the bundle into glassfish 3.1.2 I can't get an instance of EJBContext:
2013-03-29 17:11:20,547|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging| _ThreadID=15;_ThreadName=Thread-2;|-----------> ejbContext is: null*|#]
Please, if you have any suggestion, I will be glad to try it.
@Resourceto inject the contexts? - kolossus