-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Alexander,
On 5/2/14, 1:40 AM, Alexander wrote: > I am hoping this is the proper forum for my problem. I have enabled > the JmxRemoteLifeCycleListener and able to connect to tomcat 7 > using jconsole etc. using the following url. Just so you know, this is likely to end in tears. What settings did you use with that listener? > service:jmx:rmi://10.92.12.88:10002/jndi/rmi://10.92.12.88:10001/jmxrmi > > However as soon as I try to connect from my own application using > the code example below I get an error the following error. I > figure I need to configure the InitialContextFactory, but I don't > know what class I should specify. I also don't understand how > jconsole is able to connect without any additional configuration, > but my client is not. So, using that URL, JConsole can connect? That's great. > Perhaps somebody has some pointers on how to make remote JMX > connections programmatically. Does anything change if you are running on the same host as the Tomcat process? > ------------------------------------------------------------------------ > > java.io.IOException : Failed to retrieve RMIServer stub: > javax.naming.NoInitialContextException: Cannot instantiate class: > com.sun.enterprise.naming.impl.SerialInitContextFactory [Root > exception is java.lang.ClassNotFoundException: > com.sun.enterprise.naming.impl.SerialInitContextFactory] > java.io.IOException: Failed to retrieve RMIServer stub: > javax.naming.NoInitialContextException: Cannot instantiate class: > com.sun.enterprise.naming.impl.SerialInitContextFactory [Root > exception is java.lang.ClassNotFoundException: > com.sun.enterprise.naming.impl.SerialInitContextFactory] at > javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:369) > > at > javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:270) > > > > Caused by: javax.naming.NoInitialContextException: Cannot > instantiate class: > com.sun.enterprise.naming.impl.SerialInitContextFactory [Root > exception is java.lang.ClassNotFoundException: > com.sun.enterprise.naming.impl.SerialInitContextFactory] at > javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:674) > > at > javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313) > > at javax.naming.InitialContext.init(InitialContext.java:244) > at javax.naming.InitialContext.<init>(InitialContext.java:216) at > javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1927) > > at > javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1896) > > at > javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:287) > > ... 3 more > Caused by: java.lang.ClassNotFoundException: > com.sun.enterprise.naming.impl.SerialInitContextFactory at > java.net.URLClassLoader$1.run(URLClassLoader.java:372) at > java.net.URLClassLoader$1.run(URLClassLoader.java:361) at > java.security.AccessController.doPrivileged(Native Method) at > java.net.URLClassLoader.findClass(URLClassLoader.java:360) at > java.lang.ClassLoader.loadClass(ClassLoader.java:424) at > sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at > java.lang.ClassLoader.loadClass(ClassLoader.java:357) at > java.lang.Class.forName0(Native Method) at > java.lang.Class.forName(Class.java:340) at > com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:72) > > at > com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:61) > > at > javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:672) > > ... 9 more Hmm. Are you using radically different versions of Java on both sides of the connection? Not being able to find an internal class seems like a big problem. Where is your code mentioned in the above stack trace? Which line is it below? (Also, this error is on the client side, not the server, right?) > ------------------------------------------------------------------------ > > Code extract: > > Map<String, String[]> env = new HashMap<String, String[]>(); > String[] credentials = new String[] { "username", "password" }; > env.put(JMXConnector.CREDENTIALS, credentials); String url = > "service:jmx:rmi://10.92.12.88:10002/jndi/rmi://10.92.12.88:10001/jmxrmi"; > > serviceUrl = new JMXServiceURL(url); > JMXConnector connector = JMXConnectorFactory.connect(serviceUrl, > env); MBeanServerConnection connection = > connector.getMBeanServerConnection(); ObjectName servicename = new > ObjectName("java.lang:type=Runtime"); ObjectInstance instance = > connection.getObjectInstance(servicename); - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBCAAGBQJTY62QAAoJEBzwKT+lPKRYiHwP/ikrgEeFYCw2DxWnpcnKCsEZ KKVXyuSPEpZXFDxOhj+EO77F+C+5ocadBkYkUTCZkBhcsc95uCVuZfJpx9HMIrKz Z/w2binOCLnnQqSrjjTw9Cp2MjKrDcTm/PkkITIMjZebDK3DzM4dOM920X4VGXAS P6oFGRdESEy+CAeEzS+0eta4hqvNbgvLHfcIzQnWJzCaWl9JLnAKXyH9yoYj0iUz bL+kDCirtqlum7KevuEQOgCsa1+vDZfsTC8SlKkYcJcoysICbBBHJfVwArzQGbat RYiKPBRA7tbsn2j4D5/YTEOAIl2v1BO9u2BJmuxDDhIuz1kPUQoRlZiLZOkw/Jek KX4kYCAa6GaqkMTKvpHmK891xV8QBtzVpnoKEMUARqGH7stjNr5hHAO7ZSpqiOVy vDPAxRBNMDOsPyXqZGqcPWVzfNbyBjAW4ZQoF+0vb8AUR4u3yn+N2GiA5v+uX0hj tWSNF1nHC1v2j6BrYAUi8wsT7+SJBcOqCjn9+IK2ujINoK9qljBMT7jVNrJjD1zC 4odZYzheMGhdmGult+zMNNLzSRuiIQIUi4ZbQPXBYZQ8zfXeHj3+jZI20hPWlA1n qAvwOV9VbsReKwLt7A8NEFW9al9qxpU0nOArNrVUdxAohQ6aGvyqrhRwUxaLe/k/ jeqt+l8rdKDmWsQmFoGZ =lwJV -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org