6 Replies Latest reply on Sep 27, 2002 5:06 AM by lekkim

    InitialLdapContext use in MBean

    lekkim

      Hi, all. I have cloned the MailService MBean to create a LDAPService MBean to provice me with an InitialLdapContext for doing LDAP operations. The MBean compile fine, but when loading I get a ClassNotFoundException for the factory class used. I have placed the ldap.jar from Sun in lib\ext and can verify that the MLET puts the jar on the classpath.

      The stacktrace (the LdapService class is the one I'm developing):
      java.lang.ClassNotFoundException: "com/sun/jndi/ldap/LdapCtxFactory"
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Unknown Source)
      at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
      at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
      at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
      at javax.naming.InitialContext.init(Unknown Source)
      at javax.naming.ldap.InitialLdapContext.(Unknown Source)
      at dk.itinspiration.jboss.mbeans.ldap.LdapService.startService(Unknown Source)
      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:1628)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      at org.jboss.configuration.ConfigurationService$ServiceProxy.invoke(ConfigurationService.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:1628)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      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)

      Anyone with ideas ?

      Thanx,

      lekkim

        • 1. Re: InitialLdapContext use in MBean

          Which version of jboss are you using?

          I don't know which classloader
          VersionHelper12.loadClass() will use.

          Try printing out:
          VersionHelper12.class.getClassLoader()
          and
          Thread.currentThread().getContextClassLoader();

          it is probably one of these.

          Regards,
          Adrian

          • 2. Re: InitialLdapContext use in MBean
            lekkim

            Thank you for replying. I'm running the JBoss 2.4.4 / Tomcat 3.2.3 bundle on SuSE Linux.

            It appears that the VersionHelper12.class has package scope so printing it wont be possible... I'm under the impression that a class inherits the classloader from the thread instance it is running in, and I don't see why this class should override this.

            What I tried also, was to do a simple Class.forName() construct with and without supplying a class loader as the third argument. The class loader I supplied was Thread.currentThread().getContextClassLoader. Both didn't produce errors...

            Any other pieces of wisdom you can throw in ?

            (I'm going to try using another factory class and see what happens).

            lekkim

            • 3. Re: InitialLdapContext use in MBean

              Class.forName(String) loads from the classloader
              of the calling class.
              Your MBean is loaded through the MLet so you won't
              see a problem.

              I've got java 1.4 which includes the ldap stuff in
              the jre so I can't really try this myself.

              Regards,
              Adrian

              • 4. Re: InitialLdapContext use in MBean
                lekkim

                Hmmm... You speak of MLET's as though I should consider them. From my point of view the MLETs are "just" loaded to bootstrap JBoss and to load all jars in lib/ext onto the JBoss classpath. What I can't understand is why the classes that comprise the MBean loads from a different classpath that the MBean it self.

                By the way. I tested my MBean with the JBoss 2.4.8/Tomcat 4.0.10 bundle - same problems... :-(

                lekkim

                • 5. Re: InitialLdapContext use in MBean

                  I mentioned the MLet because that is what loads
                  your MBean so class.forName() will use.

                  This is probably not true for Sun's class.
                  I don't know why Sun's class isn't using the
                  context classloader or looking at the classpath.

                  I do know this will work with JBoss3.0 because of
                  the UnifiedClassLoader system.

                  Regards,
                  Adrian

                  • 6. Re: InitialLdapContext use in MBean (closing thread)
                    lekkim

                    OK thank you.

                    I tried with JBoss 3.0 and it worked the first time. I'll escalate internally and ask that we wait to implement this feature untill we upgrade to JBoss 3.0.

                    lekkim