[jboss-jira] [JBoss JIRA] Created: (JBAS-7980) Dependency Injection inconsistent with EJB3.1/JAX-RS

Jon Kennedy (JIRA) jira-events at lists.jboss.org
Tue Apr 27 13:47:10 EDT 2010


Dependency Injection inconsistent with EJB3.1/JAX-RS
----------------------------------------------------

                 Key: JBAS-7980
                 URL: https://jira.jboss.org/jira/browse/JBAS-7980
             Project: JBoss Application Server
          Issue Type: Bug
      Security Level: Public (Everyone can see)
          Components: EJB3
    Affects Versions: JBossAS-6.0.0.M2
         Environment: Redhat Linux 4.1.2-41
            Reporter: Jon Kennedy
            Assignee: Carlo de Wolf


I'm making use of the recent EJB3.1 support in JBoss6M2 to deploy a stateless session bean within a war. This bean also implements a JAX-RS annotated interface and is called as a web service. 

The session bean uses dependency injection to get a JPA EntityManager and the EJB SessionContext:

    @Resource 
    private SessionContext context;
	 
    @PersistenceContext(unitName="drs2_services")
    private EntityManager em;

The problem is that calling my service sometimes fails with a NullPointerException where I make use of the EntityManager or the SessionContext. This behavior is inconsistent and sometimes works. 

To add more detail: 

If I call the service and I get a NullPointerException on the EntityManager, I can work around the issue by restarting the service until the call succeeds. After it succeeds once, I won't see the NullPointerException again (until, perhaps, I restart the JBoss again).

The SessionContext issue is a little trickier. I am able to call my webservice from the browser successfully, but when using Java's HttpUrlConnection class, I consistently get a NullPointerException on the SessionContext. 

I followed the RestEasy 1.2 guide for configuring and annotating my project, specifically chapter 38 "EJB Integration." I didn't bundle the ReastEasy jars in my war since they are bundled with JBoss 6. 

Any help is appreciated, I'm happy to provide more details/code if desired. 




-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list