2 Replies Latest reply on Jan 21, 2014 7:54 AM by garberfc

    Trouble injecting into Stateless EJB

    garberfc

      Hello,

       

      We have an AS 6.1 web application and we're implementing some @Stateless EJBs. Our problem is that an EJB doesn't seem to get injected into another EJB.

       

      Both EJBs are in the same package and are both declared with @Stateless. One of the beans needs to use the other and has the following notation within it:

       

      @EJB
      HelloWorldEJB helloWorldEjb;

       

      When I start the server I see both EJB get deployed and the aren't any errors. It's just at runtime the 'helloWorldEjb' reference is always null!

       

      Any questions / suggestions would be much appreciated.

       

      Thanks in advance,

      Frank

        • 1. Re: Trouble injecting into Stateless EJB
          garberfc

          A couple more pieces of information:

           

          The EJBs reside in a WAR file.

          The target EJB is a Restful service with annotation: @Path("api")

           

          Here are the console lines when the EJBs are created:

          13:22:12,581 INFO  [org.jboss.weld.deployer] (MSC service thread 1-6) JBAS016002: Processing weld deployment prod-ops-reportingtool-rest-web.war

          13:22:12,583 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-6) JNDI bindings for session bean named PortWorkOrderResource in deployment unit subdeployment "prod-ops-reportingtool-rest-web.war" of deployment "prod-ops-reportingtool-ear.ear" are as follows:

           

           

            java:global/prod-ops-reportingtool-ear/prod-ops-reportingtool-rest-web/PortWorkOrderResource!com.espn.port.rest.resource.PortWorkOrderResource

            java:app/prod-ops-reportingtool-rest-web/PortWorkOrderResource!com.espn.port.rest.resource.PortWorkOrderResource

            java:module/PortWorkOrderResource!com.espn.port.rest.resource.PortWorkOrderResource

            java:global/prod-ops-reportingtool-ear/prod-ops-reportingtool-rest-web/PortWorkOrderResource

            java:app/prod-ops-reportingtool-rest-web/PortWorkOrderResource

            java:module/PortWorkOrderResource

           

           

          13:22:12,583 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-6) JNDI bindings for session bean named HelloWorldEJB in deployment unit subdeployment "prod-ops-reportingtool-rest-web.war" of deployment "prod-ops-reportingtool-ear.ear" are as follows:

           

           

            java:global/prod-ops-reportingtool-ear/prod-ops-reportingtool-rest-web/HelloWorldEJB!com.espn.port.rest.resource.HelloWorldEJB

            java:app/prod-ops-reportingtool-rest-web/HelloWorldEJB!com.espn.port.rest.resource.HelloWorldEJB

            java:module/HelloWorldEJB!com.espn.port.rest.resource.HelloWorldEJB

            java:global/prod-ops-reportingtool-ear/prod-ops-reportingtool-rest-web/HelloWorldEJB

            java:app/prod-ops-reportingtool-rest-web/HelloWorldEJB

            java:module/HelloWorldEJB

          • 2. Re: Trouble injecting into Stateless EJB
            garberfc

            The problem was been discovered in our code base. The EJB that was supposed to be getting another EJB injected into it was being created directly via another class and NOT via the container. The container never had the opportunity to perform the injection.