RMI Rebind problem

Hi
I'm a novice on RMI and have been trying to learn the concept by copying the HelloWorld RMI example from the Java Tutorials to run on my Windows 98 PC. However, when I issued a DOS command: Java HelloImpl, the following error came up:
" Access denied (java.net.SocketPermission .....1099 connect resolve)"
Any suggestions what possible cause of the problem ?
Thanks.

check the permissions in your policy file.

Similar Messages

  • RMI Marshalling Problem:  weblogic.Admin PING

    WebLogic 5.1.0 with service pack 8 has been installed on a HPUX server. I'm
    trying to ping the server from an NT box, but I'm getting some RMI
    marshalling problems.
    Here is the command that I run on NT:
    C:\weblogic\jre1_2\jre\bin\java -classpath
    c:weblogic/lib/weblogic510sp.jar;c:/weblogic/classes;c:/weblogic/lib/weblogi
    caux.jar weblogic.Admin t3://HPServer:7001 PING > MarshallingProblem.txt
    Here is what is in MarshallingProblem.txt (modified server name):
    Failed to connect to t3://HPServer:7001 due to:
    [weblogic.rmi.UnexpectedException: Marshalling:
    - with nested exception:
    [weblogic.rjvm.PeerGoneException:
    - with nested exception:
    [weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[ Exception
    creating response stream ] - with nested exception:
    [java.io.InvalidClassException:
    weblogic.security.acl.internal.AuthenticatedUser; Local class not
    compatible: stream classdesc serialVersionUID=6699361079932480379 local
    class serialVersionUID=2825328378974757378]]]]
    I previously had similar problems pinging the server from the server itself
    until I included the servicepack in the classpath.
    Anyone have any idea what going on in this situation?
    Cameron Taggart

    Cameron
    Can you test with sp8 installed on your NT machine too ? And also make
    sure you set the classpath with the sp8 jar files on NT before you run
    weblogic.Admin PING
    Raj Alagumalai
    Cameron Taggart wrote:
    WebLogic 5.1.0 with service pack 8 has been installed on a HPUX server. I'm
    trying to ping the server from an NT box, but I'm getting some RMI
    marshalling problems.
    Here is the command that I run on NT:
    C:\weblogic\jre1_2\jre\bin\java -classpath
    c:weblogic/lib/weblogic510sp.jar;c:/weblogic/classes;c:/weblogic/lib/weblogi
    caux.jar weblogic.Admin t3://HPServer:7001 PING > MarshallingProblem.txt
    Here is what is in MarshallingProblem.txt (modified server name):
    Failed to connect to t3://HPServer:7001 due to:
    [weblogic.rmi.UnexpectedException: Marshalling:
    - with nested exception:
    [weblogic.rjvm.PeerGoneException:
    - with nested exception:
    [weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[ Exception
    creating response stream ] - with nested exception:
    [java.io.InvalidClassException:
    weblogic.security.acl.internal.AuthenticatedUser; Local class not
    compatible: stream classdesc serialVersionUID=6699361079932480379 local
    class serialVersionUID=2825328378974757378]]]]
    I previously had similar problems pinging the server from the server itself
    until I included the servicepack in the classpath.
    Anyone have any idea what going on in this situation?
    Cameron Taggart

  • Rmi rebind's problem,dynamic rebind object!

    hi,everyone
    I have a problem,i know a class's name and this class have implement remoteobject,
    what can i rebind this class on the RMI registry .
    I write code like this:
    Class temp = Class.forName("Test");
    Naming.rebind("test",temp.newInstance());
    the "Test" is my class name,but cann't compile this code ,it's say:
    rebind(java.lang.String,java.rmi.Remote) in java.rmi.Naming cannot be applied to (java.lang.String,java.lang.Object)
    what can i do? help me

    You might try downcasting your newly created Object to a Remote. If you give a method a java.lang.Object reference, it won't figure out if it's really pointing to a java.rmi.Remote.

  • Rmi Registry rebind problem

    hi
    I have used the Registry.rebind method in my program. The problem I am facing is like this;
    when I use the rebind method as 'registry.rebind("Server",this);' it is working fine; but when I use
    String name="Server";
    'registry.rebind(name,this);' it is giving the following error: java.rmi.NotBoundException: Server.
    Any suggestions?
    thnx
    Som

    have you try
    final static String name = "Server";

  • 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.

  • Got a RMI Client problem

    HI all im really not sure how to fix this error that im having, to be honest im not really sure what i have done wrong, or where im going wrong with pulling information from my interface or and implimentation.
    Okies here is all the code
    Interface:
    public interface RMIServ
    extends java.rmi.Remote {
    public String PassCheck(String pass, String user)
    throws java.rmi.RemoteException;
    Implimentation:
    public class RMIServImpl
    extends
         java.rmi.server.UnicastRemoteObject
    implements RMIServ {
    // Implementations must have an
    //explicit constructor
    // in order to declare the
    //RemoteException exception
    public RMIServImpl()
    throws java.rmi.RemoteException {
    super();
         public String PassCheck(String pass, String user)//takes the user and switch number
    throws java.rmi.RemoteException {
         String result;
         int password = Integer.parseInt(pass);//converts the string to an int
              int info = Integer.parseInt(user);//converts the string to an int
    if (password==72)//checks password
         switch(info)                         //start switch.
              case 1: result="Hello my name is Gareth Gates.";break;
              case 2: result= "My student number is 0302814.";break;
              case 3: result= "I am Taking Computer Science and Robotics.";break;
              case 4: result= "This semester i am taking 4 units, this is one.";break;
              case 5: result= "my project is on server times.";break;
              case 6: result= "i live in luton during the week.";break;
              case 7: result= "i work in a garden centre.";break;
              case 8: result= "please let me know what you think of my server.";break;
              case 9: result= "Email: [email protected]";break;
              case 10: result= "Email me any time, thanks.";break;
              default : result= "You entered a number bigger then 10 please try again.";break;
              }                                        //end switch.
         return result;                         //sends string back to client.
    else
         return result= "You entered the wrong password";//send back an error
    Server:
    import java.rmi.Naming;
    public class RMIServServer {
    public RMIServServer() {
    try {
    RMIServ c = new RMIServImpl();
    Naming.rebind("rmi://localhost:1099/RMIServService", c);
    } catch (Exception e) {
    System.out.println("Trouble: " + e);
    public static void main(String args[]) {
    new RMIServServer();
    Client:
    import java.rmi.Naming;
    import java.rmi.RemoteException;
    import java.net.MalformedURLException;
    import java.rmi.NotBoundException;
    import javax.swing.*;
    public class RMIServClient {
    public static void main(String[] args) {
    try {
    RMIServ c = (RMIServ)
    Naming.lookup("rmi://localhost/RMIServService");
    String password = JOptionPane.showInputDialog("Please enter your password");
    if (password == c.PassCheck(pass)){
    JOptionPane.showMessageDialog(null, "Password Correct");
    catch (MalformedURLException murle) {
    System.out.println();
    System.out.println(
    "MalformedURLException");
    System.out.println(murle);
    catch (RemoteException re) {
    System.out.println();
    System.out.println(
    "RemoteException");
    System.out.println(re);
    catch (NotBoundException nbe) {
    System.out.println();
    System.out.println(
    "NotBoundException");
    System.out.println(nbe);
    catch (
    java.lang.ArithmeticException
    ae) {
    System.out.println();
    System.out.println(
    "java.lang.ArithmeticException");
    System.out.println(ae);
    Any light that you could shed on my problem would be much appreciated, thanks for the help in advance
    the bold is where my problem lies
    Joe de Ronde
    Message was edited by:
    joederonde

    try
    String password = JOptionPane
              .showInputDialog("Please enter your password");
    if (password == c.PassCheck(password, "username")) {
         JOptionPane.showMessageDialog(null, "Password Correct");
    }Also your implementation is wrong, you better take a look at some examples (like the java tutorial, including the rmi tutorial, or if you're using eclipse there are some working ready to use examples in the rmi plugin for eclipse (google it).

  • RMI exception problem

    Hi guys. I am developing distributed application based on RMI, but I have problem I cannot solve.
    I compile my project, generate stubs for implementation classes and then run Server class. But each time I get following errors:
    java.rmi.UnmarshalException: error unmarshalling arguments; nested excep
    tion is:
            java.lang.ClassNotFoundException: Server_Stub
            at sun.rmi.server.UnicastServerRef.oldDispatch(Unknown Source)
            at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
            at sun.rmi.transport.Transport$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at sun.rmi.transport.Transport.serviceCall(Unknown Source)
            at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
            at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Sou
    rce)
            at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Sour
    ce)
            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
            at java.lang.Thread.run(Unknown Source)
            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.rebind(Unknown Source)
            at java.rmi.Naming.rebind(Unknown Source)
            at Server.main(Server.java:341)I run the name server in the same folder, than all other code and all class files should be there also. Do you have any thought, why is this happening? Thanks

    Look at the stack trace. You will see:
    (a) Registry.bind(), which means you are invoking a Registry operation
    (b) ServerException, which means that whatever the exception was it happened in the server you were calling, not in your own code. In this case it happened inside the Registry's implementation of bind().
    So it is the Registry that can't find the class.

  • RMI-NAT Problem with random ports

    Hi,
    I had a RMI server in a machine with the private IP 10.XX.XX.XX and a firewall with the public IP 196.XX.XX.XX
    I am using the property: java.rmi.server.hostname to 196.XX.XX.XX and a small test application. The server is behind the firewall/NAT machine with a limited set of open ports (including the non standard 8001 port that I am using instead 1099)
    1. The server start perfectly
    2. The client can connect to the server and execute the method Naming.list() successfully
    3. At the moment that the client attempt to perform the bind, the client hang up for almost 7 minutes and finally throws and exception due time-outs.
    According a "strace" and "netstat" commands under Linux and also the flag: java.rmi.server.logCalls we obtain the next data:
    1. The server open the port 8001 (PERFECT)
    2. But also open a random port and the client -at the bind moment- use that port (in the range 34000-35000). And of course our firewall block all the ports except 8001.
    So, is that the expect behaviour? If that is true then RMI is not functional under NAT/Firewall.
    Am I missing something?
    Thanks!!
    Gerardo

    Hello,
    Let me see if I got it right:
    1. You're starting the registry (programatically) in port 8001.
    2. You're creating a server implementation object.
    3. Next you bind/rebind your server to this registry.
    4. Your client hangs at Naming.lookup().
    If this is the problem then that random port you mentioned is the server's attributed port (a ServerSocket that is hanging on accept) at the time of creation. You can avoid this by instead of using the super() call in you serverimpl constructor using the UnicastRemoteObject constructor that specifies a port (check the interface). That way you can configure your firewall to allow traffic through that port too.
    However, what puzzles me is the fact that it hangs on step 4 instead of in a subsequent remote call. step 4 should be using port 8001. Can you confirm that it's hanging in Naming.lookup ?
    (two other sources of data you may find usefull are the Firewall logs and a tcpdump analisys of the traffic between the firewall and the server machine)
    Nuno

  • RMI Startup Problem

    Hello:
    We have installed Ptg 1.0.2.2.0 in a Solaris machine with Solaris 2.7. All things seem to be right, but we have a problem with the RMI server that appears in /tmp/sys_panama.log.
    Why don4t it find the ServerImpl_Stub class?
    It finds the ServerImpl class, that it stored in the same "zip" file.
    Any idea?
    Thanks in advance.
    Javier Sanchez
    9/26/00 7:29:39 PM ERROR : [RMI Daemon] core.rmi.server.ServerImpl.run(ServerImpl.java:108) java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: java.lang.ClassNotFoundException: oracle.panama.core.rmi.server.ServerImpl_Stub java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:java.lang.ClassNotFoundException:oracle.panama.core.rmi.server.ServerImpl_Stub java.lang.ClassNotFoundException:oracle.panama.core.rmi.server.ServerImpl_Stub at java.lang.Throwable.fillInStackTrace(Native M
    ethod)at java.lang.Throwable.fillInStackTrace(Compiled
    Code) at sun.rmi.transport.StreamRemoteCall.exceptionR
    eceivedFromServer(Compiled Code)
    at sun.rmi.transport.StreamRemoteCall.executeCal
    l(StreamRemoteCall.java:223) at sun.rmi.server.UnicastRef.invoke(UnicastRef.j
    ava:342) at sun.rmi.registry.RegistryImpl_Stub.rebind(Unk
    nown Source) at oracle.panama.core.rmi.server.ServerImpl.run(
    ServerImpl.java:105) at java.lang.Thread.run(Thread.java:485)

    Thanks for your concern.
    I got the following message after starting the rmi registry and running the server using the command:
    java LoanServerImpl
    java.rmi.ConnectException: Connection refused to host: 10.2.0.4; nested exception is:
    java.net.ConnectException: Connection refused: connect

  • 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!

  • Java.rmi.ServerException Problem

    The exception that has occured is java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
    java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
    java.lang.ClassNotFoundException: Process00Impl_Stub
    I have the interface, Client, Server and the Implementation java files
    in the same machine.
    11/29/2002 08:52p 282 Process00.class
    11/29/2002 08:25p 221 Process00.java
    11/29/2002 07:40p 215 Process00.java.bak
    11/29/2002 08:56p 1,008 Process00Client.java
    11/29/2002 08:55p 1,010 Process00Client.java.bak
    11/29/2002 08:57p 451 Process00Impl.class
    11/29/2002 08:57p 936 Process00Impl.java
    11/29/2002 08:52p 934 Process00Impl.java.bak
    11/29/2002 08:57p 2,153 Process00Impl_Skel.class
    11/29/2002 08:57p 3,938 Process00Impl_Stub.class
    11/29/2002 08:56p 995 Process00Server.class
    11/29/2002 08:57p 645 Process00Server.java
    11/29/2002 08:56p 643 Process00Server.java.bak
    I also have the _Stub.class. I do not know why I get this error. If any
    one have an idea, kindly share with me.
    Thanks.

    Hi,
    I had the same problem. In my machine, path was having jre1.1.7 before my jdk 1.4. So it was picking up from jre1.1.7.
    Java was happy when I moved my jdk1.4 path to the beginning of the path variable.
    Hope this helps you.

  • RMI SSL problem

    Hi, I am learning RMI whit SSL and I have a problem, I cant run the example form the RMI SSL tutorials.
    I can run the server, and bind the object but the client throw this exception:
    HelloClient exception: error during JRMP connection establishment; nested exception is:
    javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is:
    javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:274)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171)
    at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:306)
    at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
    at HelloClient.main(HelloClient.java:60)...
    can you help me???

    Hi,
    Dis you solved the probelm ? I am facing the similar exception. I am using jre1.5.0_11.
    Regards,
    Titas Mutsuddy

  • 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 compliation problem

    when i try to compile my server i get the following errors
    D:\JAVA_P~1\SIMPLE~1>javac -classpath . PhoneDirServer.java
    PhoneDirServer.java:6: package PhoneDirectory does not exist
    import PhoneDirectory.PhoneDirImpl;
    ^
    .\PhoneDirImpl.java:34: class, interface, or enum expected
    ^
    .\PhoneDirImpl.java:12: cannot find symbol
    symbol: class PhoneDirInterface
    implements PhoneDirInterface {
    ^
    PhoneDirServer.java:29: cannot access PhoneDirImpl
    bad class file: .\PhoneDirImpl.java
    file does not contain class PhoneDirImpl
    Please remove or make sure it appears in the correct subdirectory of the classpa
    th.
    PhoneDirImpl myObject = new PhoneDirImpl();
    ^
    4 errors
    here is my server code
    import java.util.Properties;
    import javax.naming.InitialContext;
    import javax.rmi.PortableRemoteObject;
    import PhoneDirectory.PhoneDirImpl;
    * Creates a Server and binds the RMI Servant with the IIOP Registry
    public class PhoneDirServer {
      static final String CONTEXT_NAME = "java.naming.factory.initial";
      static final String IIOP_STRING  = "com.sun.jndi.cosnaming.CNCtxFactory";
      static final String URL_NAME = "java.naming.provider.url";
      static final String IIOP_URL_STRING  = "iiop://localhost:1000";
       * Entry Point to this application
      public static void main(String[] args) {
        try {
          // Create the Object
          PhoneDirImpl myObject = new PhoneDirImpl();
          // Create the IIOP Initial Context
          Properties iiopProperties = new Properties();
          iiopProperties.put( PhoneDirServer.CONTEXT_NAME,
                              PhoneDirServer.IIOP_STRING );
          iiopProperties.put( PhoneDirServer.URL_NAME,
                              PhoneDirServer.IIOP_URL_STRING );
          InitialContext iiopContext = new InitialContext( iiopProperties );
          // Bind the object to the IIOP registry
          iiopContext.rebind( "Phone Directory", myObject );
          System.out.println( "Hello from server, ready for action..." );
        catch ( Exception exception ) {
          exception.printStackTrace ();
    }they are all in the same directory ..
    PhoneDirImpl.java
    PhoneDirInterface.java
    PhoneDirServer.java

    sorry the code is
    import java.rmi.*;
    import java.rmi.server.*;
    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.util.HashMap;
    import java.util.Map;
    public class PhoneDirServer extends UnicastRemoteObject
    implements PhoneDirInterface {
    private Map pbMap = new HashMap();
        public PhoneDirServer () throws RemoteException
            super();
    try {     
              BufferedReader br = new BufferedReader(new FileReader("numbers.txt"));     
              String line;     
              while ((line = br.readLine()) != null)
                   String[] info = line.split(":", 2);       
                   pbMap.put(info[0], info[1]);    
              catch (Exception exc) {       
             exc.printStackTrace();       
              System.exit(1);    }
    public String getPhoneNumber(String name) {   
              return (String) pbMap.get(name);  } 
    public boolean addPhoneNumber(String name, String num) {  
              if (pbMap.containsKey(name)) return false;   
              pbMap.put(name, num);    return true;  }       
    public boolean replacePhoneNumber(String name, String num) {   
              if (!pbMap.containsKey(name)) return false;   
              pbMap.put(name, num);    return true; 
        public static void main ( String args[] ) throws Exception
            // Assign a security manager, in the event that dynamic
         // classes are loaded
            if (System.getSecurityManager() == null)
                System.setSecurityManager ( new RMISecurityManager() );
            // Create an instance of our service server ...
            PhoneDirServer server = new PhoneDirServer();
            // ... and bind it with the RMI Registry
            Naming.bind ("PhoneBook",server);
            System.out.println ("Service bound....");
    }and the interface is
    import java.rmi.Remote;
    import java.rmi.RemoteException;
    * This is an interface to a component that looks up
    public interface PhoneDirInterface extends Remote {
      public String getPhoneNumber(String name) throws RemoteException;
      public boolean addPhoneNumber(String name, String num) throws RemoteException;
      public boolean replacePhoneNumber(String name, String num)throws RemoteException;
    }

  • RMI connectivity problem (multi-NIC)

    I'm developing a simple photo share program with Java RMI.
    I connect rmiregistry (192.168.100.3), it returns the object reference, but when I invoke a method I get problems.
    My server (remote) - 192.168.100.3 - reply with an address of another NIC - 192.168.62.1 (from VMware). I print out the Proxy object, and I was surprised when I saw 192.167.62.1 address, instead 192.168.100.3. My client is running on 192.168.100.1 address.
    Why is this happening?
    When I turned off the VMware virtual NICs, I was successful. I want to understand what is going on, and if is there a way to fix this issue.
    $ java rmi.Client
    Looking...object found!
    Proxy[PhotoShare,RemoteObjectInvocationHandler[UnicastRef [liveRef: [endpoint:[192.168.62.1:58343](remote),objID:[4cc5973e:11de2bb065b:-7fff, 4037313925566802436]]]]]
    Exception in thread "main" java.rmi.ConnectIOException: Exception creating connection to: 192.168.62.1; nested exception is:
         java.net.SocketException: Network is unreachable
         at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:614)
         at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
         at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
         at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:110)
         at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:178)
         at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132)
         at $Proxy0.listaFotos(Unknown Source)
         at rmi.Client.main(Client.java:26)
    Caused by: java.net.SocketException: Network is unreachable
         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:519)
         at java.net.Socket.connect(Socket.java:469)
         at java.net.Socket.<init>(Socket.java:366)
         at java.net.Socket.<init>(Socket.java:180)
         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:595)
         ... 7 moreEdited by: pantony on Nov 28, 2008 3:26 AM
    Edited by: pantony on Nov 28, 2008 3:27 AM

    See item A.1 of the [RMI FAQ|http://java.sun.com/j2se/1.5.0/docs/guide/rmi/faq.html].

Maybe you are looking for

  • Type def boolean button.

    hi, i'm korean. my english is it' too bad. that why i'm sorry. first i wanna make type def boolean button. it's not problem. but make triangle shape. happen problem. like that red box is notihing. but if i click there, that is change to true or false

  • How do i set up a second ipad with the same apple id

    I bought two new iPad 2 's for my office.  They are for patient self check-in and I would like to set them both up with the same apple ID.  How do I go about setting the second iPad up once I finished setting up the first one? Thanks!

  • Customising the button widget

    Hi I would like to include the navigation options on all my slides to give the user control of the presentation, from reading other posts, the best way to do this seems to be to include the button widget on the master slide. I have looked at insertin

  • Run report using command utility

    Hi All, I am working on OBIEE 11.1.1.6.0. can it is possible, Using command utility, we can run obiee report, and it's output should be any format other than text. and also this report schedule on hr basis, without using delivers. if this possible, t

  • HT4623 when i update my iphone 3g 4.1 to 4.2 it is hanging and not working now

    tell me plzz what m i do now now i m so confused that what shoul i do now?