8 Replies Latest reply on Jun 30, 2002 8:16 PM by sgturner

    ear and mbeans

    vishalsant

      hi,
      i am trying to deploy an ear file which has a war file
      whose servlet's init method is the one creating the Mbeanserver

      MBeanServer server = MBeanServerFactory.createMBeanServer( "ResourceAdmin" );

      The need of this approach is a desire to bring up mbeans
      from within an ear file rather than making jboss.jcml entries and thus make the proces of deploying mbeans dynamic without the need of a server bounce.
      One would assume that ear classloader would load the bean
      classes required which does not seem to be the case .
      i could for example using reflection instantiate the mbean
      class without exception .
      As soon as i hit
      server.createMBean( resourceAdminClassName, resourceAdmin );
      i get this exception
      ----------------------------------------------------------
      javax.management.ReflectionException: The MBean class could not be loaded by the
      default loader repository
      at com.sun.management.jmx.MBeanServerImpl.createMBean(MBeanServerImpl.ja
      va:367)
      at com.gallup.g.servlets.StartupServlet.init(StartupServlet.java:102)
      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.
      java:916)
      at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:80
      8)
      at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContex
      t.java:3266)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:3
      395)
      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:78
      5)
      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:454)

      at org.jboss.web.catalina.EmbeddedCatalinaServiceSX.createWebContext(Emb
      eddedCatalinaServiceSX.java:298)
      at org.jboss.web.catalina.EmbeddedCatalinaServiceSX.performDeploy(Embedd
      edCatalinaServiceSX.java:223)
      at org.jboss.web.AbstractWebContainer.deploy(AbstractWebContainer.java:2
      11)
      at java.lang.reflect.Method.invoke(Native Method)
      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.deployment.J2eeDeployer.startModules(J2eeDeployer.java:505)

      at org.jboss.deployment.J2eeDeployer.startApplication(J2eeDeployer.java:
      459)
      at org.jboss.deployment.J2eeDeployer.deploy(J2eeDeployer.java:190)
      at java.lang.reflect.Method.invoke(Native Method)
      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.deployment.AutoDeployer.deploy(AutoDeployer.java:395)
      at org.jboss.deployment.AutoDeployer.run(AutoDeployer.java:233)
      at org.jboss.deployment.AutoDeployer.startService(AutoDeployer.java:371)

      at org.jboss.util.ServiceMBeanSupport.start(ServiceMBeanSupport.java:103
      )
      at java.lang.reflect.Method.invoke(Native Method)
      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.configuration.ConfigurationService$ServiceProxy.invoke(Conf
      igurationService.java:967)
      at $Proxy0.start(Unknown Source)
      at org.jboss.util.ServiceControl.start(ServiceControl.java:79)
      at java.lang.reflect.Method.invoke(Native Method)
      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:208)
      at org.jboss.Main$1.run(Main.java:110)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.jboss.Main.main(Main.java:106)

      _________________________________________________________

      Is their a classloader defined within Jboss that would
      only pick up jar files in lib/ext as far as loading
      MBeans is concerned .
      Though the server is retrieved from the MbeanServerfactory.
      NOTE:- if i add the jar file containing the Mbean classes
      in lib/ext it works fine .

      If any body could shed some light on this i'll be delighted

      vishal








        • 1. Re: ear and mbeans

          Have your tried JBoss3.0 where all your prayers will
          be answered. i.e. Hot deploying mbeans.

          It is possible to do what your are doing with 2.4
          but it will take a lot more work.

          Regards,
          Adrian

          • 2. Re: ear and mbeans
            davidjencks

            In particular, if you use jboss Branch_3_0 from cvs, you can include a .sar or *-service.xml file in an ear. You need to also include a jboss-app.xml file next to your application.xml with something like this:

            <jboss-app>

            msar.sar

            </jboss-app>

            • 3. Re: ear and mbeans
              vishalsant

              i will migrate to Jboss3.0..

              but is it a classloader problem i am facing here
              i am sorry i did not specify the version of jboss
              it is 2.4.6 with catalina..
              thank u

              • 4. Re: ear and mbeans
                davidjencks

                I don't know what the classloader model followed by the jmxri is, but I wouldn't be surprised if they managed to make the system classloader their parent, thus keeping anything loaded by the classloader in jboss's mbeanserver out of the classloader of your mbeanserver.

                • 5. i have the solution for jboss 2.4.6
                  vishalsant

                  my reflection from within the servlet in a war in an ear was working..
                  so instaed of using the core jmxri reflection ..
                  i instantiated the Mbeans from within the servlet and instead of calling the
                  server.createMBean(mbeanclasname,objectName)
                  used
                  server.registerMBean(mbeanclass,objectName)
                  and everything worked fine....




                  • 6. Re: ear and mbeans
                    srivatsanp

                    Hi,
                    I am using jboss-3.0.0 with tomcat
                    I placed a .sar file inside an .ear file.
                    I added a file jboss-app.xml inside the META-INF directory of the .ear file.
                    The service didn't get started.

                    If I deploy the .sar separately, the service gets started.
                    Do I need to do any other configuration?

                    • 7. Re: ear and mbeans
                      srivatsanp

                      Hi,
                      I am using JBoss-3.0.0 with tomcat.
                      I created a .ear file which has a .sar in it.
                      The jboss-app.xml is present in the META-INF directory present in the ear file along with application.xml.
                      When I deploy the ear, the service is not getting started.

                      If I deploy the .sar as a standalone one, the service is getting started.
                      Do I need to do any other configuration?

                      • 8. Re: ear and mbeans
                        sgturner

                        I just tested this with JBoss 3.0.1RC1 that was released today and I believe I found a bug which I entered into sourceforge as bug #575767. It has to do with the fact that if the ear file contains a dependency jar file referred to in a Class-Path attribute of the manifest file, the sar classes do not have access to the classes in the dependency jar and it seems to me they should.