4 Replies Latest reply on Jun 5, 2006 2:37 PM by barrys52

    Problem obtaining MBeanServerConnection object

    barrys52

      Please help!

      I am using JBoss 4.0.4.GA and JBoss Messaging 1.0.1.CR2. I am trying to create Messaging queues dynamically. To do this requires that I get a handle to the "jmx/invoker/RMIAdaptor" MBeanServerConnection object. The following code, taken from a JBoss provided example, is causing an exception:

       InitialContext ic = new InitialContext();
       MBeanServerConnection p =
       (MBeanServerConnection)ic.lookup("jmx/invoker/RMIAdaptor");


      The exception generated is:

      javax.naming.CommunicationException [Root exception is
      java.lang.ClassNotFoundException: org.jboss.jmx.adaptor.rmi.RMIAdaptor
      (no security manager: RMI class loader disabled)]
      at
      org.jnp.interfaces.NamingContext.lookup(NamingContext.java:729)
      at
      org.jnp.interfaces.NamingContext.lookup(NamingContext.java:588)
      at javax.naming.InitialContext.lookup(InitialContext.java:351)
      ...

      ============================================
      I would appreciate it if someone could explain how to correct this!

      Thanks,
      Barry

        • 1. Re: Problem obtaining MBeanServerConnection object
          wengong

          This code worked for me:

           Properties env = new Properties();
           env.setProperty(Context.INITIAL_CONTEXT_FACTORY,
           "org.jboss.naming.HttpNamingContextFactory");
          
           env.setProperty(Context.PROVIDER_URL,
           "http://[hostname]:8080/invoker/JNDIFactory");
          
           Context ctx = new InitialContext(env);
          
           MBeanServerConnection server = (MBeanServerConnection) ctx.lookup("jmx/invoker/RMIAdaptor");
          
          


          • 2. Re: Problem obtaining MBeanServerConnection object
            barrys52

            Unfortunately, that doesn't work for me. This property:

            env.setProperty(Context.INITIAL_CONTEXT_FACTORY,
             "org.jboss.naming.HttpNamingContextFactory");


            causes the following exception:
            "org.jboss.naming.HttpNamingContextFactory");javax.naming.NoInitialContextException: Cannot instantiate class: org.jboss.naming.HttpNamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jboss.naming.HttpNamingContextFactory]

            In my original post, I neglected to mention the jndi property settings I'm using. They are defined in a jndi.properties file. Setting the properties in the code instead, I have:

             Properties properties = new Properties();
             properties.put(
             Context.INITIAL_CONTEXT_FACTORY,
             "org.jnp.interfaces.NamingContextFactory");
             properties.put(
             Context.PROVIDER_URL,
             "jnp://localhost:1099");
             properties.put(
             Context.OBJECT_FACTORIES,
             "org.jboss.naming:org.jnp.interfaces");
             InitialContext ic = new InitialContext(properties);
             MBeanServerConnection p =
             (MBeanServerConnection)ic.lookup("jmx/invoker/RMIAdaptor");


            That produces the same exception:

            javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundException: org.jboss.jmx.adaptor.rmi.RMIAdaptor (no security manager: RMI class loader disabled)]
            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:729)


            Any ideas?

            Thanks,
            Barry

            • 3. Re: Problem obtaining MBeanServerConnection object
              peterj

              I wonder if your problem is more related to the part of the error message that states "no security manager: RMI class loader disabled". I ran into something like this a couple of weeks ago and had to read up about security managers and the java.policy file and other such fun topics. Googling the portion of the error text I quoted should lead you to several web pages that attempt to explain the problem and how to fix it. (If I ever find the code I had this problem with I will post what I did to get around the problem. I vaguely recall declaring a security manager in my Java code and providing an alternate java.policy file.)

              • 4. Re: Problem obtaining MBeanServerConnection object
                barrys52

                Problem resolved: It turns out that the problem had nothing to do with lack of a security manager. The problem was that I did not have all the jar files required in my classpath. The jar files are contained in the [jboss_home]/server/messaging/lib directory.