db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kathey Marsden <kmarsdende...@sbcglobal.net>
Subject Problem with MBean user/ password example on Wiki page (non-JRMP server at remote endpoint)
Date Wed, 23 Apr 2008 17:23:09 GMT
   
I am trying to follow the example to connect to the MBean server 
programatically with password, but have thus far not been able to get it 
to work.

I start my server like this:
java -Dcom.sun.management.jmxremote.port=9999  
-Dcom.sun.management.jmxremote.password.file=jmxremote.password 
-Djavax.net.ssl.keyStore=serverKeyStore.key 
-Djavax.net.ssl.keyStorePassword=derbym 
-Dcom.sun.management.jmxremote.ssl.need.client.auth=true  
-Djavax.net.ssl.trustStore=serverTrustStore.key 
-Djavax.net.ssl.trustStorePassword=derbym 
-Dcom.sun.management.jmxremote.registry.ssl=true -Djava.security.manager 
-Dderby.install.url=file:/C:/kmarsden/projects/jmxtesting/db-derby-10.4.1.3-lib/lib/  
-Djava.security.policy=jmx.policy -jar lib/derbyrun.jar server start -h 
0.0.0.0

My program is just a cut and paste of the example pretty much.
import javax.management.*;
import javax.management.remote.*;
import java.util.HashMap;

public class MbeanProgramSSL {

public static void main(String[] args) throws Exception
{
    JMXServiceURL url = new JMXServiceURL(
            "service:jmx:rmi:///jndi/rmi://localhost:9999/jmxrmi");
    // Assuming the following JMX credentials: username=controlRole, 
password=derby
    String[] credentials = new String[] { "controlRole" , "derby" };
    HashMap<String,Object> env = new HashMap<String,Object>();
    // Set credentials (jmx.remote.credentials, see JMX Remote API 1.0 
spec section 3.4)
    env.put(JMXConnector.CREDENTIALS, credentials);
    JMXConnector jmxc = JMXConnectorFactory.connect(url, env);
    MBeanServerConnection mbeanServerConn = jmxc.getMBeanServerConnection();

}

}

I run my program like:
java -Djavax.net.ssl.trustStore=clientTrustStore.key 
-Djavax.net.ssl.trustStorePassword=derbym 
-Djavax.net.ssl.keyStore=clientKeyStore.key 
-Djavax.net.ssl.keyStorePassword=derbym MbeanProgramSSL


The exception I get is:

Exception in thread "main" java.io.IOException: Failed to retrieve 
RMIServer stub: javax.naming.CommunicationException [
Root exception is java.rmi.ConnectIOException: non-JRMP server at remote 
endpoint]
        at 
javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:323)
        at 
javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
        at MbeanProgramSSL.main(MbeanProgramSSL.java:16)
Caused by: javax.naming.CommunicationException [Root exception is 
java.rmi.ConnectIOException: non-JRMP server at remote
 endpoint]
        at 
com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:101)
        at 
com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:185)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at 
javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1871)
        at 
javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1841)
        at 
javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:257)
        ... 2 more
Caused by: java.rmi.ConnectIOException: non-JRMP server at remote endpoint
        at 
sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:230)
        at 
sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
        at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
        at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
        at 
com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:97)
        ... 7 more


I was able to connect with SSL user/password with JConsole but just 
can't seem to get it working programatically.  Any idea what I am doing 
wrong?

Kathey




Mime
View raw message