4 Replies Latest reply on Jul 27, 2002 5:37 PM by davidjencks

    Calling a bean from an MBean

    mteunissen

      I'm using JBoss 3.0.0 alpha

      When I try to call a Session bean from an MBean I get a ClassCastException on the narrow(). The lookup seems to deliver the right Object. I have provided the beans interfaces in the sar file for this MBean.

      Is there anything special to do when calling a bean from an MBean compared to calling it from another bean or client?

        • 1. Re: Calling a bean from an MBean
          marc.fleury

          I am surprised it is not a "classnotfound", there is no way you can really do that cleanly today.

          Unclean would mean put your beans in the lib/ext directory (make sure to add that to the jboss-service.xml stupid entry of listed jars) and both the bean and the ejb will see the same class.

          If you need to change the class you lose the hotdeploy though (you put your class definition in lib/ext) so you need to restart JBoss everytime, but it would be a simple solution in the interim.

          FYI David and I are going to be coding the solution to this problem very soon,then you will have real hot-deploy and what not.

          marcf

          • 2. Re: Calling a bean from an MBean
            rakhbari

            Hi,

            I'm running into a similar situation with JBoss 2.4.7 (Tomcat 4.0.4 bundle). I have an MBEAN which I've configured at the end of jboss.jcml. It's service class, EmailService lives in our own application's .jar file. But when JBoss is starting and hits the MBEAN tag it doesn't know about our app's .jar file yet so it's throwing this in the JVM window:

            [ERROR,ConfigurationService] Could not create MBean :service=EmailQueue(com.apli
            a.platform.mail.EmailService)
            java.lang.ClassNotFoundException: com.aplia.platform.mail.EmailService
            at javax.management.loading.MLet.findClass(MLet.java:800)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:262)
            at com.sun.management.jmx.MBeanServerImpl.findClass(MBeanServerImpl.java
            :2466)
            at com.sun.management.jmx.MBeanServerImpl.createMBean(MBeanServerImpl.ja
            va:751)
            at org.jboss.configuration.ConfigurationService.create(ConfigurationServ
            ice.java:683)
            at org.jboss.configuration.ConfigurationService.loadConfiguration(Config
            urationService.java:461)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
            java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
            sorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:324)
            at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:16
            28)
            at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
            23)
            at org.jboss.Main.(Main.java:201)
            at org.jboss.Main$1.run(Main.java:110)
            at java.security.AccessController.doPrivileged(Native Method)
            at org.jboss.Main.main(Main.java:106)

            I tried to put our aplia.jar (where the com.aplia.platform.email.EmailService lives) in the JBOSS_CLASSPATH in the run.bat file, but when I do that, all sorts of other ClassNotFoundExceptions come up in the JVM window when JBoss tries to deploy all our beans. It's really wierd.

            Is there any way to deploy this service MBEAN as a part of our aplia.ear application and not in the jboss.jcml? That way all our classes would be visible to it.

            Thanks in advance,

            Ramin

            • 3. Re: Calling a bean from an MBean
              davidjencks

              This is easy in jboss 3 using a jboss-service.xml, or .sar file but very difficult in 2.4 versions.

              • 4. Re: Calling a bean from an MBean
                davidjencks

                This is easy in jboss 3 using a jboss-service.xml, or .sar file but very difficult in 2.4 versions.