6 Replies Latest reply on May 5, 2006 1:04 PM by mtihepner

    How to / where to specify classpath for MBean

    lpmon

      When my EJB3 MBean loads it cannot find the other classes in my app. These classes are in my web app.

      In my ear at the top folder I have:


      META-INF ......
      webapplication.war\WEB-INF\classes (where the classes are)
      beans.jar

      I need the bean to find the classes in the WEB-INF\classes folder.

      How do I setup this class loading for the MBean?

        • 1. Re: How to / where to specify classpath for MBean
          mtihepner

          I'm having the same problem.

          On jboss 3.2.7 I was able to add my webapplication.war\WEB-INF\classes directory to the classpath in an xml descriptor. Now jboss 4.0.3 is unable to load the classes.


          Instead, is there a way I can deploy the mbeans inside WAR file?

          • 2. Re: How to / where to specify classpath for MBean
            bdecoste

            if the war and the jar are using the same classloader repository, the EJBs will be able to load classes deployed in the .war. Repositories are configured in jboss.xml and jboss-web.xml with the <loader-repositpory> tag. However, <loader-repository> is will not be implemented in EJB3 until RC7, slated for release in mid-May.

            • 3. Re: How to / where to specify classpath for MBean
              mtihepner

              There is no jar file that I'm trying to use for this exmple. I'm trying to deploy an MBean using an XML descriptor. The classes for the MBean are located in my WAR file. For example classes would exist here:

              deploy/webapplication.war/WEB-INF/classes/com/example/mbeans/TestMBean.class
              deploy/webapplication.war/WEB-INF/classes/com/example/mbeans/Test.class

              I put the descriptor for this inside the user-service.xml in the deploy directory. Like this:

              <classpath codebase="deploy/webapplication.war/WEB-INF/classes/com/example/mbeans/" archives="*.class" />
              
               <mbean code="com.example.mbeans.Test"
               name="com.example.mbeans:service=Test">
               </mbean>
              

              When jboss attempts to deploy the user-service.xml it can't find a classloader for the classes:

              09:56:21,583 ERROR [MainDeployer] Could not create deployment: file:/C:/jboss-4.0.3SP1/server/default/deploy/user-service.xml
              org.jboss.deployment.DeploymentException: No ClassLoaders found for: mil.navy.fnmoc.pel.services.mbeans.CacheMonitor; - nested throwable: (java.lang.ClassNotFoundException: No ClassLoaders found for: mil.navy.fnmoc.pel.services.mbeans.CacheMonitor)

              The way I understand it the loader repository tag will limit the scope of my classes inside the war file. It seems to me that this is already the case. Am I trying to use this incorrectly?
              thanks for the help,
              Tim

              • 4. Re: How to / where to specify classpath for MBean
                mtihepner

                I just realized this post was created in the wrong category. I've reposted here:
                http://www.jboss.com/index.html?module=bb&op=viewtopic&t=81975

                • 5. Re: How to / where to specify classpath for MBean
                  bdecoste

                  You need to use the JBoss classloader when deploying a web app that contains classes that need to be visible to an ejb3 deployment. You need to set the UseJBossWebLoader attribute to true in the tomcat jboss-service.xml

                  • 6. Re: How to / where to specify classpath for MBean
                    mtihepner

                    By default this was set to true. I still get the same error. Is there a similiar setting for webapps with classes that need to be made available to MBeans?