Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-7980

Dependency Injection inconsistent with EJB3.1/JAX-RS

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 6.0.0.M2, 6.0.0.M3
    • EJB
    • None
    • Redhat Linux 4.1.2-41

      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.

              Unassigned Unassigned
              hipjon_jira Jon Kennedy (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: