Problem in LocateRegistry.createRegistry

while trying to start rmi registry other than default port
it give Connection refused exception
java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
java.net.ConnectException: EDC8128I Connection refused.
java.net.ConnectException: EDC8128I Connection refused.
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java(Compiled Code))
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:141)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:128)
at java.net.Socket.<init>(Socket.java:285)
at java.net.Socket.<init>(Socket.java:112)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:29)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:124)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:512)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:194)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:178)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:324)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:161)
at UpesTestServer.main(UpesTestServer.java:27)
is it possible to start rmiregistry on non default port without any settings.

while trying to start rmi registry other than default port
it give Connection refused exception
java.rmi.ConnectException: Connection refused to host: localhost; nested exception is: ...
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:161)
at UpesTestServer.main(UpesTestServer.java:27) The exception is raised by a Naming.rebind() call done on line 27 of UpesTestServer.java
Don't forget to use the same port as in your
LocateRegistry.createRegistry(port);
Naming.rebind("//localhost:port/UpesTestServer", uts);
both "port" must be the same.
If this doesn't help, please include UpesTestServer.java code in your question.

Similar Messages

  • Problems using LocateRegistry.createRegistry and getRegistry

    In my server, I create the registry:
    Registry registry = LocateRegistry.createRegistry(1099);This creates a new rmiregistry process at the localhost, so the URL should be
    //localhost:1099
    Then I call:
    registry.rebind("shapes", shapes);The server runs fine. The problem begins with the client (started on the same machine) - the code is as fallows:
    Registry registry = LocateRegistry.getRegistry("my.domain.name", port);
    shapes = (MyContainer) registry.lookup("shapes");And I get the following exception:
    java.rmi.NotBoundException: shapes
    Why does this happen?
    Also, is there any method to check if a given port is free? When I start my server, I give it a port as an argument, create a registry and if the port is already taken, I get a BoundException, but the registry process is already statred (at least my process manager says so).

    Ok, the client runs on the same machine. Now I checked if it works on another computer, and guess what, it doesn't :-(. (I don't use any secutiry yet - neither server nor the client have any security manager set).
    Creating the registry and binding the object:
    Registry registry = LocateRegistry.createRegistry(1099);
    registry.rebind("shapes", shapes);shapes is of type MyContainer, which extends UnicastRemotObject. Its implementation is MyContainerImpl and It has an array inside, and several methods. All of them work nice when run on the same machine. The array containes String objects.
    The client has the interface for MyConatiner. The code looks like this:
    Registry registry = LocateRegistry.getRegistry("my.domain.name", 1099);
    MyContainer shapes = (MyContainer) registry.lookup("shapes");
    System.out.println(shapes.printAllShapes());And this doesn't work. I get an exception:
    java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
    java.net.ConnectException: Connection refused
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:574)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:94)
    at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:179)
    at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132)
    at $Proxy0.getBestJoke(Unknown Source)
    at pizda.Main.main(Main.java:12)
    Caused by: java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:507)
    at java.net.Socket.connect(Socket.java:457)
    at java.net.Socket.<init>(Socket.java:365)
    at java.net.Socket.<init>(Socket.java:178)
    at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
    at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:569)
    ... 7 more
    What is wierd is that I get the exception not in the lookup call (it seems that this works, it returns a reference) but in the line which calls one of the methods of MyContainer object. When I call registry.list()[0] it return the string "shapes".
    All this makes me more and more frystrated, becouse it seems the client can find the remote object, but if it calls it's methods the exception says it can't connect to 127.0.0.1. Why does it try in the first place?
    Someone please help me out.

  • RMI in 1.3.1 vs. 1.1.7 - code that works in 1.1.7 fails in 1.3.1

    I have an RMI server and client that works great under JRE 1.1.7. At initialization, the server installs RMISecurityManager, creates a registry using LocateRegistry.createRegistry(), creates a remote-server object and registers it in the registry. This set-up takes roughly 1 second. Clients are able to locate the remote object by its registry entry and make remote calls without trouble.
    Under JRE 1.3.1_03, this same code, unchanged, is totally worthless. The server initialization takes nearly 3 minutes. The LocateRegistry.createRegistry() call alone takes 40 seconds. Client code takes 2 minutes to locate the remote object by its registry entry, and then all remote calls fail with this exception: java.rmi.UnmarshalException: invalid method hash.
    I realize that "invalid method hash" is supposed to mean that the remote interface used by the client is out of synch with that used by the server, but I can't figure out how this might be. I've deleted all .class files from my project and rebuilt entirely from scratch. Everything compiles cleanly.
    I'm running this under NT 4.0 Workstation SP6. My code is built with Visual Cafe 4.1. (Please don't hold that against me. I know Cafe sucks, but it did produce working code.) I've tried switching Cafe's VM to 1.3 but that didn't help. I've tried creating new stubs manually with "rmic -vcompat" but those stubs are identical to the ones created by Cafe.
    When I threw out 1.3.1_03 and reinstalled JRE 1.1.7, all my code worked again.
    Any ideas? I'm stumped and will appreciate any suggestions.
    -hersker

    Progress report for those who might be interested:
    * Persuade Visual Cafe to not generate ANY stubs or skeletons.
    Either use -normi with the sj.exe compiler,
    or change the project options to use the Sun compiler.
    * Use JDK's rmic with -v1.2 to generate the stubs (no skeletons)
    * Create the RMI server's Jar directly with JDK's jar utility.
    Cafe's archiver appears to be stuck on having skeletons
    and can no longer be used for the server Jar. It can still be
    used to create the client Jars, however.
    This produces an RMI server and client that run under 1.3.1
    without the "invalid method hash" UnmarshalExceptions.
    Of course, it will no longer run under 1.1.x -- <sigh>.
    But the performance problems remain:
    * LocateRegistry.createRegistry() takes 40 seconds
    * Client code takes 2 minutes to locate the remote object by its registry entry
    I'd welcome suggestions from the experts out there.
    -hersker

  • Unexpected RMI problem

    Hi,
    I have unexpected problem with RMI.
    I wrote an application with several server modules and client modules.
    Two server modules use RMI to expose their methods for client and reciprocal exchange. These servers are in the same directory and use the same RMI service. One server starts before other and lunch RMI service. After that it binds its methods. The second server get RMI service , search methods of first server and bind its methods.
    The first time that servers started, they ran correctly for months.
    When I stopped servers for maintenance of other module, without change servers, I had the problem.
    First server started correctly and RMI started correctly too. When second server started, it ran correctly but first server hangs without errors from RMI. I tried to start servers for an hours but nothing changed.
    After 12 hours I tried to start servers and they ran correctly at first trial.
    My questions are: why the same code has this different behaviour? What was it changed in those 12 hours?
    Code:
    Server1: main
    Registry registry = null;
    try {
    registry = LocateRegistry.createRegistry(Integer.valueOf(Port));
    } catch (RemoteException e) {
              e.printStackTrace();
    Server1MethodInterface server1RMIinterface = (server1MethodInterface) UnicastRemoteObject.exportObject(server1RMI,Integer.parseInt(portRMI));
    registry.rebind("server1RMI", server1RMIinterface);
    end main
    Server2: constructor
    try {
         registry = LocateRegistry.getRegistry(ipServer1,Integer.parseInt(Server1RegistryPort.trim()));
    server1MethodInterface = (server1MethodInterface)registry.lookup("server1RMI ");
    } catch (RemoteException e) {
         e.printStackTrace();
    Main
    Server2 server2 = new Server2 (filePath);
    CheckLogin serverLogin = new CheckLogin(filePath, server2);
    LoginInterface loginInterface = (LoginInterface) UnicastRemoteObject.exportObject(serverLogin, server2.getPortRMI());
    server2.registry.rebind("Login", loginInterface);
    Communication communications = new Communication(server2);
    CommunicationsInterface communicationInterface = (CommunicationsInterface) UnicastRemoteObject.exportObject(communications, server2.getPortaRMI());
    server2.registry.rebind("Communications", communicationInterface);
    ……….

    Hi,
    I have unexpected problem with RMI.
    I wrote an application with several server modules and client modules.
    Two server modules use RMI to expose their methods for client and reciprocal exchange. These servers are in the same directory and use the same RMI service. One server starts before other and lunch RMI service. After that it binds its methods. The second server get RMI service , search methods of first server and bind its methods.
    The first time that servers started, they ran correctly for months.
    When I stopped servers for maintenance of other module, without change servers, I had the problem.
    First server started correctly and RMI started correctly too. When second server started, it ran correctly but first server hangs without errors from RMI. I tried to start servers for an hours but nothing changed.
    After 12 hours I tried to start servers and they ran correctly at first trial.
    My questions are: why the same code has this different behaviour? What was it changed in those 12 hours?
    Code:
    Server1: main
    Registry registry = null;
    try {
    registry = LocateRegistry.createRegistry(Integer.valueOf(Port));
    } catch (RemoteException e) {
              e.printStackTrace();
    Server1MethodInterface server1RMIinterface = (server1MethodInterface) UnicastRemoteObject.exportObject(server1RMI,Integer.parseInt(portRMI));
    registry.rebind("server1RMI", server1RMIinterface);
    end main
    Server2: constructor
    try {
         registry = LocateRegistry.getRegistry(ipServer1,Integer.parseInt(Server1RegistryPort.trim()));
    server1MethodInterface = (server1MethodInterface)registry.lookup("server1RMI ");
    } catch (RemoteException e) {
         e.printStackTrace();
    Main
    Server2 server2 = new Server2 (filePath);
    CheckLogin serverLogin = new CheckLogin(filePath, server2);
    LoginInterface loginInterface = (LoginInterface) UnicastRemoteObject.exportObject(serverLogin, server2.getPortRMI());
    server2.registry.rebind("Login", loginInterface);
    Communication communications = new Communication(server2);
    CommunicationsInterface communicationInterface = (CommunicationsInterface) UnicastRemoteObject.exportObject(communications, server2.getPortaRMI());
    server2.registry.rebind("Communications", communicationInterface);
    ……….

  • RMI observer problem

    Hello
    I want to write a client server application using rmi and eclipse, where many clients are able to register to the server. The server has a string attribute and a client should be able to pass a string object to the server and the server replaces the value of his attribute with the sent string and notifies all registered clients of the new value. In a later step the server writes to a mysql database and notifies the clients about changes in the database, but that is later...
    I use eclipse for developing.
    Here is the remoteinterface of the server:
    package com.iz.rmi.server;
    import java.rmi.*;
    import java.rmi.server.*;
    import com.iz.rmi.client.IObserver;
    public interface ISubject extends Remote
         public void registerClient(IObserver obs) throws RemoteException, ServerNotActiveException;
         public void notifyObervers() throws RemoteException, ServerNotActiveException;
    } the remoteinterface of the client:
    package com.iz.rmi.client;
    import java.rmi.*;
    import java.rmi.server.*;
    public interface IObserver extends Remote
         public void sendNotify(String notification) throws RemoteException, ServerNotActiveException;
    }the implementation of the server interface:
    package com.iz.rmi.server;
    import java.net.MalformedURLException;
    import java.rmi.*;
    import java.rmi.server.*;
    import java.rmi.registry.*;
    import java.util.*;
    import com.iz.rmi.client.*;
    public class Subject extends UnicastRemoteObject implements ISubject
         private Vector<IObserver> obs;
         private String service;
         public Subject() throws java.rmi.RemoteException
              super();
              this.obs = new Vector<IObserver>();
         @Override
         public void notifyObervers() throws RemoteException, ServerNotActiveException
              Iterator<IObserver> obsIt = this.obs.iterator();
              while(obsIt.hasNext())
                   IObserver o = obsIt.next();
                   try
                        o.sendNotify("blabla");
                   catch (Exception e)
                        e.printStackTrace();
         @Override
         public void registerClient(IObserver obs) throws RemoteException, ServerNotActiveException
              System.out.println("client registered");
              this.obs.add(obs);
         public static void main(String[] args)
              if (System.getSecurityManager() == null)
                System.setSecurityManager(new SecurityManager());
              try
                String name = "Observable";
                ISubject engine = new Subject();
                //ISubject stub = (ISubject) UnicastRemoteObject.exportObject(engine, 0);
                LocateRegistry.createRegistry(1099);
                Registry registry = LocateRegistry.getRegistry(1099);
                registry.rebind(name, engine);
                System.out.println("ComputeEngine boundlll");
              catch (Exception e)
                System.err.println("ComputeEngine exception:");
                e.printStackTrace();
    } and the implementation of the client interface
    package com.iz.rmi.client;
    import java.rmi.*;
    import java.rmi.server.*;
    import com.iz.rmi.server.*;
    public class Observer extends UnicastRemoteObject implements IObserver
         private String host;
         private String service;
         private ISubject sub;
         public Observer(String host, String service) throws RemoteException
              this.host = host;
              this.service = service;
              System.out.println("Service: " + service);
              try
                   this.sub = (ISubject) Naming.lookup(this.service);
                   this.sub.registerClient(this);
                   System.out.println(" istered");
              catch(Exception e)
                   System.out.println("Unable to connect and register with subject.");
                   e.printStackTrace();
         @Override
         public void sendNotify(String notification) throws RemoteException,
                   ServerNotActiveException
         public static void main(String[] args)
              try {
                   new Observer("192.168.1.34:1099", "Observable");
              } catch (RemoteException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
    }Both programs get started with this vm-argument:
    -Djava.security.policy=C:\daten\noSpring\Obsv\wideopen.policy
    where wideopen.policy looks like this for testing:
    grant {
         // Allow everything for now
         permission java.security.AllPermission;
    };when I start the server all looks fine, but when I start the a client i become just the output.
    Service: Observable
    isteredinstead of
    Service: Observable
    client registerd
    isteredThere are no exceptions or something like that, but it seems that the registerClient()-method does not get called on the server when the client starts. There were many changes since the last time I used rmi, so I don't know what's wrong here. I hope some one can help me with this problem.
    Kind regards,
    Michael

    The server's System.out.prints will go to the server's console on the server host.
    Not interleaved wih the client's output on the client's console on the client host.

  • Problem in Rmi in machine with two IP local & internet

    I am having problem in Rmi in machine with two interfaces local & internet
    i.e..
    if I set property java.rmi.server.hostname+ to the one with internet ip address using System.setProperty()
    I can not access Rmi through local LAN
    if I do not set the property Everything works fine in LAN but I can not access the RMI from Internet
    Pls tell me the solution

    Consider the code Here and if you can suggest in this code what changes I have to make ,I will be thankful to you
    // Class MyHelloServer
    package rmi.server;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.net.Inet4Address;
    import java.net.InetAddress;
    import java.net.MalformedURLException;
    import java.net.NetworkInterface;
    import java.net.SocketException;
    import java.rmi.*;
    import java.rmi.server.ServerNotActiveException;
    import java.util.ArrayList;
    import java.util.Enumeration;
    import javax.swing.JOptionPane;
    import rmi.bl.HelloImpl;
         public class MyHelloServer
              static public ArrayList hostList = new ArrayList();
              static String hostname=null;
              static String SERVER_PORT="9999";
              static String MULTIPLE_BIND="true";
              static{
                   startTest();
              public static void startTest(){
                   try {
                        Enumeration enum1= NetworkInterface.getNetworkInterfaces();
                        while(enum1.hasMoreElements()){
                             NetworkInterface networkInterface = (NetworkInterface)enum1.nextElement();
                             Enumeration enum2 = networkInterface.getInetAddresses();
                             while(enum2.hasMoreElements()){
                                  Object obj = enum2.nextElement();
                                  if(obj instanceof Inet4Address){
                                       if(!hostList.contains(((Inet4Address)obj).getHostAddress())){
                                       hostList.add(((Inet4Address)obj).getHostAddress());
                                            if(networkInterface.isPointToPoint()){
                                                      hostname=((Inet4Address)obj).getHostAddress();
                   }catch (SocketException e) {
                        e.printStackTrace();
                   if(hostname!=null){
                        System.setProperty("java.rmi.server.hostname", hostname);
                   System.out.println(System.getProperty("java.rmi.server.hostname")+"<<<<<< New");
              public static void main(String args[])
               try
                HelloImpl storeServer = new HelloImpl();
                int port=Integer.parseInt(SERVER_PORT);
                String host=InetAddress.getLocalHost().getHostAddress();
                 java.rmi.registry.LocateRegistry.createRegistry(port);
                if(MULTIPLE_BIND.equals("true")){ 
                    for (int i = 0; i < hostList.size(); i++) {
                         System.out.println(hostList.get(i).toString() + " <<<<IP" + i);
                         Naming.rebind("//"+hostList.get(i).toString()+":"+port+"/STORESERVER", storeServer);
                  }else{
                       Naming.rebind("//"+host+":"+port+"/"+"STORESERVER", storeServer);
                MyHelloServer.MyThread thread= new MyThread(":"+port+"/"+"STORESERVER", storeServer);
                System.out.println("Remote Server started.....");
            catch (java.net.MalformedURLException me)
                 System.out.println("Malformed URL: " + me.toString());
                 System.exit(0);
            catch (RemoteException re)
                 System.out.println("Remote exception: " + re.toString());
                 System.exit(0);
            catch (Exception e)
                 System.out.println("Error: " + e.toString());
                 System.exit(0);
         static class MyThread extends javax.swing.JPanel implements ActionListener{
                   String str="";
                   HelloImpl impl;
                   public MyThread(String text,HelloImpl storeServer){
                        this.impl=storeServer;
                        str=text;
                        int timetoWaitForCheck=15000;
                        javax.swing.Timer timer = new javax.swing.Timer(timetoWaitForCheck, this);
                        timer.start();
                          public void actionPerformed(ActionEvent ae)
                             startTest();
                             // Rebind
                                   for (int i = 0; i < hostList.size(); i++) {
                                        try {
                                            Naming.rebind("//"+hostList.get(i).toString()+str, impl);
                                       } catch (RemoteException e) {
                                            e.printStackTrace();
                                       } catch (MalformedURLException e) {
                                            e.printStackTrace();
    }

  • Problem in starting rmid in a port different than the default one

    hi all,
    i am experiencing exceptions in running rmid in a port different than a default one.
    if i run
    rmiregistry 2000
    rmid -J-Djava.security.policy=policy
    java -Djava.security.policy=policy -Djava.rmi.server.codebase=<mypath> -classpath <myclasspath> com.myclass.ActivatableRMI <host:port>
    everything works fine
    but if i try to specify a port in which rmid should be started, then i have exceptions...
    can anyone tell me how to solve my problem? i am running NT 4.0
    thanx and regards
         marco

    If you start rmid at port other than the default one
    (1098) with -port option, it is necessary to set the
    system property "java.rmi.activation.port" to this
    port.
    Rmid internally starts a local registry service
    (LocateRegistry.createRegistry(port)) and binds the
    RMI activation system server object with this registry
    service like Naming.rebind("//:" + port +
    "/java.rmi.activation.ActivationSystem",
    activationSystem);. Activation system provides a means
    for registering groups and "activatable" objects to be
    activated within those groups. When a activatable
    server object is exported, it is registered with this
    activation system, so it should get the stub to the
    activation system which is started as part of rmid.
    ActivationGroup class provides a static function
    getSystem() to get the reference to the activation
    system stub. Now it makes use of the system property
    "java.rmi.activation.port" value to contact the
    registry service where activation system registered
    itself under the name "//:" + value of
    java.rmi.activation.port +
    "/java.rmi.activation.ActivationSystem". If this
    property is not set, it uses the default port 1098.
    -- Srinath MandalapuThis is an awesome and lovely forum answer (and I saw srinath_babu reply to another similarly in my search), but I would like to ask for just a bit of clarification.
    My question is simply making sure I understand the reply above in my own terms...
    Suppose that right now my program involving activatables is already working with default port 1098, but that I wanted or needed to change to another port for rmid. Then is this statement true?
    - IF the commandline which which I start rmid specifies port xyxyx,
    - AND IF I added -Djava.rmi.activation.port=xyxyx to the commandline with which I run the setup for my Activatable (i.e. the program that calls Activatable.register method),
    - THEN my code will still work as is (i.e. I wouldn't have to change my existing code to specify the port anywhere in it)?
    (If I am not understanding this correctly, please let me know!)
    Thanks very much,
    /Mel

  • Problem with lost of the access to the RMI server

    Hi to all.
    We have two applications. First one (master) provides to second (slave) through RMI service their data or other resources.
    In the ordinary way all works fine. But if we need for some reason restart master application, slave can't access to the RMI service and calling of the method Naming.lookup(...) throws java.rmi.UnmarshalException: error unmarshalling return; nested exception is: java.io.EOFException
    Interestingly, calling of method Namig.list(...) at this moment correctly returns an array of the names bound in the registry.
    For completeness, in the time of restarting master application, classes of the RMI services are not changed and thus Stub/Skeleton classes are same on both sides.
    What is reason for this behaviour? It is way to restart/restore RMI access of the slave application to the master without restarting server (Tomcat) of both applications?
    Thank, Roman

    Thank for your reply, but your suggestion not helped me now.
    For registering and binding I used usual practices. Following snippets of code are inside method that perform initialization on application startup. I was trying three versions.
    First version creates registry and binds service classes only. Without any checks.
    try {
      LocateRegistry.createRegistry(rmiPort);
      String ip = Functions.getCurrentEnvironmentNetworkIp();
      if (ip.startsWith("?"))
        throw new Exception("Can't retrieve application IP address.");
      logger.info("Application IP address: " + ip);+
      RMIServiceCommonImpl rmiServiceCommon = new RMIServiceCommonImpl();
      String name = "rmi://" + ip + ":" + rmiPort + "/";
      Naming.rebind(name + IRMIServiceCommon.RMI_SERVICE_COMMON_NAME, rmiServiceCommon);
    catch (Exception e) {
      logger.error("Failed to register RMI services: ", e);
    }On first application start all is OK and client has no problem to access RMI service.
    But if master application is restarted, calling of the method LocateRegistry.createRegistry(rmiPort); throws
    java.rmi.server.ExportException: internal error: ObjID already in use
    Since that, client can't access to the RMI service and following code (method Naming.lookup) throws
    java.rmi.UnmarshalException: error unmarshalling return; nested exception is: java.io.EOFException
      String name = "rmi://" + ConfigServlet.getProperty("rmiHostUrl") + "/";
      IRMIServiceCommon service = (IRMIServiceCommon) Naming.lookup(name + IRMIServiceCommon.RMI_SERVICE_COMMON_NAME);Second version checks if registry exist and trying to get list of registered services. If services not exist Register is created.
    try {
      Registry reg = LocateRegistry.getRegistry(rmiPort);
      String[] list = null;
      try {
        list = reg.list();
      catch (Exception ex) {
        // ignore
      if (list == null || list.length == 0)
        LocateRegistry.createRegistry(rmiPort);
      String ip = Functions.getCurrentEnvironmentNetworkIp();
      if (ip.startsWith("?"))
        throw new Exception("Can't retrieve application IP address.");
      logger.info("Application IP address: " + ip);
      String name = "rmi://" + ip + ":" + rmiPort + "/";
      RMIServiceCommonImpl rmiServiceCommon = new RMIServiceCommonImpl();
      Naming.rebind(name + IRMIServiceCommon.RMI_SERVICE_COMMON_NAME, rmiServiceCommon);
    catch (Exception e) {
      logger.error("Failed to registering RMI services: ", e);
    }Again, first start is OK.
    In this case, after application restart, calling of method Naming.rebind() throws
    java.lang.IllegalStateException at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1272)
    INFO: Illegal access: this web application instance has been stopped already. Could not load eu.arachne.rmi.RMIServiceCommonImpl_Stub.
    This exception is followed by similar exceptions, but differs in class names (stubs) - java.rmi.server.RemoteStub, java.rmi.server.RemoteObject, java.rmi.dgc.Lease, java.rmi.dgc.VMID, java.rmi.server.UID
    Of course, client application can't access to the service.
    The third version first unbinds all services and then performs binding again.
    if (list == null || list.length == 0)
      LocateRegistry.createRegistry(rmiPort);
    else {
      for (int ii = 0; ii < list.length; ii++)
        Naming.unbind(name + list[ii]);
    }But again, rebinding fail as I mentioning above.
    I don't know... :-( How I can solve this problem?
    Thank, Roman

  • Connecting through firewall (weird problem)

    Hello,
    I'm having a very weird problem with JMX on a Linux server. I'm aware of the fact that the out-of-the-box JMX agent doesn't work with firewalls and I'm using a custom agent or rather I'm trying to. The problem is that JConsole/Custom Client fails to connect to the agent with a NoSuchObjectException.
    The Server side code looks as follows
    public class TestServer {
    public static void main(String[] args) throws Exception {
    System.setProperty("java.rmi.server.randomIDs", "true");
    LocateRegistry.createRegistry(15003);
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    JMXServiceURL serviceUrl = new JMXServiceURL(
    "service:jmx:rmi://localhost:15002/jndi/rmi://localhost:15003/jmxrmi");
    JMXConnectorServer connectorServer = JMXConnectorServerFactory
    .newJMXConnectorServer(serviceUrl, null, mbs);
    connectorServer.start();
    Thread.sleep(Integer.MAX_VALUE);
    The Client side code looks as following
    public class TestClient {
    public static void main(String[] args) throws Exception {
    JMXServiceURL u = new JMXServiceURL(
    "service:jmx:rmi:///jndi/rmi://ec2-67-202-2-113.z-2.compute-1.amazonaws.com:15002/jmxrmi");
    JMXConnector c = JMXConnectorFactory.connect(u);
    The Exception I'm getting is
    Exception in thread "main" java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.CommunicationException [Root exception is java.rmi.NoSuchObjectException: no such object in table]
         at javax.management.remote.rmi.RMIConnector.connect(Unknown Source)
         at javax.management.remote.JMXConnectorFactory.connect(Unknown Source)
         at javax.management.remote.JMXConnectorFactory.connect(Unknown Source)
         at foo.bar.TestClient.main(TestClient.java:12)
    The Java version on the Server is
    java version "1.6.0_02"
    Java(TM) SE Runtime Environment (build 1.6.0_02-b05)
    Java HotSpot(TM) Client VM (build 1.6.0_02-b05, mixed mode, sharing)

    You were right. There was one more thing though which I figured out with Wireshark/Ethereal. The machines in Amazon's EC2 Network are running behind a NAT or something and I had to specify the external address with -Djava.rmi.server.hostname=BlaBlub.

  • RMI classpath problem

    Hi folks,
    Using this tutorial;
    http://java.sun.com/j2se/1.5.0/docs/guide/rmi/hello/hello-world.html
    I was able to get the example working when I had all of my classes in the same directory as I ran it. E.g.
    $pwd
    /home/jmcparla/RMI2/server
    $ ls
    Hello.class  Server.class
    $rmiregistry 2000 &
    $ java Server
    Server ready
    $ pwd
    /home/jmcparla/RMI2/client
    $ ls
    Client.class  Hello.class
    $ java Client
    response: Hello, world!So I decided to bundle the code into two Jars, Server.jar (containing Hello.class and Server.class) and Client.jar (Hello.class and Client.class). However this time when I went to start the Server;
    $ pwd
    /home/jmcparla/RMI2
    $ ls
    Server.jar  bin  client  policy  server  src
    $ rmiregistry 2000 &
    [1] 2848
    $ java -jar Server.jarI got these exceptions;
    Server exception: java.rmi.ServerException: RemoteException occurred in server t
    hread; nested exception is:
            java.rmi.UnmarshalException: error unmarshalling arguments; nested excep
    tion is:
            java.lang.ClassNotFoundException: Hello
    java.rmi.ServerException: RemoteException occurred in server thread; nested exce
    ption is:
            java.rmi.UnmarshalException: error unmarshalling arguments; nested excep
    tion is:
            java.lang.ClassNotFoundException: Hello
            at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:396
            at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250)
            at sun.rmi.transport.Transport$1.run(Transport.java:159)
            at java.security.AccessController.doPrivileged(Native Method)
            at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
            at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:5
    35)
            at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTranspor
    t.java:790)
            at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
    .java:649)
            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
    utor.java:886)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
    .java:908)
            at java.lang.Thread.run(Thread.java:619)
            at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknow
    n Source)
            at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
            at sun.rmi.server.UnicastRef.invoke(Unknown Source)
            at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
            at Server.main(Server.java:22)
    Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested ex
    ception is:
            java.lang.ClassNotFoundException: Hello
            at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
            at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:386
            at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250)
            at sun.rmi.transport.Transport$1.run(Transport.java:159)
            at java.security.AccessController.doPrivileged(Native Method)
            at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
            at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:5
    35)
            at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTranspor
    t.java:790)
            at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
    .java:649)
            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
    utor.java:886)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
    .java:908)
            at java.lang.Thread.run(Thread.java:619)
    Caused by: java.lang.ClassNotFoundException: Hello
            at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Class.java:247)
            at sun.rmi.server.LoaderHandler.loadProxyInterfaces(LoaderHandler.java:7
    11)
            at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:655)
            at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:592)
            at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:6
    28)
            at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:294
            at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStrea
    m.java:238)
            at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1531)
            at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1493)
            at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1
    732)
            at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
            at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
            ... 12 moreIt seems to be that it cannot find the Hello class file but this is bundled in Server.jar. Putting Server.jar on the classpath makes no difference.
    Any ideas?

    Cheers, using createRegistry(int) did the trick (along with a few other bits and pieces).
    For the sake of aiding others with this kind of problem here's what I did. Remember most of it came from the Sun Java 5 RMI tutorial (http://java.sun.com/j2se/1.5.0/docs/guide/rmi/hello/hello-world.html).
    1. Download and compile SUN's class file server (http://java.sun.com/javase/technologies/core/basic/rmi/class-server.zip). You'll need this to serve up the classes. Place this in a different directory to the one your going to use for the RMI tutorial.
    2. Download the source files for the tutorial.
    3. Use this directory structure (relative to /home/<username>)
    | RMI/
            | src/
                  | example/
                                | hello/
            | bin/4. Change the server to the following. The main points to note are the registry is now created (rather than located) and the port number used.
    package example.hello;
    import java.rmi.registry.Registry;
    import java.rmi.registry.LocateRegistry;
    import java.rmi.RemoteException;
    import java.rmi.server.UnicastRemoteObject;
    public class Server implements Hello {
        public Server() {}
        public String sayHello() {
         return "Hello, world!";
        public static void main(String args[]) {
         try {
                System.out.println("Starting Server");
             Server obj = new Server();
             Registry registry = LocateRegistry.createRegistry(2000);
                System.out.println("Created registry");
             Hello stub = (Hello) UnicastRemoteObject.exportObject(obj, 0);
                System.out.println("Exported Server");
             // Bind the remote object's stub in the registry
             registry.rebind("Hello", stub);
                System.out.println("Bound Server to \"Hello\"");
             System.out.println("Server ready");
         } catch (Exception e) {
             System.err.println("Server exception: " + e.toString());
             e.printStackTrace();
    }5. In the src dir compile with the following;
    javac -d ../bin example/hello/*.java6. In the bin dir create the server jar with the following;
    jar cvfe Server.jar example.hello.Server example/hello/Server* example/hello/Hello*7. In the bin dir create the client jar with the following;
    jar cvfe Client.jar example.hello.Client example/hello/Client* example/hello/Hello*8. Move both Jars out of the bin directory to the parent one (e.g. /home/<username>RMI/) (to prevent the rmi registry / server using the current dir in the classpath if you've set it up that way).
    9. Create the policy file in the RMI directory (see above directory structure);
    grant codeBase * {
        permission java.security.AllPermission;
        permission java.net.SocketPermission "*", "accept, connect, listen, resolve";
    };10. Start the class file server (read the notes that come with it) in its own directory. Note the port number used (different from RMI registry) and the Jar file on the end of the path.
    java ClassFileServer 2001 /home/<username>/RMI/Server.jar11. If this has worked you should be able to visit the URL http://localhost:2001 and get a blank page (as opposed to a broken link notification).
    12. Start the RMI server in the bin dir. Note the port is the same as the one used to launch the class file server.
    java -Djava.security.policy=policy -Djava.rmi.codebase=http://localhost:2001/ -jar Server.jar13. You should see the following output;
    Starting Server
    Created registry
    Exported Server
    Bound Server to "Hello"
    Server ready14. Start the client
    java -jar Client.jar15. You should see the following output;
    response: Hello, world!

  • RMI & windows 2000 - eth. cable disconnection problem

    Hello
    RMI server and client on the same PC, if I disconnect eth. cable on the PC client cannot access anymore to server (remote exception), exactly as if they were on 2 different PC, with link cut !!!
    The problem didn't exist on Windows NT 4.
    Is there a parameter somewhere to avoid this behaviour, or should I live with ?
    Many thanks in advance

    Thanks
    but it doesn't work !
    Details :
    Server : i use LocateRegistry.createRegistry(xx), i do rebind (//:xx/<objectname>)
    Client : i do lookup(//:xx/<objectname>)
    Client and server on the same PC - When i stop the server :
    - on NT 4 : connectException on localhost
    - on windows 2000 : connectException on PC IP @ (!! localhost should be used)
    That's why when i disconnect the PC eth. cable on windows 2000 the RMI connection is lost, whereas it's not lost on NT.
    any idea to force windows 2000 to use local host ?

  • SocketEXception problem in  windows vista IPV6

    Hi,
    i am not able to run tcpmon(tool used for tracking soap messages)on IPV6 vista machine, It has jre1.5.0_10 version and axis1.2.
    The error thrown is "java.net.SocketException:Address family not supported by protocol family:create".
    I am able to successfully run tcpmon on windows XP with the same java and axis version.
    Is it anyways related to the existing bug http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6230761 ???
    Can anyone help me out???
    Thanks in advance.
    sirisha

    I got the same errors while creating a ServerSocket in Windows Vista Pure IPv6
    The JRE version is 1.5.0_11.
    java.net.SocketException: Address family not supported by protocol family: create
         java.net.ServerSocket.createImpl(Unknown Source)
         java.net.ServerSocket.getImpl(Unknown Source)
         java.net.ServerSocket.bind(Unknown Source)
         java.net.ServerSocket.<init>(Unknown Source)
         java.net.ServerSocket.<init>(Unknown Source)
         sun.rmi.transport.proxy.RMIDirectSocketFactory.createServerSocket(Unknown Source)
         sun.rmi.transport.proxy.RMIMasterSocketFactory.createServerSocket(Unknown Source)
         com.ca.dia.common.socketFactory.ServerSocketFactory.createServerSocket(ServerSocketFactory.java:122)
         sun.rmi.transport.tcp.TCPEndpoint.newServerSocket(Unknown Source)
         sun.rmi.transport.tcp.TCPTransport.listen(Unknown Source)
         sun.rmi.transport.tcp.TCPTransport.exportObject(Unknown Source)
         sun.rmi.transport.tcp.TCPEndpoint.exportObject(Unknown Source)
         sun.rmi.transport.LiveRef.exportObject(Unknown Source)
         sun.rmi.server.UnicastServerRef.exportObject(Unknown Source)
         sun.rmi.registry.RegistryImpl.setup(Unknown Source)
         sun.rmi.registry.RegistryImpl.<init>(Unknown Source)
         java.rmi.registry.LocateRegistry.createRegistry(Unknown Sourc

  • Beginner running RMI example problem

    I am trying to test this RMI code from Thinking in java and it is giving this error
    Exception in thread "main" java.lang.NoClassDefFoundError: DispatchPerfectTime (
    wrong name: project3/rmi/DispatchPerfectTime)
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:488)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:10
    6)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:243)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:51)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:190)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:183)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:294)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:281)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:310)
    I compiled the 3 files below and also called rmic and created a stub and skeleton..... Only it doesnt run..
    Any ideas why ?
    INTERFACE
    package project3.rmi;
    import java.rmi.*;
    interface PerfectTimeI extends Remote
         long getPerfectTime() throws RemoteException;
    }Implementation of Remote interface
    package project3.rmi;
    import java.rmi.*;
    import java.rmi.server.*;
    import java.rmi.registry.*;
    import java.net.*;
    public class PerfectTime extends UnicastRemoteObject implements PerfectTimeI
         public long getPerfectTime() throws RemoteException
              return System.currentTimeMillis();
         //constructor to throw remote exceptions
         public PerfectTime() throws RemoteException
              //super(); called automatically
         //register for rmi server
         public static void main(String args[]) throws Exception
              LocateRegistry.createRegistry(2005);
              System.setSecurityManager(new RMISecurityManager());
              PerfectTime pt = new PerfectTime();
         Naming.rebind("//200.23.23.2:2005/PerfectTime",pt); //I put dummy IP instead of my real IP
              System.out.println("Ready to do time");
    }USING REMOTE OBJECT
    /**Using the remote object**/
    package project3.rmi;
    import java.rmi.*;
    public class DispatchPerfectTime
         public static void main(String args[]) throws Exception
              System.setSecurityManager(new RMISecurityManager());
              PerfectTimeI t = (PerfectTime)Naming.lookup("//200.23.23.2:2005/PerfectTime");
              for(int i =0;i<10;i++)
              System.out.println("Perfect Time is "+t.getPerfectTime());
    }

    I am just using another RMI example from class now...
    All files are compiling but this is error.....
    C:\>java -classpath c:\ RMIServer
    Starting Server
    Started Server...
    Binding to RMI Registry
    Error RemoteException occurred in server thread; nested exception is:
    java.rmi.UnmarshalException: error unmarshalling arguments; nested excep
    tion is:
    java.lang.ClassNotFoundException: RMIServer_Stub
    I doono if my host is correct...... I donno what to write in place of test... its some service??
    import java.rmi.*;
    import java.rmi.server.*;
    import java.rmi.registry.*;
    public class RMIServer extends UnicastRemoteObject implements RMIInterface
      static String host = "rmi://IPAddress/test";
      static String data[] = {"c","c++","java"};
      public RMIServer() throws RemoteException
                super();
      //implement methods
      public int getNumData() throws RemoteException
                return data.length;
      public String getData(int index) throws RemoteException
              if(index>=0 && index<data.length)
                   return data[index];
              else
                   return "N/A";
      public static void main(String args[])
           RMIServer server;
           try{
                System.out.println("Starting Server");
                server = new RMIServer();
                System.out.println("Started Server...");
                  System.out.println("Binding to RMI Registry");
                Naming.rebind(host,server);
                System.out.println("Remote methods registered successfully");
           catch(Exception e){
                System.out.println("Error "+e.getMessage());
      }//main
    } //class

  • RMI related NotSerializableException problem

    Hi,
    I am attempting to write a distributed chess player program. I've written a ChessServer class that all clients register with before they can play (which keeps track of how many clients are connected). Each clients creates an instance of a ChessServerListener which they add to the ChessServer's vector of listeners via a remote call to the method 'addChessServerListener(ChessServerListener listener)' in the ChessServer class. Everytime a new Client registers with the server, an event method is fired which notifies all listeners.
    My client uses the following code to create the listener and add it to the server's vector of listeners:
    chessServerListener = new ChessServerListener() {
    public void clientListValueChanged() {
    System.out.println("client list value changed");
    //The following results in a RemoteException:
    chessServer.addChessServerListener(chessServerListener);
    The exception is as follows:
    trouble: RemoteException
    java.rmi.MarshalException: error marshalling arguments; nested exception is:
              java.io.NotSerializableException: frontend.IBoard$12
              at sun.rmi.server.UnicastRef.invoke(Uknown Source)
              at frontend.RMI.ChessServerImpl_Stub.addChessServerListener(Uknown Source)
              at frontend.IBoard.connectToChessServer(IBoard.java:430)
    I have done a million Google searches trying to sort this out, and I think it might have something to do with the code I use to start up my ChessServer, which is as follows:
    UnicastRemoteObject.exportObject(this,REG_PORT);
    reg = LocateRegistry.createRegistry(REG_PORT);
    reg.rebind(SERVER_NAME, this);
    Can anyone help me? I can't continue with my project until I solve this!
    Thanks in advance.

    Anonymous classes that you create from an interface implement only that interface; they are not Serializable. You need to declare the listener as a named local class:class LocalClass implements ChessServerListener, Serializable {
        public void clientListValueChanged() {
            System.out.println("client list value changed");
    chessServerListener = new LocalClass();
    chessServer.addChessServerListener(chessServerListener);
    ...

  • Problem using SSL with JMX

    Hi ,
    I am trying to implement SSL with JMX. I took the example of Luis Miguel Alventosa to see how it works. I imported all the classes, password a access properties file. When I am able to start the MyApp server in the example. But when I am trying to run MyClient, it is giving me the following exception
    Initialize the environment map
    Create an RMI connector client and connect it to the RMI connector server
    Exception in thread "main" java.rmi.ConnectIOException: Exception creating connection to: <IP>; nested exception is:
         java.net.SocketException: Default SSL context init failed: null
         at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
         at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
         at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
         at sun.rmi.server.UnicastRef.newCall(Unknown Source)
         at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
         at com.example.MyClient.main(MyClient.java:30)
    Caused by: java.net.SocketException: Default SSL context init failed: null
         at javax.net.ssl.DefaultSSLSocketFactory.createSocket(Unknown Source)
         at javax.rmi.ssl.SslRMIClientSocketFactory.createSocket(Unknown Source)
         ... 6 moreHere is the MyApp code I used
    package com.example;
    import java.lang.management.*;
    import java.rmi.registry.*;
    import java.util.*;
    import javax.management.*;
    import javax.management.remote.*;
    import javax.management.remote.rmi.*;
    import javax.rmi.ssl.*;
    public class MyApp {
        public static void main(String[] args) throws Exception {
            // Ensure cryptographically strong random number generator used
            // to choose the object number - see java.rmi.server.ObjID
            System.setProperty("java.rmi.server.randomIDs", "true");
            // Start a secure RMI registry on port 3000.
            System.out.println("Create a secure RMI registry on port 3000");
            SslRMIClientSocketFactory csf = new SslRMIClientSocketFactory();
            SslRMIServerSocketFactory ssf = new SslRMIServerSocketFactory(null, null, true);
            Registry registry = LocateRegistry.createRegistry(3000, csf, ssf);
            // Retrieve the PlatformMBeanServer.
            System.out.println("Get the platform's MBean server");
            MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
            // Environment map.
            System.out.println("Initialize the environment map");
            Map<String,Object> env = new HashMap<String,Object>();
            // Provide the password file used by the connector server to
            // perform user authentication. The password file is a properties
            // based text file specifying username/password pairs.
            env.put("jmx.remote.x.password.file", "password.properties");
            // Provide the access level file used by the connector server to
            // perform user authorization. The access level file is a properties
            // based text file specifying username/access level pairs where
            // access level is either "readonly" or "readwrite" access to the
            // MBeanServer operations.
            env.put("jmx.remote.x.access.file", "access.properties");
            // Create and start an RMI connector server.
            // As specified in the JMXServiceURL the RMIServer stub will be
            // registered in the RMI registry running in the local host on
            // port 3000 with the name "jmxrmi". This is the same name the
            // out-of-the-box management agent uses to register the RMIServer
            // stub too.
            // JMXServiceURL = "service:jmx:rmi:///jndi/rmi://:3000/jmxrmi"
            System.out.println("Create and start an RMI connector server");
            JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
            RMIJRMPServerImpl server = new RMIJRMPServerImpl(3000, csf, ssf, env);
            RMIConnectorServer cs = new RMIConnectorServer(url, env, server, mbs);
            cs.start();
            registry.bind("jmxrmi", server);
            System.out.println("Waiting for incoming connections...");
    }Here is the MyClient
    package com.example;
    import java.rmi.registry.*;
    import java.util.*;
    import javax.management.*;
    import javax.management.remote.rmi.*;
    import javax.rmi.ssl.SslRMIClientSocketFactory;
    public class MyClient {
        public static void main(String[] args) throws Exception {
            // Environment map
            System.out.println("\nInitialize the environment map");
            Map<String,Object> env = new HashMap<String,Object>();
            // Provide the credentials required by the server to successfully
            // perform user authentication
            String[] credentials = new String[] { "username" , "password" };
            env.put("jmx.remote.credentials", credentials);
            // Create an RMI connector client and
            // connect it to the RMI connector server
            System.out.println("\nCreate an RMI connector client and " +
                    "connect it to the RMI connector server");
            SslRMIClientSocketFactory csf = new SslRMIClientSocketFactory();
            Registry registry = LocateRegistry.getRegistry(null, 3000, csf);
            RMIServer stub = (RMIServer) registry.lookup("jmxrmi");
            RMIConnector jmxc = new RMIConnector(stub, env);
            jmxc.connect(env);
            // Get an MBeanServerConnection
            System.out.println("\nGet an MBeanServerConnection");
            MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
            // Get domains from MBeanServer
            System.out.println("\nDomains:");
            String domains[] = mbsc.getDomains();
            for (int i = 0; i < domains.length; i++) {
                System.out.println("\tDomain[" + i + "] = " + domains);
    // Get MBean count
    System.out.println("\nMBean count = " + mbsc.getMBeanCount());
    // Close MBeanServer connection
    System.out.println("\nClose the connection to the server");
    jmxc.close();
    System.out.println("\nBye! Bye!");
    Here is the password.properties
    monitorRole mrpasswd
    controlRole crpasswdand access.properties
    monitorRole readonly
    controlRole readwriteI used the following jvm parameters to run the apps
    -Djavax.net.ssl.keyStore=.keystore -Djavax.net.ssl.keyStorePassword=keypass -Djavax.net.ssl.trustStore=proxytruststore -Djavax.net.ssl.trustStorePassword=trustpassI really don't know where I am doing the mistake. Can anyone please give any idea ? For security I didnt disclosed the IP of my mechine in the error, insted I replace it with <IP>

    Hi,
    I assume you did create a keystore and trustore, right?
    Could you verify that the paths to these files you give in your java options
    are correct?
    You could also try to activate debug traces - in particular security traces - see
    at the end of this blog:
    http://blogs.sun.com/jmxetc/entry/troubleshooting_connection_problems_in_jconsole
    This may help you diagnose what is going wrong.
    Hope this helps,
    -- daniel
    JMX, SNMP, Java, etc...
    http://blogs.sun.com/jmxetc

Maybe you are looking for

  • Document category changes to credit from returns

    hi, we have changed the document type category from that of the returns to the credit memo request and modified the order related billing type. When we wanted to move changes to the production, we see that there are 2500 documents lying with some del

  • 2.0 Install Error

    When I run the htmldbins.sql I am getting the following error ...done Oracle SYS grants ...CONNECT as the Oracle user who will own the flows engine Session altered. I. I N S T A L L P R E - C R E A T E T A B L E S P E C S SP2-0310: unable to open fil

  • Digital camera video = memory card

    What is the best kind of memory card for videos ( making a video on a digital camera) & how many GBs should i consider on getting?

  • IChat unexpectedly quits on launch

    Hello. Ever since I got my new iMac, straight out of the box iChat would not open. It works on other user accounts so it must be related to when I set up the computer. This is not a big problem for me since I use Adium for most of my instant messagin

  • Displaying PDF within Browser, but disabling Toolbars and Navigation Panel

    I am currently working on the site for the University of Oregon Undergraduate Council, and my boss wishes me to disable the Toolbars and Navigation Panel that display when users open a PDF, as she finds them "distracting". Although I think this is a