1 Reply Latest reply on Nov 3, 2009 7:44 AM by brettcave

    MBean service either has no business interface or does not i

    brettcave

      I found the following thread, but no response as yet:
      http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4180208

      We are busy with a jbas4.2.2 -> 5.1.0.GA migration, and have an mbean:

      MyMBeanService.java:

      @Service(objectName = "mycompany:service=MyMBeanService")
      @Management(MyMBeanServiceMBean.class)
      public class MyMBeanService extends ServiceMBeanSupport implements MyMBeanServiceMBean {}
      


      MyMBeanServiceMBean.java:
      public interface MyMBeanServiceMBean {}
      


      It is being mapped as an mbean, via jboss-service.xml:
      <mbean code="com.mycompany.mypackage.management.MyMBeanService"
       name="mycompany:service=MyMBeanService">
      </mbean>
      


      When I deploy this to JBAS 5, I get the following error:
      ERROR [org.jboss.management.j2ee.MBean] (main) Could not destroy JSR-77 MBean: mycompany:service=MyMBeanService
      javax.management.MBeanRegistrationException: preDeregister
       at org.jboss.mx.server.registry.BasicMBeanRegistry.unregisterMBean
      ....
      Caused by: javax.management.RunimeOperationsException
       at org.jboss.mx.server.MBeanServerImpl.removeNotficationLister
       ...
      Caused by: java.lang.IllegalArgumentException: The MBean mycompany:service=MyMBeanService exists but does not implement the NotifcationBroadcaster interface.
      


      So I added the implementation:
      public class MyMBeanService extends ServiceMBeanSupport implements MyMBeanServiceMBean, NotificationBroadcaster {}
      


      which results in the following error
      ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (HDScanner) Error installing to Real: name=vfszip:/usr/share/jbo
      ss/jboss-5.1.0.GA/server/all/farm/7-Project-ear.ear/ state=PreReal mode=Manual requiredState=Real
      org.jboss.deployers.spi.DeploymentException: Error deploying Project.sar: Error creating ejb container MyMBeanService: Bean Class com.mycompany.project
      .management.MyMBeanService has no local, webservice, or remote interfaces defined and does not implement at least one business interface: MyMBeanService
       at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:196)
       at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:99)
      


      I found a reference to the EJB 3 spec on JBoss Jira:
      "if a bean class implements a single interface, that interface will be assumed to be the business interface of the bean."

      And if a bean class implements more than 1 interface, then the business interface is specified through @Local or @Remote.

      So I added the annotation to MyMBeanServiceMBean:
      @Local
      public interface MyMBeanServiceMBean {}
      


      After deploying this, I get the same error about the mbean existing, but not implementing NotificationBroadcaster interface (even though the bean does implement NotificationBroadcaster).

      I have also tried extending NotificationBroadcaster in the ServiceMBean:
      public interface MyMBeanServiceMBean extends NotificationBroadcaster {}
      


      which also still results in the not implementing notificationbroadcaster error.

      Not sure how to resolve this for this implementation (or perhaps a bug?)