3 Replies Latest reply on Apr 15, 2010 9:25 PM by Pepe Gamba

    EJB 3.0 circular injection problem

    Mirek Sz Newbie

      Hello,

      I using jboss 5.0.0 GA (also tryied on jboss 5.1.0.GA)

      I have problem with injection. I have two services:

       

      @Local
      public interface DepatureService {
           void find();
      }
      
      @Stateless
      public class DepatureServiceImpl implements DepatureService {
           @EJB
           EmployeeService employeeService;
      
           @Override
           public void find() {
           }
      
      }
      
      
      @Local
      public interface EmployeeService {
           public void hire();
      }
      
      @Stateless
      public class EmployeeServiceImpl implements EmployeeService {
      
           @EJB
           DepatureService depatureService;
      
           @Override
           public void hire() {
           }
      
      }
      

       

      When I remove injection for example in EmployeeServiceImple or inDepartmentServiceImpl then works fine. But when I have this circular injection I get the following exception:

       

      20:49:24,968 INFO  [Ejb3DependenciesDeployer] Encountered deployment AbstractVFSDeploymentContext@5734641{vfszip:/D:/SPS/jboss-5.0.0.GA/server/default/deploy/testejb.jar}
      20:49:24,968 INFO  [Ejb3DependenciesDeployer] Encountered deployment AbstractVFSDeploymentContext@5734641{vfszip:/D:/SPS/jboss-5.0.0.GA/server/default/deploy/testejb.jar}
      20:49:25,078 INFO  [JBossASKernel] Created KernelDeployment for: testejb.jar
      20:49:25,078 INFO  [JBossASKernel] installing bean: jboss.j2ee:jar=testejb.jar,name=DepatureServiceImpl,service=EJB3
      20:49:25,078 INFO  [JBossASKernel]   with dependencies:
      20:49:25,078 INFO  [JBossASKernel]   and demands:
      20:49:25,078 INFO  [JBossASKernel]      jboss.ejb:service=EJBTimerService
      20:49:25,078 INFO  [JBossASKernel]      jndi:EmployeeServiceImpl/local-pakiet.EmployeeService
      20:49:25,078 INFO  [JBossASKernel]   and supplies:
      20:49:25,078 INFO  [JBossASKernel]      jndi:DepatureServiceImpl/local-pakiet.DepatureService
      20:49:25,078 INFO  [JBossASKernel]      jndi:DepatureServiceImpl/remote
      20:49:25,078 INFO  [JBossASKernel]      Class:pakiet.DepatureService
      20:49:25,078 INFO  [JBossASKernel]      jndi:DepatureServiceImpl/local
      20:49:25,078 INFO  [JBossASKernel] Added bean(jboss.j2ee:jar=testejb.jar,name=DepatureServiceImpl,service=EJB3) to KernelDeployment of: testejb.jar
      20:49:25,093 INFO  [JBossASKernel] installing bean: jboss.j2ee:jar=testejb.jar,name=EmployeeServiceImpl,service=EJB3
      20:49:25,093 INFO  [JBossASKernel]   with dependencies:
      20:49:25,093 INFO  [JBossASKernel]   and demands:
      20:49:25,093 INFO  [JBossASKernel]      jboss.ejb:service=EJBTimerService
      20:49:25,093 INFO  [JBossASKernel]      jndi:DepatureServiceImpl/local-pakiet.DepatureService
      20:49:25,093 INFO  [JBossASKernel]   and supplies:
      20:49:25,093 INFO  [JBossASKernel]      Class:pakiet.EmployeeService
      20:49:25,093 INFO  [JBossASKernel]      jndi:EmployeeServiceImpl/local-pakiet.EmployeeService
      20:49:25,093 INFO  [JBossASKernel]      jndi:EmployeeServiceImpl/remote
      20:49:25,093 INFO  [JBossASKernel]      jndi:EmployeeServiceImpl/local
      20:49:25,093 INFO  [JBossASKernel] Added bean(jboss.j2ee:jar=testejb.jar,name=EmployeeServiceImpl,service=EJB3) to KernelDeployment of: testejb.jar
      20:49:25,156 WARN  [HDScanner] Failed to process changes
      org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):
      
      *** CONTEXTS MISSING DEPENDENCIES: Name -> Dependency{Required State:Actual State}
      
      jboss.j2ee:jar=testejb.jar,name=DepatureServiceImpl,service=EJB3
       -> <UNKNOWN jboss.j2ee:jar=testejb.jar,name=DepatureServiceImpl,service=EJB3>{Described:** UNRESOLVED Demands 'jndi:EmployeeServiceImpl/local-pakiet.EmployeeService' **}
      
      jboss.j2ee:jar=testejb.jar,name=EmployeeServiceImpl,service=EJB3
       -> <UNKNOWN jboss.j2ee:jar=testejb.jar,name=EmployeeServiceImpl,service=EJB3>{Described:** UNRESOLVED Demands 'jndi:DepatureServiceImpl/local-pakiet.DepatureService' **}
      
      
      *** CONTEXTS IN ERROR: Name -> Error
      
      <UNKNOWN jboss.j2ee:jar=testejb.jar,name=DepatureServiceImpl,service=EJB3> -> ** UNRESOLVED Demands 'jndi:EmployeeServiceImpl/local-pakiet.EmployeeService' **
      
      <UNKNOWN jboss.j2ee:jar=testejb.jar,name=EmployeeServiceImpl,service=EJB3> -> ** UNRESOLVED Demands 'jndi:DepatureServiceImpl/local-pakiet.DepatureService' **
      
      
           at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:863)
           at org.jboss.deployers.plugins.main.MainDeployerImpl.checkComplete(MainDeployerImpl.java:665)
           at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDScanner.java:293)
           at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScanner.java:221)
           at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
           at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
           at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
           at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
           at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
           at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
           at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
           at java.lang.Thread.run(Thread.java:619)
      
      How to resolve this problem
      
      Best regards
      
      
        • 1. Re: EJB 3.0 circular injection problem
          jaikiran pai Master

          Use @IgnoreDependency on one side. See this for details http://community.jboss.org/message/526200#526200

          1 of 1 people found this helpful
          • 2. Re: EJB 3.0 circular injection problem
            Mirek Sz Newbie

            Thans for answer.

            This works but this is not solution. I'm writing application with many people and everyone can inject any service. When I injecting service A I don't know If service A has alrady injection to my service. Maybe I have to add @ignoreDependiency to each injection...

            • 3. Re: EJB 3.0 circular injection problem
              Pepe Gamba Newbie

              Hi. Sorry for mi english, I speak spanish.

               

              This is my "scenario":

              Im migrating an enterprise application from ejb2.x to ejb3 (im using jboss 5.1.0GA)

              The ear contains + or - 50 jars, and more than 300 ejbs and contains several circular dependencies, but it works fine before the migration.

              After the migration, I got the "CONTEXTS MISSING DEPENDENCIES" problems.

               

              I cant use the @IgnoreDependenciy, because the same ear must run in jboss and Websphere (and maybe others), and I dont want to use propietary annotations.

               

              Specify the <ignore-dependecy> in the jboss.xml is an option, but I have the problem in several places (and the double declaration complicate the maiteinance)

               

              My questions are:

               

              Exists some tool to generate the jboss.xml ?

              Is possible to specify the <ignore-dependecy> at class level (or jar level or ear level) ? Or configure the server in some way?

              Why the ear work fine before the migration ? (My boss ask me that )

               

              Thanks.

               

              PS: If you know another alternative, please let me know.