7 Replies Latest reply on Dec 23, 2011 4:23 AM by jaikiran pai

    Inject service in service (service dependency)

    Michael Wittig Newbie

      Hi,

       

      I use jboss-6.1.0.Final and have two Services, let us call them ServiceA and ServiceB. ServiceB depends on ServiceA, because ServiceB wants to inject ServiceA.

      So I added @Depend to ServiceB. Now the services are started in the right order, everything works.

      But now I try to inject ServiceA within ServiceB. This causes an error like this:

       

      13:17:10,866 WARN  [org.jboss.profileservice.deployment.hotdeploy.HDScanner] Scan failed: org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):
      
      
      DEPLOYMENTS MISSING DEPENDENCIES:
        Deployment "jboss-switchboard:appName=com.test.pool,module=com.test.poolEJB,name=ServiceB" is missing the following dependencies:
          Dependency "jboss.j2ee:ear=com.test.pool.ear,jar=com.test.poolEJB.jar,name=ServiceA,service=EJB3" (should be in state "Installed", but is actually in state "Configured")
        Deployment "jboss.j2ee:ear=com.test.pool.ear,jar=com.test.poolEJB.jar,name=KXPriceImporterService,service=EJB3" is missing the following dependencies:
          Dependency "<UNKNOWN jboss.j2ee:ear=com.test.pool.ear,jar=com.test.poolEJB.jar,name=KXPriceImporterService,service=EJB3>" (should be in state "Installed", but is actually in state "** UNRESOLVED Demands 'jboss.j2ee:ear=com.test.pool.ear,jar=com.test.poolEJB.jar,name=PriceService,service=EJB3' **")
        Deployment "jboss.j2ee:ear=com.test.pool.ear,jar=com.test.poolEJB.jar,name=PriceService,service=EJB3" is missing the following dependencies:
          Dependency "<UNKNOWN jboss.j2ee:ear=com.test.pool.ear,jar=com.test.poolEJB.jar,name=PriceService,service=EJB3>" (should be in state "Installed", but is actually in state "** UNRESOLVED Demands 'jboss-switchboard:appName=com.test.pool,module=com.test.poolEJB,name=ServiceB' **")
        Deployment "jboss.j2ee:ear=com.test.pool.ear,jar=com.test.poolEJB.jar,name=RandomPriceImporterService,service=EJB3" is missing the following dependencies:
          Dependency "<UNKNOWN jboss.j2ee:ear=com.test.pool.ear,jar=com.test.poolEJB.jar,name=RandomPriceImporterService,service=EJB3>" (should be in state "Installed", but is actually in state "** UNRESOLVED Demands 'jboss.j2ee:ear=com.test.pool.ear,jar=com.test.poolEJB.jar,name=PriceService,service=EJB3' **")
        Deployment "jboss.j2ee:ear=com.test.pool.ear,jar=com.test.poolEJB.jar,name=ServiceA,service=EJB3" is missing the following dependencies:
          Dependency "<UNKNOWN jboss.j2ee:ear=com.test.pool.ear,jar=com.test.poolEJB.jar,name=ServiceA,service=EJB3>" (should be in state "Installed", but is actually in state "** UNRESOLVED Demands 'jboss-switchboard:appName=com.test.pool,module=com.test.poolEJB,name=ServiceB' **")
        Deployment "jboss.j2ee:ear=com.test.pool.ear,jar=com.test.poolEJB.jar,name=ServiceB,service=EJB3" is missing the following dependencies:
          Dependency "<UNKNOWN jboss.j2ee:ear=com.test.pool.ear,jar=com.test.poolEJB.jar,name=ServiceB,service=EJB3>" (should be in state "Installed", but is actually in state "** UNRESOLVED Demands 'jboss.j2ee:ear=com.test.pool.ear,jar=com.test.poolEJB.jar,name=ServiceA,service=EJB3' **")
      
      
      DEPLOYMENTS IN ERROR:
        Deployment "<UNKNOWN jboss.j2ee:ear=com.test.pool.ear,jar=com.test.poolEJB.jar,name=KXPriceImporterService,service=EJB3>" is in error due to the following reason(s): ** UNRESOLVED Demands 'jboss.j2ee:ear=com.test.pool.ear,jar=com.test.poolEJB.jar,name=PriceService,service=EJB3' **
        Deployment "<UNKNOWN jboss.j2ee:ear=com.test.pool.ear,jar=com.test.poolEJB.jar,name=PriceService,service=EJB3>" is in error due to the following reason(s): ** UNRESOLVED Demands 'jboss-switchboard:appName=com.test.pool,module=com.test.poolEJB,name=ServiceB' **
        Deployment "<UNKNOWN jboss.j2ee:ear=com.test.pool.ear,jar=com.test.poolEJB.jar,name=ServiceA,service=EJB3>" is in error due to the following reason(s): ** UNRESOLVED Demands 'jboss-switchboard:appName=com.test.pool,module=com.test.poolEJB,name=ServiceB' **
        Deployment "<UNKNOWN jboss.j2ee:ear=com.test.pool.ear,jar=com.test.poolEJB.jar,name=ServiceB,service=EJB3>" is in error due to the following reason(s): ** UNRESOLVED Demands 'jboss.j2ee:ear=com.test.pool.ear,jar=com.test.poolEJB.jar,name=ServiceA,service=EJB3' **
        Deployment "<UNKNOWN jboss.j2ee:ear=com.test.pool.ear,jar=com.test.poolEJB.jar,name=RandomPriceImporterService,service=EJB3>" is in error due to the following reason(s): ** UNRESOLVED Demands 'jboss.j2ee:ear=com.test.pool.ear,jar=com.test.poolEJB.jar,name=PriceService,service=EJB3' **
      
      
                at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:1370) [:2.2.2.GA]
                at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:1316) [:2.2.2.GA]
                at org.jboss.deployers.plugins.main.MainDeployerImpl.checkComplete(MainDeployerImpl.java:968) [:2.2.2.GA]
                at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.checkComplete(MainDeployerPlugin.java:82) [:6.1.0.Final]
                at org.jboss.profileservice.dependency.ProfileControllerContext$DelegateDeployer.checkComplete(ProfileControllerContext.java:138) [:0.2.2]
                at org.jboss.profileservice.deployment.hotdeploy.HDScanner$HDScanAction.deploy(HDScanner.java:246) [:0.2.2]
                at org.jboss.profileservice.deployment.hotdeploy.HDScanner$HDScanAction.complete(HDScanner.java:192) [:0.2.2]
                at org.jboss.profileservice.management.TwoPCActionWrapper.doComplete(TwoPCActionWrapper.java:57) [:0.2.2]
                at org.jboss.profileservice.management.actions.AbstractTwoPhaseModificationAction.complete(AbstractTwoPhaseModificationAction.java:74) [:0.2.2]
                at org.jboss.profileservice.management.actions.AbstractTwoPhaseModificationAction.prepare(AbstractTwoPhaseModificationAction.java:95) [:0.2.2]
                at org.jboss.profileservice.management.ModificationSession.prepare(ModificationSession.java:87) [:0.2.2]
                at org.jboss.profileservice.management.AbstractActionController.internalPerfom(AbstractActionController.java:234) [:0.2.2]
                at org.jboss.profileservice.management.AbstractActionController.performWrite(AbstractActionController.java:213) [:0.2.2]
                at org.jboss.profileservice.management.AbstractActionController.perform(AbstractActionController.java:150) [:0.2.2]
                at org.jboss.profileservice.management.AbstractActionController.perform(AbstractActionController.java:135) [:0.2.2]
                at org.jboss.profileservice.deployment.hotdeploy.HDScanner.scan(HDScanner.java:146) [:0.2.2]
                at org.jboss.profileservice.deployment.hotdeploy.HDScanner.run(HDScanner.java:90) [:0.2.2]
                at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [:1.6.0_26]
                at java.util.concurrent.FutureTask$Sync.innerRunAndReset(Unknown Source) [:1.6.0_26]
                at java.util.concurrent.FutureTask.runAndReset(Unknown Source) [:1.6.0_26]
                at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(Unknown Source) [:1.6.0_26]
                at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(Unknown Source) [:1.6.0_26]
                at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [:1.6.0_26]
                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [:1.6.0_26]
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [:1.6.0_26]
                at java.lang.Thread.run(Unknown Source) [:1.6.0_26]
      
      
      

       

      The Service*Management Interface is annotated with @Management and Service*Local with @Local.

      @Service
      public class ServiceA implements ServiceAManagement, ServiceALocal {
                @Override
                public final void create() throws Exception {
                     System.out.println("ServiceA: create");
                }
                @Override
                public final void start() throws Exception {
                     System.out.println("ServiceA: start");
                }
                 @Override
                public final void stop() {
                     System.out.println("ServiceA: stop");
                }
                @Override
                public final void destroy() {
                     System.out.println("ServiceA: destroy");
                }
      }
      
      @Service
      @Depends("jboss.j2ee:ear=com.test.pool.ear,jar=com.test.poolEJB.jar,name=ServiceA,service=EJB3")
      public class ServiceB implements ServiceBManagement, ServiceBLocal {
                @EJB
                ServiceALocal serviceA;
      
                @Override
                public final void create() throws Exception {
                     System.out.println("ServiceB: create");
                }
                @Override
                public final void start() throws Exception {
                     System.out.println("ServiceB: start");
                }
                @Override
                public final void stop() {
                     System.out.println("ServiceB: stop");
                }
                @Override
                public final void destroy() {
                     System.out.println("ServiceB: destroy");
                } 
      }