4 Replies Latest reply on Dec 12, 2008 11:22 AM by Alejandro Ayuso

    Two MBeans on the same JAR

    Alejandro Ayuso Newbie

      Hi!

      This works on Jboss4.0.5 but now I'm moving to Jboss-5.0.0.GA and I'm not able to make it work.

      I have an abstract class with some common methods for two MBeans. Something like:

      server (abstract)
       +-MBean1
       | |-MBean1Management (I)
       | |-MBean1Local (I)
       |
       +-MBean2
       | |-MBean2Management (I)
       | |-MBean2Local (I)
      


      With Jboss-4.0.5.GA my jboss-service.xml looks like this:
      <server>
       <mbean code="org.test.Server" name="org.test:service=Server" >
       </mbean>
      </server>
      

      And both MBeans are deployed, but on Jboss5 neither that or the following works:
      <server>
       <mbean code="org.test.MBean1" name="org.test:service=MBean1" >
       </mbean>
       <mbean code="org.test.MBean2" name="org.test:service=MBean2" >
       </mbean>
      </server>
      


      And I get this errors


      jboss.j2ee:jar=server.jar,name=MBean1,service=EJB3 -> java.lang.NullPointerException
      jboss.j2ee:jar=server.jar,name=MBean2,service=EJB3 -> java.lang.NullPointerException


      Thanks for any help.

        • 1. Re: Two MBeans on the same JAR
          Alejandro Ayuso Newbie

          Well, I took each MBean to different JAR's, each implementing all the methods from the Server Abstract Class, and both work, but now I have duplicated code :(

          • 2. Re: Two MBeans on the same JAR
            Alejandro Ayuso Newbie

            I took out the Server class and implemented all the common methods on the MBeans, but still got the same error.
            I would really like not to maintain two separated JARs.

            • 3. Re: Two MBeans on the same JAR
              Alejandro Ayuso Newbie

              This is the stack trace:

              13:10:50,199 ERROR [AbstractKernelController] Error installing to Start: name=jboss.j2ee:jar=server.jar,name=MBean1,service=EJB3 state=Create
              java.lang.RuntimeException: Problem registering @Management interface for @Service class org.test.MBean1
               at org.jboss.ejb3.service.ServiceContainer.registerManagementInterface(ServiceContainer.java:727)
               at org.jboss.ejb3.service.ServiceContainer.lockedStart(ServiceContainer.java:299)
               at org.jboss.ejb3.EJBContainer.start(EJBContainer.java:879)
               at sun.reflect.GeneratedMethodAccessor322.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:121)
               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:171)
               at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
               at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
               at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)
               at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
               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:781)
               at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:545)
               at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDScanner.java:290)
               at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScanner.java:221)
               at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
               at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
               at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
               at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
               at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
               at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
               at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
               at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
               at java.lang.Thread.run(Thread.java:619)
              Caused by: java.lang.NullPointerException
               at org.jboss.ejb3.service.ServiceContainer.registerManagementInterface(ServiceContainer.java:704)
               ... 54 more
              


              • 4. Re: Two MBeans on the same JAR
                Alejandro Ayuso Newbie

                FIXED

                Added it to the main EAR of my app, and everything works now :)