-
1. Re: Problem obtaining MBeanServerConnection object
wengong Jun 5, 2006 12:49 PM (in response to barrys52)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 Jun 5, 2006 1:25 PM (in response to 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 Jun 5, 2006 2:34 PM (in response to barrys52)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 Jun 5, 2006 2:37 PM (in response to 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.