1 2 Previous Next 16 Replies Latest reply on Jan 7, 2009 5:44 AM by Andrew Rubinger

    MBean start ordering in 5.0CR2

    Hubert Holierhoek Newbie

      I'm having difficulty with MBean start ordering in AS 5.0CR2. I've got two MBeans: MBeanA with an @Depends annotation referencing the other, plus an injected (@Resource) reference to it. In the start method of MBeanB I initialize a POJO singleton. When MBeanA's start method is called, it calls a method on MBeanB via its injected reference, which delegates to the singleton. The problem is that at this point, a field in the singleton has not been initialized, as MBeanB's start method hasn't yet been called.

      Am I doing something wrong? This used to work in 4.2.1. Or is this just broken? Is anyone else having issues with dependencies?

      If I remove the @Depends, I get an injection error indicating that the name hasn't been bound yet, so the annotation does seem to be affecting something.

      I also get other occasional dependency problems - sometimes things go completely unresolved, even though the JMX console shows them.

        • 1. Re: MBean start ordering in 5.0CR2
          Hubert Holierhoek Newbie

          I should probably add that to get this far, I had to download, build and apply the 1.0.0-Beta4 release of the EJB3 module.

          • 2. Re: MBean start ordering in 5.0CR2
            jaikiran pai Master

            Can you please post the code of those MBeans and the exception stacktrace? That will help in understanding the problem better.

            While posting the logs or xml content or code, remember to wrap it in a code block using the Code button in the message editor window and please hit the Preview button to make sure your post is correctly formatted

            • 3. Re: MBean start ordering in 5.0CR2
              Hubert Holierhoek Newbie

              Here are the various classes involved, pruned down to the relevant bits. Let me know if I've done too much pruning.

              // MBeanB in the initial post
              @Management(StatisticsAdmin.class)
              @Service(objectName = "com.alcatel.tpapps.common:service=StatisticsAdmin")
              @RemoteBinding(jndiBinding = StatisticsAdmin.JNDI_NAME)
              public class StatisticsMBean
               implements StatisticsAdmin
              {
               public void start() throws OperationFailedException
               {
               StatisticsManager.getInstance().init(getDBStatisticsSamplingInterval(),
               getDBRateCalculationEnabled());
               }
              
               public void registerCounter(String aInCounterName,
               String aInDesc)
               throws OperationFailedException
               {
               StatisticsManager.getInstance().
               registerCounter(aInCounterName, aInDesc);
               }
               ...
              }


              // MBeanA in the initial post
              @Management(BasicMBeanInterface.class)
              @Service(objectName = "com.alcatel.tpapps.rac:service=BWAllocatorAdmin")
              @Depends({"com.alcatel.tpapps.common:service=StatisticsAdmin"})
              public class BWAllocatorAdminMBean implements BasicMBeanInterface
              {
               @Resource(mappedName = StatisticsAdmin.JNDI_NAME)
               StatisticsAdmin statsAdmin;
              
              
               public void start() throws OperationFailedException
               {
               // Counter Registration
               registerCounters();
               }
              
               private void registerCounters() throws OperationFailedException
               {
               Enumeration<String> lCounterList =
               BWAllocatorCounters.getInstance().getKeys();
               while (lCounterList.hasMoreElements())
               {
               String lCounterName = lCounterList.nextElement();
              
               statsAdmin.registerCounter(lCounterName,
               BWAllocatorCounters.getInstance().getCounterDescription(
               lCounterName));
               }
               }
              }



              // The Singleton class
              public class StatisticsManager
              {
               private static StatisticsManager instance = new StatisticsManager();
              
               private String localHost = null;
               private long statisticsSamplingInterval = 0L;
               private boolean rateCalculationEnabled = false;
              
               public static StatisticsManager getInstance()
               {
               return instance;
               }
               public void init(long aInSamplingInterval,
               boolean aInRateCalculationEnabled) throws OperationFailedException
               {
               try
               {
               localHost = InetAddress.getLocalHost().getHostAddress();
               }
               catch (UnknownHostException e)
               {
               //noinspection ThrowInsideCatchBlockWhichIgnoresCaughtException
               throw new OperationFailedException(Level.ERROR,
               "IP address of localhost could not be determined. ("
               + e.getMessage() + ')');
               }
              
               rateCalculationEnabled = aInRateCalculationEnabled;
               statisticsSamplingInterval = aInSamplingInterval;
               }
              
               public synchronized Counter registerCounter(String aInCounterName,
               String aInDesc)
               throws OperationFailedException
               {
               ...
               // When this is called, localHost is null. There's more code here, which
               // ultimately ends up assigning the null localHost to a not-null constrained
               // field of an entity and persists that entity
               }
              }


              And here's the exception:
              javax.ejb.EJBTransactionRolledbackException: org.hibernate.PropertyValueException: not-null property references a null or transient value: com.myorg.common.par.Statistic.hostIpAddress
              java.lang.RuntimeException: Problem registering @Management interface for @Service class com.myorg.rac.server.bwallocator.BWAllocatorAdminMBean
               at org.jboss.ejb3.service.ServiceContainer.registerManagementInterface(ServiceContainer.java:641)
               at org.jboss.ejb3.service.ServiceContainer.lockedStart(ServiceContainer.java:241)
               at org.jboss.ejb3.EJBContainer.start(EJBContainer.java:866)
               at sun.reflect.GeneratedMethodAccessor190.invoke(Unknown Source)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:597)
               at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)
               at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150)
               at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)
               at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:241)
               at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47)
               at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:109)
               at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:70)
               at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:221)
               at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54)
               at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42)
               at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
               at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
               at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
               at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
               at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)
               at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
               at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)
               at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
               at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:774)
               at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:540)
               at org.jboss.kernel.plugins.dependency.AbstractKernelController.install(AbstractKernelController.java:106)
               at org.jboss.kernel.plugins.dependency.AbstractKernelController.install(AbstractKernelController.java:100)
               at org.jboss.ejb3.deployers.JBossASKernel.install(JBossASKernel.java:154)
               at org.jboss.ejb3.deployers.JBossASKernel.installMBean(JBossASKernel.java:172)
               at org.jboss.ejb3.service.ServiceContainer.registerManagementInterface(ServiceContainer.java:615)
               at org.jboss.ejb3.service.ServiceContainer.lockedStart(ServiceContainer.java:241)
               at org.jboss.ejb3.EJBContainer.start(EJBContainer.java:866)
               at sun.reflect.GeneratedMethodAccessor190.invoke(Unknown Source)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:597)
               at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)
               at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150)
               at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)
               at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:241)
               at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47)
               at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:109)
               at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:70)
               at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:221)
               at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54)
               at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42)
               at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
               at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
               at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
               at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
               at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)
               at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
               at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)
               at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
               at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:774)
               at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:540)
               at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:124)
               at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:51)
               at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
               at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
               at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:169)
               at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1285)
               at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1003)
               at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1024)
               at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1056)
               at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:944)
               at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
               at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)
               at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
               at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)
               at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
               at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
               at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
               at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:627)
               at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:541)
               at org.jboss.system.server.profileservice.ProfileServiceBootstrap.loadProfile(ProfileServiceBootstrap.java:265)
               at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:143)
               at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:409)
               at org.jboss.Main.boot(Main.java:209)
               at org.jboss.Main$1.run(Main.java:544)
               at java.lang.Thread.run(Thread.java:619)
              Caused by: java.lang.RuntimeException: javax.management.MBeanException
               at org.jboss.ejb3.deployers.JBossASKernel.installMBean(JBossASKernel.java:181)
               at org.jboss.ejb3.service.ServiceContainer.registerManagementInterface(ServiceContainer.java:615)
               ... 80 more
              Caused by: javax.management.MBeanException
               at org.jboss.ejb3.service.ServiceMBeanDelegate.invoke(ServiceMBeanDelegate.java:219)
               at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
               at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
               at org.jboss.ejb3.deployers.JBossASKernel.invokeOptionalMethod(JBossASKernel.java:287)
               at org.jboss.ejb3.deployers.JBossASKernel.installMBean(JBossASKernel.java:177)
               ... 81 more
              Caused by: javax.ejb.EJBTransactionRolledbackException: org.hibernate.PropertyValueException: not-null property references a null or transient value: com.myorg.common.par.Statistic.hostIpAddress
               at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:115)
               at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
               at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:194)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:157)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:65)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:485)
               at org.jboss.ejb3.remoting.IsLocalInterceptor.invokeLocal(IsLocalInterceptor.java:97)
               at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:74)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:62)
               at $Proxy388.invoke(Unknown Source)
               at org.jboss.ejb3.proxy.handler.session.SessionSpecProxyInvocationHandlerBase.invoke(SessionSpecProxyInvocationHandlerBase.java:125)
               at $Proxy382.addManagedObject(Unknown Source)
               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
               at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:597)
               at com.myorg.common.utils.RefProxy$1.invoke(RefProxy.java:64)
               at $Proxy422.addManagedObject(Unknown Source)
               at com.myorg.common.server.statistics.StatisticsManager.createStatistic(StatisticsManager.java:289)
               at com.myorg.common.server.statistics.StatisticsManager.registerCounter(StatisticsManager.java:262)
               at com.myorg.common.server.statistics.StatisticsMBean.registerCounter(StatisticsMBean.java:77)
               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
               at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:597)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111)
               at org.jboss.ejb3.EJBContainerInvocationWrapper.invokeNext(EJBContainerInvocationWrapper.java:69)
               at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.invoke(InterceptorSequencer.java:73)
               at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.aroundInvoke(InterceptorSequencer.java:59)
               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
               at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:597)
               at org.jboss.aop.advice.PerJoinpointAdvice.invoke(PerJoinpointAdvice.java:174)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.fillMethod(InvocationContextInterceptor.java:72)
               at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_fillMethod_752909931.invoke(InvocationContextInterceptor_z_fillMethod_752909931.java)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.setup(InvocationContextInterceptor.java:88)
               at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_setup_752909931.invoke(InvocationContextInterceptor_z_setup_752909931.java)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:56)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
               at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:194)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:157)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:65)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.service.ServiceContainer.dynamicInvoke(ServiceContainer.java:456)
               at org.jboss.ejb3.remoting.IsLocalInterceptor.invokeLocal(IsLocalInterceptor.java:101)
               at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:74)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.proxy.handler.service.ServiceRemoteProxyInvocationHandler.invoke(ServiceRemoteProxyInvocationHandler.java:100)
               at $Proxy410.registerCounter(Unknown Source)
               at com.myorg.rac.server.bwallocator.BWAllocatorAdminMBean.registerCounters(BWAllocatorAdminMBean.java:81)
               at com.myorg.rac.server.bwallocator.BWAllocatorAdminMBean.start(BWAllocatorAdminMBean.java:51)
               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
               at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:597)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111)
               at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:56)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at com.myorg.common.server.transaction.Ejb3TxPolicy.invokeInOurTx(Ejb3TxPolicy.java:101)
               at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:190)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:65)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.service.ServiceContainer.localInvoke(ServiceContainer.java:409)
               at org.jboss.ejb3.service.ServiceContainer.localInvoke(ServiceContainer.java:374)
               at org.jboss.ejb3.service.ServiceMBeanDelegate.invoke(ServiceMBeanDelegate.java:215)
               ... 85 more
              Caused by: javax.persistence.PersistenceException: org.hibernate.PropertyValueException: not-null property references a null or transient value: com.myorg.common.par.Statistic.hostIpAddress
               at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614)
               at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:226)
               at org.jboss.ejb3.entity.TransactionScopedEntityManager.persist(TransactionScopedEntityManager.java:185)
               at com.myorg.common.server.configmanager.ConfigurationManagerBean.addManagedObject(ConfigurationManagerBean.java:491)
               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
               at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:597)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111)
               at org.jboss.ejb3.EJBContainerInvocationWrapper.invokeNext(EJBContainerInvocationWrapper.java:69)
               at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.invoke(InterceptorSequencer.java:73)
               at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.aroundInvoke(InterceptorSequencer.java:59)
               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
               at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:597)
               at org.jboss.aop.advice.PerJoinpointAdvice.invoke(PerJoinpointAdvice.java:174)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.fillMethod(InvocationContextInterceptor.java:72)
               at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_fillMethod_752909931.invoke(InvocationContextInterceptor_z_fillMethod_752909931.java)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.setup(InvocationContextInterceptor.java:88)
               at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_setup_752909931.invoke(InvocationContextInterceptor_z_setup_752909931.java)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:56)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:68)
               at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
               at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
               ... 200 more
              Caused by: org.hibernate.PropertyValueException: not-null property references a null or transient value: com.myorg.common.par.Statistic.hostIpAddress
               at org.hibernate.engine.Nullability.checkNullability(Nullability.java:95)
               at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:313)
               at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
               at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:144)
               at org.hibernate.ejb.event.EJB3PersistEventListener.saveWithGeneratedId(EJB3PersistEventListener.java:49)
               at org.hibernate.event.def.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:154)
               at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:110)
               at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:61)
               at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:645)
               at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:619)
               at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:623)
               at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:220)
               ... 232 more


              • 4. Re: MBean start ordering in 5.0CR2
                jaikiran pai Master

                 

                When MBeanA's start method is called, it calls a method on MBeanB via its injected reference, which delegates to the singleton. The problem is that at this point, a field in the singleton has not been initialized, as MBeanB's start method hasn't yet been called.


                As per the documentation http://docs.jboss.org/ejb3/app-server/reference/build/reference/en/html/jboss_extensions.html:

                start() - called by the server when the service is started and all the services it depends upon have been started too. At this point the service (and all the services it depends on) is fully functional.


                So what you are observing should not have happened. So i decided to give it a try with a simple application with 2 dependent services (MyService depends on AnotherService):

                @Service (objectName = "org.myapp:name=MyService")
                @Management(MyService.class)
                @Depends({"org.myapp:name=AnotherService"})
                public class MyServiceImpl implements MyService {
                
                
                 public void create() throws Exception {
                 System.out.println("Created " + this.getClass().getName() + " at " + new Timestamp(System.currentTimeMillis()));
                
                 }
                
                 public void start() throws Exception {
                 System.out.println("Started " + this.getClass().getName() + " at " + new Timestamp(System.currentTimeMillis()));
                
                
                 }
                
                }
                
                


                @Service (objectName = "org.myapp:name=AnotherService")
                @Management(AnotherService.class)
                public class AnotherServiceImpl implements AnotherService {
                
                 public void create() throws Exception {
                 System.out.println("Created " + this.getClass().getName() + " at " + new Timestamp(System.currentTimeMillis()));
                
                 }
                
                 public void start() throws Exception {
                 System.out.println("Started " + this.getClass().getName() + " at " + new Timestamp(System.currentTimeMillis()));
                
                 }
                
                }
                
                
                


                Since MyService depends on AnotherService, the start() of AnotherService will be called first and then the start() of the MyService. And that's exactly how it behaves as can be seen in the logs:

                13:42:24,590 INFO [JBossASKernel] Created KernelDeployment for: myapp_ejb3.jar
                13:42:24,605 INFO [JBossASKernel] installing bean: jboss.j2ee:ear=ServiceTest.ear,jar=myapp_ejb3.jar,name=AnotherServiceImpl,service=EJB3
                13:42:24,605 INFO [JBossASKernel] with dependencies:
                13:42:24,605 INFO [JBossASKernel] and demands:
                13:42:24,605 INFO [JBossASKernel] jboss.ejb:service=EJBTimerService
                13:42:24,605 INFO [JBossASKernel] and supplies:
                13:42:24,605 INFO [JBossASKernel] Class:org.myapp.service.AnotherService
                13:42:24,605 INFO [JBossASKernel] jndi:ServiceTest/AnotherServiceImpl/remote
                13:42:24,605 INFO [JBossASKernel] jndi:ServiceTest/AnotherServiceImpl/local
                13:42:24,605 INFO [JBossASKernel] jndi:ServiceTest/AnotherServiceImpl/local-org.myapp.service.AnotherService
                13:42:24,605 INFO [JBossASKernel] Added bean(jboss.j2ee:ear=ServiceTest.ear,jar=myapp_ejb3.jar,name=AnotherServiceImpl,service=EJB3) to KernelDeployment of: myapp_ejb3.jar
                13:42:24,605 INFO [JBossASKernel] installing bean: jboss.j2ee:ear=ServiceTest.ear,jar=myapp_ejb3.jar,name=MyServiceImpl,service=EJB3
                13:42:24,605 INFO [JBossASKernel] with dependencies:
                13:42:24,605 INFO [JBossASKernel] and demands:
                13:42:24,605 INFO [JBossASKernel] jboss.ejb:service=EJBTimerService
                13:42:24,605 INFO [JBossASKernel] org.myapp:name=AnotherService
                13:42:24,605 INFO [JBossASKernel] and supplies:
                13:42:24,605 INFO [JBossASKernel] jndi:ServiceTest/MyServiceImpl/local
                13:42:24,605 INFO [JBossASKernel] jndi:ServiceTest/MyServiceImpl/local-org.myapp.service.MyService
                13:42:24,605 INFO [JBossASKernel] Class:org.myapp.service.MyService
                13:42:24,605 INFO [JBossASKernel] jndi:ServiceTest/MyServiceImpl/remote
                13:42:24,605 INFO [JBossASKernel] Added bean(jboss.j2ee:ear=ServiceTest.ear,jar=myapp_ejb3.jar,name=MyServiceImpl,service=EJB3) to KernelDeployment of: myapp_ejb3.jar
                13:42:25,027 INFO [EJBContainer] STARTED EJB: org.myapp.service.AnotherServiceImpl ejbName: AnotherServiceImpl
                13:42:25,136 INFO [JBossASKernel] installing bean: org.myapp:name=AnotherService
                13:42:25,136 INFO [JBossASKernel] with dependencies:
                13:42:25,136 INFO [JBossASKernel] and demands:
                13:42:25,136 INFO [JBossASKernel] jboss.ejb:service=EJBTimerService
                13:42:25,136 INFO [JBossASKernel] and supplies:
                13:42:25,136 INFO [JBossASKernel] Class:org.myapp.service.AnotherService
                13:42:25,136 INFO [JBossASKernel] jndi:ServiceTest/AnotherServiceImpl/remote
                13:42:25,136 INFO [JBossASKernel] jndi:ServiceTest/AnotherServiceImpl/local
                13:42:25,136 INFO [JBossASKernel] jndi:ServiceTest/AnotherServiceImpl/local-org.myapp.service.AnotherService
                13:42:25,136 INFO [JBossASKernel] Installing bean(org.myapp:name=AnotherService) into kernel
                13:42:25,230 INFO [STDOUT] Created org.myapp.service.AnotherServiceImpl at 2008-10-16 13:42:25.23
                 13:42:25,855 INFO [STDOUT] Started org.myapp.service.AnotherServiceImpl at 2008-10-16 13:42:25.855
                 13:42:26,527 INFO [EJBContainer] STARTED EJB: org.myapp.service.MyServiceImpl ejbName: MyServiceImpl
                13:42:26,558 INFO [JBossASKernel] installing bean: org.myapp:name=MyService
                13:42:26,558 INFO [JBossASKernel] with dependencies:
                13:42:26,558 INFO [JBossASKernel] and demands:
                13:42:26,558 INFO [JBossASKernel] jboss.ejb:service=EJBTimerService
                13:42:26,558 INFO [JBossASKernel] org.myapp:name=AnotherService
                13:42:26,558 INFO [JBossASKernel] and supplies:
                13:42:26,558 INFO [JBossASKernel] jndi:ServiceTest/MyServiceImpl/local
                13:42:26,558 INFO [JBossASKernel] jndi:ServiceTest/MyServiceImpl/local-org.myapp.service.MyService
                13:42:26,558 INFO [JBossASKernel] Class:org.myapp.service.MyService
                13:42:26,558 INFO [JBossASKernel] jndi:ServiceTest/MyServiceImpl/remote
                13:42:26,558 INFO [JBossASKernel] Installing bean(org.myapp:name=MyService) into kernel
                13:42:26,574 INFO [STDOUT] Created org.myapp.service.MyServiceImpl at 2008-10-16 13:42:26.574
                 13:42:26,590 INFO [STDOUT] Started org.myapp.service.MyServiceImpl at 2008-10-16 13:42:26.59
                


                So are you sure that the problem is not something else in your example?

                • 5. Re: MBean start ordering in 5.0CR2
                  Hubert Holierhoek Newbie

                  I added 'Starting' logs to my MBeans and got:

                  2008/10/16 09:35:43.366 INFO (main) [com.myorg.rac.server.bwallocator.BWAllocatorAdminMBean.start:50] Starting BWAllocatorAdminMBean
                  
                  2008/10/16 09:35:45.661 ERROR (main) [org.jboss.logging.util.LoggerStream.write:156] java.lang.RuntimeException: Problem registering @Management interface for @Service class com.myorg.rac.server.bwallocator.BWAllocatorAdminMBean
                  
                  2008/10/16 09:35:46.132 INFO (main) [com.myorg.common.server.statistics.StatisticsMBean.start:54] Starting StatisticsMBean


                  Another thing to note here is that these MBeans are in two different jars in an exploded ear, which has no application.xml.

                  I should probably also mention that I'm getting lots of warnings like:
                  2008/10/16 09:35:44.659 WARN (main) [org.jboss.ejb3.interceptors.registry.InterceptorRegistry.getApplicableInterceptorClasses:82] applicable interceptors is non-existent for public void com.myorg.common.server.statistics.StatisticsMBean.registerCounter(java.lang.String,java.lang.String) throws com.myorg.common.exception.OperationFailedException


                  Curiously, I seem to be getting one of those for all mgmt interface methods except 'start'. Things seem to be functioning well enough that I had been assuming those were benign.

                  I have other MBeans that do end up starting in the right order. In fact, most of them do. That doesn't necessarily mean that such timing is enforced, of course. If it's left to a race, there will be winners and losers.

                  Can you try separating them into separate jars, play with the names of the jars, putting a sleep(60) in the create method of AnotherServiceImpl (although, they're all started from thread 'main' so I guess it's unlikely that will show anything)?

                  Also, what log4j tweak do I need to do to get the 'installing bean:' logs?

                  • 6. Re: MBean start ordering in 5.0CR2
                    Hubert Holierhoek Newbie

                    I've attached a debugger to the server and placed a break-point in BWAllocatorAdminMBean.start. Here's the stack trace in the main thread:

                    main@2, priority=5, in group 'jboss', status: 'RUNNING'
                     at com.alcatel.tpapps.rac.server.bwallocator.BWAllocatorAdminMBean.start(BWAllocatorAdminMBean.java:50)
                     at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-1)
                     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                     at java.lang.reflect.Method.invoke(Method.java:597)
                     at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122)
                     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111)
                     at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:56)
                     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
                     at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
                     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
                     at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
                     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
                     at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
                     at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:190)
                     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
                     at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
                     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
                     at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
                     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
                     at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41)
                     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
                     at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
                     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
                     at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:65)
                     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
                     at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
                     at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
                     at org.jboss.ejb3.service.ServiceContainer.localInvoke(ServiceContainer.java:409)
                     at org.jboss.ejb3.service.ServiceContainer.localInvoke(ServiceContainer.java:374)
                     at org.jboss.ejb3.service.ServiceMBeanDelegate.invoke(ServiceMBeanDelegate.java:215)
                     at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
                     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
                     at org.jboss.ejb3.deployers.JBossASKernel.invokeOptionalMethod(JBossASKernel.java:287)
                     at org.jboss.ejb3.deployers.JBossASKernel.installMBean(JBossASKernel.java:177)
                     at org.jboss.ejb3.service.ServiceContainer.registerManagementInterface(ServiceContainer.java:615)
                     at org.jboss.ejb3.service.ServiceContainer.lockedStart(ServiceContainer.java:241)
                     at org.jboss.ejb3.EJBContainer.start(EJBContainer.java:866)
                     at sun.reflect.GeneratedMethodAccessor190.invoke(Unknown Source:-1)
                     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                     at java.lang.reflect.Method.invoke(Method.java:597)
                     at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)
                     at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150)
                     at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)
                     at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:241)
                     at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47)
                     at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:109)
                     at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:70)
                     at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:221)
                     at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54)
                     at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42)
                     at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
                     at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
                     at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
                     at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
                     at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1,598)
                     at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
                     at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1,062)
                     at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
                     at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:774)
                     at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:540)
                     at org.jboss.kernel.plugins.dependency.AbstractKernelController.install(AbstractKernelController.java:106)
                     at org.jboss.kernel.plugins.dependency.AbstractKernelController.install(AbstractKernelController.java:100)
                     at org.jboss.ejb3.deployers.JBossASKernel.install(JBossASKernel.java:154)
                     at org.jboss.ejb3.deployers.JBossASKernel.installMBean(JBossASKernel.java:172)
                     at org.jboss.ejb3.service.ServiceContainer.registerManagementInterface(ServiceContainer.java:615)
                     at org.jboss.ejb3.service.ServiceContainer.lockedStart(ServiceContainer.java:241)
                     at org.jboss.ejb3.EJBContainer.start(EJBContainer.java:866)
                     at sun.reflect.GeneratedMethodAccessor190.invoke(Unknown Source:-1)
                     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                     at java.lang.reflect.Method.invoke(Method.java:597)
                     at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)
                     at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150)
                     at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)
                     at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:241)
                     at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47)
                     at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:109)
                     at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:70)
                     at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:221)
                     at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54)
                     at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42)
                     at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
                     at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
                     at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
                     at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
                     at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1,598)
                     at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
                     at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1,062)
                     at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
                     at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:774)
                     at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:540)
                     at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:124)
                     at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:51)
                     at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
                     at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
                     at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:169)
                     at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1,285)
                     at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1,003)
                     at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1,024)
                     at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1,056)
                     at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:944)
                     at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
                     at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1,598)
                     at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
                     at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1,062)
                     at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
                     at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
                     at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
                     at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:627)
                     at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:541)
                     at org.jboss.system.server.profileservice.ProfileServiceBootstrap.loadProfile(ProfileServiceBootstrap.java:265)
                     at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:143)
                     at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:409)
                     at org.jboss.Main.boot(Main.java:209)
                     at org.jboss.Main$1.run(Main.java:544)
                     at java.lang.Thread.run(Thread.java:619)


                    Interestingly, you'll see that JBossASKernel.installMBean appears twice. The lower one (i.e. the one closer to Thread.run) is for StatisticsMBean. The higher one is for BWAllocatorAdmimMBean. The StatisticsMBean installation hasn't progressed to the call to 'invokeOptionalMethod(create/start)', yet as part of the call to 'install' above, it eventually ends up installing the BWAllocatorAdminMBean.

                    The dependencies for StatisticsMBean are as expected.

                    Unfortunately, I don't have the source for much of the stack in between so I'm unable to decipher why it might have gone where it did. What other parts of the stack might be of interest here? And can you point me to the sources for those? I've got the source for AS 5.0CR2, and EJB3 1.0.0-Beta4.

                    • 7. Re: MBean start ordering in 5.0CR2
                      jaikiran pai Master

                       

                      "huberth" wrote:


                      I've got the source for AS 5.0CR2, and EJB3 1.0.0-Beta4.


                      If you have 5.0CR2 source then you will find most of the required java files in there. The source for the other projects can be found under 5.0CR2 source/thirdparty/jboss/xxx folder.

                      "huberth" wrote:

                      I should probably add that to get this far, I had to download, build and apply the 1.0.0-Beta4 release of the EJB3 module.


                      I should admit that, i am not on 1.0.0-Beta4 of EJB3. I know there's a bug in JBoss-5 CR2 https://jira.jboss.org/jira/browse/EJBTHREE-1430, because of which you probably moved to this version of EJB3. The fix for that was a single line change in one of the EJB3 files (ServiceContainer.java). So i just patched in this single file instead of moving to 1.0.0-Beta4. I am not sure if the issue that you are seeing is specific to 1.0.0-Beta4.

                      "huberth" wrote:

                      Can you try separating them into separate jars, play with the names of the jars, putting a sleep(60) in the create method of AnotherServiceImpl (although, they're all started from thread 'main' so I guess it's unlikely that will show anything)?


                      I can give it a try during some free time tomorrow. But if possible, upload your application to some place where i could access it.

                      "huberth" wrote:

                      Also, what log4j tweak do I need to do to get the 'installing bean:' logs?

                      Nothing. The log4j settings are the default that come with JBoss.

                      • 8. Re: MBean start ordering in 5.0CR2
                        Hubert Holierhoek Newbie

                        The thirdparty directory seems to cover a lot of (only?) non-jboss stuff. For example, AbstractController.java is not under the 5.0 source directory anywhere, and it seems to be an important player here. I found a copy of it under viewvc, but it's obviously a different version as the line numbers don't line up. But I am at least able to look at variable values for that class in the debugger.

                        And, yes, EJB3-1430 is the reason I downloaded beta4. I'm not sure how anyone's getting anywhere with CR2 as it stands. But, agreed, it's hard to tell if it's specific to the Beta4 load, as my current issue would have been preempted by the other one.

                        Uploading the application might be a bit difficult as I don't think it'd be simply a matter of giving you the ear.

                        I figured out the log4j thing - we had altered the default one so those lines weren't coming out. I just had to set the logger 'org.jboss.ejb3.deployers.JBossASKernel' to 'INFO' level.

                        • 9. Re: MBean start ordering in 5.0CR2
                          Hubert Holierhoek Newbie

                          Look closely at the chain of calls between the lower installMBean and the resolveContexts calls. Further down inside the install call from installMBean the code eventually transitions the state of StatisticsMBean to created, then started, then installed, constantly calling resolveContexts(boolean) along the way. That call to resolveContexts eventually figures out that StatisticsMBean is installed, which BWAllocatorAdminMBean requires, so it installs that MBean as well (although, stepping through I didn't quite figure out exactly how that happened, to be honest).

                          The problem is that the actual create/start methods get invoked on StatisticsMBean only after the install call returns, much later.

                          I would have thought those calls would have been more closely tied to the actual state transitions that they represent... say, as part of StartStopLifecycleAction.installAction() for example.

                          There seems to be an odd inconsistency in the approach to handling dependencies here, too. We have both the recursion thing going on, as well as the iteration going on in resolveContexts. That is, of course, from a fairly superficial understanding of the code and the problem space, so maybe there's nothing to that.

                          • 10. Re: MBean start ordering in 5.0CR2
                            Hubert Holierhoek Newbie

                            I've got it. Try this:

                            public interface LifeCycle
                            {
                             public void create() throws Exception;
                             public void start() throws Exception;
                            
                             public void destroy();
                             public void stop();
                            }


                            @Management(LifeCycle.class)
                            @Service(objectName = "myorg:service=MBeanB")
                            public class MBeanB implements LifeCycle
                            {
                             private static final Logger logger = Logger.getLogger(MBeanB.class);
                            
                             public void create() throws Exception
                             {
                             logger.log(Level.INFO, "Creating");
                             }
                            
                             public void start() throws Exception
                             {
                             logger.log(Level.INFO, "Starting");
                             }
                            
                             public void destroy()
                             {
                             logger.log(Level.INFO, "Destroying");
                             }
                            
                             public void stop()
                             {
                             logger.log(Level.INFO, "Stopping");
                             }
                            }


                            @Management(LifeCycle.class)
                            @Depends("myorg:service=MBeanB")
                            @Service(objectName = "myorg:service=MBeanA")
                            public class MBeanA implements LifeCycle
                            {
                             private static final Logger logger = Logger.getLogger(MBeanA.class);
                            
                             public void create() throws Exception
                             {
                             logger.log(Level.INFO, "Creating");
                             }
                            
                             public void start() throws Exception
                             {
                             logger.log(Level.INFO, "Starting");
                             }
                            
                             public void destroy()
                             {
                             logger.log(Level.INFO, "Destroying");
                             }
                            
                             public void stop()
                             {
                             logger.log(Level.INFO, "Stopping");
                             }
                            }


                            Then put MBeanA into a.jar and MBeanB into b.jar (the jar names matter - the relative alphabetical sort order to be precise). Create an exploded ear in the deploy directory with no application.xml (not sure if this part matters, but it's what I've been doing) and place the two jars in it.

                            I get the following logs, indicating they started out of order:

                            2008/10/17 08:54:18.813 INFO (main) [com.myorg.common.server.MBeanA.create:36] Creating
                            2008/10/17 08:54:18.835 INFO (main) [com.myorg.common.server.MBeanA.start:41] Starting
                            2008/10/17 08:54:18.842 INFO (main) [com.myorg.common.server.MBeanB.create:35] Creating
                            2008/10/17 08:54:18.896 INFO (main) [com.myorg.common.server.MBeanB.start:40] Starting


                            The ear's contents are sorted first by suffix, then by name to come up with the attempted installation order. Since MBeanA comes first, but can't be installed yet due to an unresolved dependency, it is skipped. When MBeanB is installed, we recurse looking for newly resolved dependencies, at which time we find MBeanB and attempt to install it. Unfortunately, as I mentioned previously, the create/start methods get invoked only after this recursion.

                            So the recursion is probably correct, but the great distance (code-wise) between the state transitions and the invocation of the corresponding life cycle methods is probably the real problem.

                            • 11. Re: MBean start ordering in 5.0CR2
                              jaikiran pai Master

                              Going by what you have shown here, this looks like a bug to me. I think its more a Microcontainer bug (as far as i know, that's what resolves the dependencies) than a EJB3 bug.

                              • 12. Re: MBean start ordering in 5.0CR2
                                Hubert Holierhoek Newbie

                                Agreed. What do we do with it now? Should I raise a JIRA? Or do you?

                                • 13. Re: MBean start ordering in 5.0CR2
                                  Hubert Holierhoek Newbie

                                  On the other hand, come to think of it, the requirement to call the life cycle methods at the right time is strictly EJB3.

                                  • 14. Re: MBean start ordering in 5.0CR2
                                    jaikiran pai Master

                                     

                                    "huberth" wrote:
                                    On the other hand, come to think of it, the requirement to call the life cycle methods at the right time is strictly EJB3.


                                    I guess you are right. I think you could file a JIRA under EJBTHREE project and point to this thread.

                                    1 2 Previous Next