3 Replies Latest reply on Jul 27, 2002 3:24 PM by marc fleury

    Classloader problem in MBean

    Juergen Dufner Newbie

      Hi,

      this posting is not specific to JBoss, but I don't know any other newsgroup with as much as knowladge about JMX. This question regards to the JMX book by juha.

      I write my own NetworkApp as in Chapter 7 (It starts the MBeanServer and creates a MLet MBean). The MLet MBean loads my MBean. This MBean tries to get the InitialContextFactory of an IBM WebSphere.

      Hashtable table = new Hashtable();
      table.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
      table.put(Context.PROVIDER_URL,"iiop://localhost:900");
      Context ctx = new InitialContext(table);

      But I get a ClassNotFoundException (see below). If I try:

      Class.forName("com.ibm.websphere.naming.WsnInitialContextFactory");

      it seems that the MBean find the ContextFactory. In my opinion the problem arises because of the use of the Classloader.

      Any suggestions?

      Thanks a lot,
      Juergen




      java.lang.ClassNotFoundException: com.ibm.websphere.naming.WsnInitialContextFactory

      at java.net.URLClassLoader$1.run(URLClassLoader.java:200)

      at java.security.AccessController.doPrivileged(Native Method)

      at java.net.URLClassLoader.findClass(URLClassLoader.java:188)

      at java.lang.ClassLoader.loadClass(ClassLoader.java:299)

      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)

      at java.lang.ClassLoader.loadClass(ClassLoader.java:255)

      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)

      at java.lang.Class.forName0(Native Method)

      at java.lang.Class.forName(Class.java:195)

      at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:45)

      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:652)

      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246)

      at javax.naming.InitialContext.init(InitialContext.java:222)

      at javax.naming.InitialContext.(InitialContext.java:198)

      at com.entory.base.common.svcloc.JNDIAccessor.connect(JNDIAccessor.java:117)

      at com.entory.base.common.svcloc.JNDIAccessor.(JNDIAccessor.java:89)

      at com.entory.base.common.svcloc.ServiceLocator.openConnectionIfNecessary(ServiceLocator.java:573)

      at com.entory.base.common.svcloc.ServiceLocator.createEJBHome(ServiceLocator.java:367)

      at com.entory.upm.client.common.ServiceLocatorClient.getAdmin(ServiceLocatorClient.java:87)

      at com.entory.upm.client.admin.AdminCF.(AdminCF.java:67)

      at com.entory.upm.imprt.paisy.InitialLine.insert(InitialLine.java:80)

      at com.entory.upm.imprt.paisy.FileGuard.readFromFile(FileGuard.java:41)

      at com.entory.upm.imprt.paisy.PaisyImport.start(PaisyImport.java:36)

      at java.lang.reflect.Method.invoke(Native Method)

      at com.sun.jdmk.MetaDataImpl.invoke(MetaDataImpl.java:535)

      at com.sun.jdmk.DefaultMBeanAccessor.invoke(DefaultMBeanAccessor.java:528)

      at com.sun.jdmk.MBeanServerImpl.invoke(MBeanServerImpl.java:579)

      at com.entory.upm.imprt.server.ImportServer.main(ImportServer.java:76)