No RMI connectors are started as yet.
Use JMXMP with the ServiceURL reported by
http://localhost:8080/__asadmin/amx
I need to update AppserverConnectionSource for JMXMP. But you can use
standard JMX APIs to connect for now, using that JMXServiceURL.
Lloyd
On Mar 26, 2008, at 4:53 PM, Sreenivas Munnangi wrote:
> Lloyd,
>
> I am trying to use AMX in a stand-alone java client and the code is
> below.
>
> try {
> AppserverConnectionSource src = new
> AppserverConnectionSource(
> AppserverConnectionSource.PROTOCOL_RMI,
> "localhost", 8686, "admin", "admin123", null);
> System.out.println("before src.getDomainRoot ...");
> DomainRoot domainRoot = src.getDomainRoot();
> } catch (Exception e) {
> System.out.println("Caught exception ...");
> e.printStackTrace();
> }
>
> When executed, it throws the following exception. Seems we have not
> started any JMX Connectors. I understand that it will happen some
> time but I want to know if I missed any thing.
>
> Appreciate your help.
>
> thanks
> sreeni
>
> run:
> [java] TestAMX
> [java] before src.getDomainRoot ...
> [java] Caught exception ...
> [java] java.lang.RuntimeException: 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.InstantiationException:
> com.sun.enterprise.naming.impl.SerialInitContextFactory]
> [java] at
> com
> .sun
> .appserv
> .management.client.ProxyFactory.getInstance(ProxyFactory.java:459)
> [java] at
> com
> .sun
> .appserv
> .management.client.ProxyFactory.getInstance(ProxyFactory.java:409)
> [java] at
> com
> .sun
> .appserv
> .management
> .client
> .AppserverConnectionSource
> .getDomainRoot(AppserverConnectionSource.java:516)
> [java] at TestAMX.main(TestAMX.java:29)
> [java] Caused by: 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.InstantiationException:
> com.sun.enterprise.naming.impl.SerialInitContextFactory]
> [java] at
> javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:
> 317)
> [java] at
> javax
> .management
> .remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
> [java] at
> com
> .sun
> .appserv
> .management
> .client
> .AppserverConnectionSource.createNew(AppserverConnectionSource.java:
> 409)
> [java] at
> com
> .sun
> .appserv
> .management
> .client
> .AppserverConnectionSource
> .getJMXConnector(AppserverConnectionSource.java:472)
> [java] at
> com
> .sun
> .appserv
> .management
> .client
> .AppserverConnectionSource
> .getMBeanServerConnection(AppserverConnectionSource.java:501)
> [java] at
> com
> .sun
> .appserv
> .management.client.ProxyFactory.getInstance(ProxyFactory.java:435)
> [java] ... 3 more
> [java] Caused by: javax.naming.NoInitialContextException: Cannot
> instantiate class:
> com.sun.enterprise.naming.impl.SerialInitContextFactory [Root
> exception is java.lang.InstantiationException:
> com.sun.enterprise.naming.impl.SerialInitContextFactory]
> [java] at
> javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:
> 657)
> [java] at
> javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
> [java] at
> javax.naming.InitialContext.init(InitialContext.java:223)
> [java] at
> javax.naming.InitialContext.<init>(InitialContext.java:197)
> [java] at
> javax
> .management
> .remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1815)
> [java] at
> javax
> .management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:
> 1787)
> [java] at
> javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:
> 259)
> [java] ... 8 more
> [java] Caused by: java.lang.InstantiationException:
> com.sun.enterprise.naming.impl.SerialInitContextFactory
> [java] at java.lang.Class.newInstance0(Class.java:335)
> [java] at java.lang.Class.newInstance(Class.java:303)
> [java] at
> javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:
> 654)
> [java] ... 14 more
>
> BUILD SUCCESSFUL
> Total time: 2 seconds
>
---
Lloyd L Chambers
lloyd.chambers_at_sun.com
Sun Microsystems, Inc