7 Replies Latest reply on Nov 5, 2009 9:58 PM by steeven

    NotBoundException when @Service POJO invoke EJB

      AS5.1.0, NO EJB3 Plugin installed.

      I packed service POJO and EJB3 SLSB together and the EJB injected to service bean doesn't worked steady. Sometimes the following exception raised when server start up and deploy.

      Is it a reason that EJB3 and Service POJO deployed in same time?
      The start() method invoked without related EJB/service ready?
      Is it possible to make this service POJO depend on EJB?

      I want to use Service POJO to do some initialization works when application server start up, am I lost in wrong direction?

      @Service(name = CmModule.SERVICE_NAME)
      public class CmModule implements ICmModule {
       public final static String SERVICE_NAME = "CmModule";
      
       Logger log = LoggerFactory.getLogger(CmModule.class);
      
       @EJB
       private IMoService moService;
      
       @TransactionAttribute(TransactionAttributeType.REQUIRED)
       public void start(){
       log.info("Cm Module started");
       moService.hello();
       log.info("Default Domain has been added.");
       }
      }



      5:51:23,084 INFO [CmModule] Cm Module started
      15:51:23,084 ERROR [STDERR] org.jboss.ejb3.common.registrar.spi.NotBoundException: Object is bound at key jboss.j2ee:ear=ems.ear,jar=ems-server.jar,name=MoService,service=EJB3, but is not fully installed, instead of state: ControllerState@18dbaa6{Start}
      15:51:23,084 ERROR [STDERR] at org.jboss.ejb3.common.registrar.plugin.mc.Ejb3McRegistrar.lookup(Ejb3McRegistrar.java:170)
      15:51:23,084 ERROR [STDERR] at org.jboss.ejb3.common.registrar.plugin.mc.Ejb3McRegistrar.lookup(Ejb3McRegistrar.java:134)
      15:51:23,084 ERROR [STDERR] at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.getContainerLocally(SessionProxyInvocationHandlerBase.java:410)
      15:51:23,084 ERROR [STDERR] at org.jboss.ejb3.proxy.impl.handler.session.SessionLocalProxyInvocationHandler.getContainer(SessionLocalProxyInvocationHandler.java:87)
      15:51:23,084 ERROR [STDERR] at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:193)
      15:51:23,084 ERROR [STDERR] at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:164)
      15:51:23,084 ERROR [STDERR] at $Proxy411.get(Unknown Source)
      15:51:23,084 ERROR [STDERR] at org.steeven.cm.CmModule.checkDefaultDomain(CmModule.java:51)
      15:51:23,084 ERROR [STDERR] at org.steeven.cm.CmModule.start(CmModule.java:43)
      15:51:23,084 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      15:51:23,084 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      15:51:23,084 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      15:51:23,084 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
      15:51:23,084 ERROR [STDERR] at org.jboss.ejb3.service.ServiceContainer.invokeOptionalMethod(ServiceContainer.java:369)
      15:51:23,084 ERROR [STDERR] at org.jboss.ejb3.service.ServiceContainer.lockedStart(ServiceContainer.java:264)
      15:51:23,084 ERROR [STDERR] at org.jboss.ejb3.EJBContainer.start(EJBContainer.java:884)
      15:51:23,084 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      15:51:23,084 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      15:51:23,084 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      15:51:23,084 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
      15:51:23,084 ERROR [STDERR] at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)
      15:51:23,084 ERROR [STDERR] at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150)
      15:51:23,084 ERROR [STDERR] at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)
      15:51:23,084 ERROR [STDERR] at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:241)
      15:51:23,084 ERROR [STDERR] at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47)
      15:51:23,084 ERROR [STDERR] at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:109)
      15:51:23,084 ERROR [STDERR] at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:70)
      15:51:23,084 ERROR [STDERR] at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:221)
      15:51:23,084 ERROR [STDERR] at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54)
      15:51:23,084 ERROR [STDERR] at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42)
      15:51:23,084 ERROR [STDERR] at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
      15:51:23,084 ERROR [STDERR] at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
      15:51:23,084 ERROR [STDERR] at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
      15:51:23,084 ERROR [STDERR] at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
      15:51:23,084 ERROR [STDERR] at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
      15:51:23,100 ERROR [STDERR] at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
      15:51:23,100 ERROR [STDERR] at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
      15:51:23,100 ERROR [STDERR] at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
      15:51:23,100 ERROR [STDERR] at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:774)
      15:51:23,100 ERROR [STDERR] at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:540)
      15:51:23,100 ERROR [STDERR] at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:121)
      15:51:23,100 ERROR [STDERR] at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:51)
      15:51:23,100 ERROR [STDERR] at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
      15:51:23,100 ERROR [STDERR] at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
      15:51:23,100 ERROR [STDERR] at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
      15:51:23,100 ERROR [STDERR] at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
      15:51:23,100 ERROR [STDERR] at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
      15:51:23,100 ERROR [STDERR] at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)
      15:51:23,100 ERROR [STDERR] at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1210)
      15:51:23,100 ERROR [STDERR] at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
      15:51:23,100 ERROR [STDERR] at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
      15:51:23,100 ERROR [STDERR] at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
      15:51:23,100 ERROR [STDERR] at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
      15:51:23,100 ERROR [STDERR] at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
      15:51:23,100 ERROR [STDERR] at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
      15:51:23,100 ERROR [STDERR] at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
      15:51:23,100 ERROR [STDERR] at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
      15:51:23,100 ERROR [STDERR] at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
      15:51:23,100 ERROR [STDERR] at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)
      15:51:23,100 ERROR [STDERR] at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
      15:51:23,100 ERROR [STDERR] at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)
      15:51:23,100 ERROR [STDERR] at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)
      15:51:23,100 ERROR [STDERR] at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:361)
      15:51:23,100 ERROR [STDERR] at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
      15:51:23,100 ERROR [STDERR] at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
      15:51:23,100 ERROR [STDERR] at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
      15:51:23,100 ERROR [STDERR] at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
      15:51:23,100 ERROR [STDERR] at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
      15:51:23,100 ERROR [STDERR] at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
      15:51:23,100 ERROR [STDERR] at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
      15:51:23,100 ERROR [STDERR] at org.jboss.system.server.profileservice.repository.AbstractProfileService.activateProfile(AbstractProfileService.java:306)
      15:51:23,100 ERROR [STDERR] at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:271)
      15:51:23,100 ERROR [STDERR] at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)
      15:51:23,100 ERROR [STDERR] at org.jboss.Main.boot(Main.java:221)
      15:51:23,100 ERROR [STDERR] at org.jboss.Main$1.run(Main.java:556)
      15:51:23,100 ERROR [STDERR] at java.lang.Thread.run(Thread.java:619)
      15:51:23,100 INFO [CmModule] Default Domain has been added.


        • 1. Re: NotBoundException when @Service POJO invoke EJB
          wolfgangknauf

          Hi,

          you are right, this is probably a timing issue, as the Service bean is probably deployed before the EJB. To avoid this: add a @Depends annotation to the service bean, which points to your EJB.
          The full EJB service name can be find in JNDIView.

          Hope this helps

          Wolfgang

          • 2. Re: NotBoundException when @Service POJO invoke EJB

            Thanks very much, I'll try it.

            • 3. Re: NotBoundException when @Service POJO invoke EJB

              Wolfgang, I have tried many names found in JNDI, none of them worked. Would you please post your Depends name? maybe I have to make EJB also as a @service?

              @Service(name = CmModule.SERVICE_NAME)
              @Depends( { "/MoService", "/ems/MoService", "/IMoService", "/ems/MoService/remote",
               "/ems/MoService/remote-com.genband.ems.gvu.server.mo.IMoService", "MoService", "ems/MoService", "IMoService",
               "ems/MoService/remote", "ems/MoService/remote-com.genband.ems.gvu.server.mo.IMoService" })
              public class CmModule implements ICmModule {
               public final static String SERVICE_NAME = "CmModule";
               // @PersistenceContext
               // private EntityManager em;
              
               Logger log = LoggerFactory.getLogger(CmModule.class);
              
               @EJB
               private IMoService moService;
               ....
              }
              

              Error message:
              DEPLOYMENTS IN ERROR:
               Deployment "<UNKNOWN jboss.j2ee:ear=ems.ear,jar=ems-server.jar,name=CmModule,service=EJB3>" is in error due to the following reason(s): ** UNRESOLVED Demands 'ems/MoService/remote' **, ** UNRESOLVED Demands '/MoService' **, ** UNRESOLVED Demands '/IMoService' **, ** UNRESOLVED Demands '/ems/MoService/remote-com.genband.ems.gvu.server.mo.IMoService' **, ** UNRESOLVED Demands '/ems/MoService/remote' **, ** UNRESOLVED Demands 'IMoService' **, ** UNRESOLVED Demands 'ems/MoService/remote-com.genband.ems.gvu.server.mo.IMoService' **, ** UNRESOLVED Demands '/ems/MoService' **, ** UNRESOLVED Demands 'ems/MoService' **, ** UNRESOLVED Demands 'MoService' **
              



              • 4. Re: NotBoundException when @Service POJO invoke EJB

                I think this should be a improvement of Service bean, all injected service should be ready before start() method.

                • 5. Re: NotBoundException when @Service POJO invoke EJB

                  Still not work, whatever how long I sleep in start()
                  void start(){
                  ...
                  sleep(50000);
                  moService.xxx(); //NotBound
                  }

                  I'm crazy now

                  • 6. Re: NotBoundException when @Service POJO invoke EJB
                    wolfgangknauf

                    Hi,

                    I used the "@Depends" only for a MDB queue, not for a depends on an EJB, so I cannot provide with a perfect sampl ;-).

                    But I think it should be:

                    @Depends(value="jboss.j2ee:ear=nameOfEarFile.ear,jar=nameOfJarFile.jar,name=nameOfBean,service=EJB3")

                    You used the JNDI names, but you need the name of the MBean.

                    Hope this helps

                    Wolfgang

                    • 7. Re: NotBoundException when @Service POJO invoke EJB

                      Wawo~ it worked! really appreciated!

                      This name can be easy found in NotBoundException.

                      I think Jboss should update document to make user happy.

                      I have another problem that EntityManager not injected well, maybe it's the same reason.

                      Thanks again~