4 Replies Latest reply on Oct 5, 2008 10:26 AM by Aleksandar Kostadinov

    obtaining MBeanServerConnection - classloading issues

    Aleksandar Kostadinov Novice

      Not sure I'm writing to the right place but anyways,

      I want to obtain a MBeanServerConnection in an ant task to a remote jboss server.

      My code is like:

      ctx=new InitialContext(properties);
      Object connection = ctx.lookup("jmx/rmi/RMIAdaptor");
      


      When I run it putting jbossall-client.jar in classpath on jvm startup, then everything works fine. When I don't but instead tell apache-ant's "taskdef" task to include it in the new task's classpath (which IMO is the normal way to do it) then upon connection an exception is thrown:
      javax.naming.NoInitialContextException: Cannot
      instantiate class: org.jboss.naming.NamingContextFactory [Root exception is jav
      a.lang.ClassNotFoundException: org.jboss.naming.NamingContextFactory]


      Now can I do something to make it work? I'm not referencing org.jboss.naming.NamingContextFactory in my code so it is used under the hood for whatever reasons. It is not the only such class. Can the thing trying to load that class, be instructed to regard the classloader created by apache-ant?

      No secret, ant tasks are server:start/stop/config and my code is in jboss-server-manager.