Working of rmi

in real times how rmi will works?why objects of one jvm can't be used by another jvm?how these objects will be placed?

in real times how rmi will works?Over TCP/IP.
why objects of one jvm can't be used by another jvm?How do you suggest this would work? other than via an RMI system?
how these objects will be placed?I do not understand.

Similar Messages

  • Enums don't work over RMI-IIOP

    Enums do not deserialize correctly so that MyEnum.ONE.equals(deserializedMyEnum);
    See for yourself.
    import java.rmi.*;
    import java.util.*;
    import javax.rmi.*;
    import javax.naming.*;
    enum MyEnum { ONE, TWO, THREE };
    public class EnumIIOPBreakage
      public static void main(String[] args)
        throws Throwable
        Hashtable properties = new Hashtable();
        properties.put("java.naming.factory.initial",
                       "com.sun.jndi.cosnaming.CNCtxFactory");
        properties.put("java.naming.provider.url", "iiop://localhost:1099");
        new Server(properties);
        Context context = new InitialContext(properties);
        Object ref = context.lookup("server");
        RServer server = (RServer) PortableRemoteObject.narrow(ref, RServer.class);
        System.out.println("equal?         " +
                           MyEnum.ONE.equals(server.get(MyEnum.ONE.name())));
        System.out.println("classes equal? " +
                           MyEnum.ONE.getClass().equals(
                               server.get(MyEnum.ONE.name()).getClass()));
        System.out.println("names equal?   " +
                           MyEnum.ONE.name().equals(
                               server.get(MyEnum.ONE.name()).name()));
    class Server
      implements RServer
      public Server(Hashtable properties)
        throws Throwable
        PortableRemoteObject.exportObject(this);
        Context context = new InitialContext(properties);
        context.rebind("server", this);
      public MyEnum get(String name)
        return MyEnum.valueOf(name);
    interface RServer
      extends Remote
      MyEnum get(String name)
        throws RemoteException;
    }

    Hi drsharmadinesh
    Which Wireless Service Provider SIM you're using ! 
    Please Check those Knowledge Base regarding your issue , and see if you are missing something :
    KB13368 :Services that are available over a Wi-Fi connection
    KB17659 : Minimum requirement for BlackBerry App World.
    You must have some sort of data plan which include internet browsing from your wireless service provider to use and access BlackBerry World without any interruption .
    Click " Like " if you want to Thank someone.
    If Problem Resolves mark the post(s) as " Solution ", so that other can make use of it.

  • Urgent Help Required For Starting RMI server from servlet.

    I am currently working on rmi project.
    I want to send request to remote machine(Web host) where my application is from desktop client .For that we are using RMI.
    I am writing servlet and inside it i am binding object to registry for rmi server.
    which will be deployed on remote server.
    code ....
    Registry reg;
    reg=LocateRegistry.createRegistry(1099);
    Server server=new Server("server");//class whose remote object to be accessed
    //extends unicast remote object.Implement ServerInt interface which extends Remote.
    reg.bind("server",server);
    When i am trying to access this object i am getting following exception.
    javax.naming.CommunicationException [Root exception is java.rmi.UnmarshalExcepti
    on: error unmarshalling return; nested exception is:
            java.lang.ClassNotFoundException: ServerModule.ServerInt]
    at com.sun.jndi.rmi.registry.RegistryContext.lookup(Unknown Source)
    at com.sun.jndi.toolkit.url.GenericURLContext.lookup(Unknown Source)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at RequstReplication.main(RequstReplication.java:27)
    Caused by: java.rmi.UnmarshalException: error unmarshalling return; nested excep
    tion is:
    java.lang.ClassNotFoundException: ServerModule.ServerInt
    at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
    ... 4 more
    Caused by: java.lang.ClassNotFoundException: ServerModule.ServerInt
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at sun.rmi.server.LoaderHandler.loadProxyInterfaces(Unknown Source)
    at sun.rmi.server.LoaderHandler.loadProxyClass(Unknown Source)
    at sun.rmi.server.LoaderHandler.loadProxyClass(Unknown Source)
    at java.rmi.server.RMIClassLoader$2.loadProxyClass(Unknown Source)
    at java.rmi.server.RMIClassLoader.loadProxyClass(Unknown Source)
    at sun.rmi.server.MarshalInputStream.resolveProxyClass(Unknown Source)
    at java.io.ObjectInputStream.readProxyDesc(Unknown Source)
    at java.io.ObjectInputStream.readClassDesc(Unknown Source)
    at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
    at java.io.ObjectInputStream.readObject0(Unknown Source)
    at java.io.ObjectInputStream.readObject(Unknown Source)
    ... 5 more
    I can access naming enumeration of registry and object bound to it.
    by following program.I shows corect objects.
    Context namingContext=new InitialContext();
    NamingEnumeration<NameClassPair> e=namingContext.list("rmi:");
    while(e.hasMore())
    System.out.println(e.next().getName());
    While when i start RMI server from simple java program i can access these objects from registry.
    I am not getting what is problem problem.Is there any other way to send request?
    Plese give quick response.

    I am currently working on rmi project.
    I want to send request to remote machine(Web host) where my application is from desktop client .For that we are using RMI.
    I am writing servlet and inside it i am binding object to registry for rmi server.
    which will be deployed on remote server.
    code ....
    Registry reg;
    reg=LocateRegistry.createRegistry(1099);
    Server server=new Server("server");//class whose remote object to be accessed
    //extends unicast remote object.Implement ServerInt interface which extends Remote.
    reg.bind("server",server);
    When i am trying to access this object i am getting following exception.
    javax.naming.CommunicationException [Root exception is java.rmi.UnmarshalExcepti
    on: error unmarshalling return; nested exception is:
            java.lang.ClassNotFoundException: ServerModule.ServerInt]
    at com.sun.jndi.rmi.registry.RegistryContext.lookup(Unknown Source)
    at com.sun.jndi.toolkit.url.GenericURLContext.lookup(Unknown Source)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at RequstReplication.main(RequstReplication.java:27)
    Caused by: java.rmi.UnmarshalException: error unmarshalling return; nested excep
    tion is:
    java.lang.ClassNotFoundException: ServerModule.ServerInt
    at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
    ... 4 more
    Caused by: java.lang.ClassNotFoundException: ServerModule.ServerInt
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at sun.rmi.server.LoaderHandler.loadProxyInterfaces(Unknown Source)
    at sun.rmi.server.LoaderHandler.loadProxyClass(Unknown Source)
    at sun.rmi.server.LoaderHandler.loadProxyClass(Unknown Source)
    at java.rmi.server.RMIClassLoader$2.loadProxyClass(Unknown Source)
    at java.rmi.server.RMIClassLoader.loadProxyClass(Unknown Source)
    at sun.rmi.server.MarshalInputStream.resolveProxyClass(Unknown Source)
    at java.io.ObjectInputStream.readProxyDesc(Unknown Source)
    at java.io.ObjectInputStream.readClassDesc(Unknown Source)
    at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
    at java.io.ObjectInputStream.readObject0(Unknown Source)
    at java.io.ObjectInputStream.readObject(Unknown Source)
    ... 5 more
    I can access naming enumeration of registry and object bound to it.
    by following program.I shows corect objects.
    Context namingContext=new InitialContext();
    NamingEnumeration<NameClassPair> e=namingContext.list("rmi:");
    while(e.hasMore())
    System.out.println(e.next().getName());
    While when i start RMI server from simple java program i can access these objects from registry.
    I am not getting what is problem problem.Is there any other way to send request?
    Plese give quick response.

  • Please help: RMI and Swing/AWT issue

    Hi guys, I've been having a lot of trouble trying to get a GUI application to work with RMI. I'd appreciate any help. Here's the story:
    I wrote a Java application and its GUI using Netbeans. In a nutshell, the application is about performing searches. I am now at the point where I need exterior programs to use my application's search capabilities, thus needing RMI. Such exterior programs are to call methods currently implemented in my application.
    I implemented RMI, and got the client --> server communication working. However, the GUI just breaks. It starts outputting exceptions, gets delayed, doesn't update properly, some parts of it stop working.... basically hysterical behavior.
    Now take a look at this line within my server class:
    Naming.rebind("SearchProgram", mySearchProgram);
    If I take it out, RMI obviously does not work... but the application and its GUI work flawlessly. If I put it in, the RMI calls work, but the GUI's above symptoms occur again. Among the symptoms are null pointer exceptions which all look similar, are related to "AWT-EventQueue-0", and keep ocurring. Here's just snippet of the errors outputted:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at javax.swing.plaf.metal.MetalScrollBarUI.getPreferredSize(MetalScrollBarUI.java:102)
    at javax.swing.JComponent.getPreferredSize(JComponent.java:1615)
    at javax.swing.JScrollBar.getMinimumSize(JScrollBar.java:704)
    at javax.swing.ScrollPaneLayout.minimumLayoutSize(ScrollPaneLayout.java:624)
    at java.awt.Container.minimumSize(Container.java:1598)
    at java.awt.Container.getMinimumSize(Container.java:1583)
    at javax.swing.JComponent.getMinimumSize(JComponent.java:1697)
    at java.awt.BorderLayout.minimumLayoutSize(BorderLayout.java:634)
    at java.awt.Container.minimumSize(Container.java:1598)
    at java.awt.Container.getMinimumSize(Container.java:1583)
    at javax.swing.JComponent.getMinimumSize(JComponent.java:1697)
    at java.awt.BorderLayout.minimumLayoutSize(BorderLayout.java:634)
    at java.awt.Container.minimumSize(Container.java:1598)
    at java.awt.Container.getMinimumSize(Container.java:1583)
    at javax.swing.JComponent.getMinimumSize(JComponent.java:1697)
    at javax.swing.BoxLayout.checkRequests(BoxLayout.java:433)
    at javax.swing.BoxLayout.layoutContainer(BoxLayout.java:375)
    at java.awt.Container.layout(Container.java:1401)
    at java.awt.Container.doLayout(Container.java:1390)
    at java.awt.Container.validateTree(Container.java:1473)
    at java.awt.Container.validateTree(Container.java:1480)
    at java.awt.Container.validateTree(Container.java:1480)
    at java.awt.Container.validateTree(Container.java:1480)
    at java.awt.Container.validateTree(Container.java:1480)
    at java.awt.Container.validate(Container.java:1448)
    at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:379)
    at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:113)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at javax.swing.plaf.basic.BasicMenuItemUI.getPreferredMenuItemSize(BasicMenuItemUI.java:400)
    at javax.swing.plaf.basic.BasicMenuItemUI.getPreferredSize(BasicMenuItemUI.java:310)
    at javax.swing.JComponent.getPreferredSize(JComponent.java:1615)
    at javax.swing.BoxLayout.checkRequests(BoxLayout.java:434)
    at javax.swing.BoxLayout.preferredLayoutSize(BoxLayout.java:251)
    at javax.swing.plaf.basic.DefaultMenuLayout.preferredLayoutSize(DefaultMenuLayout.java:38)
    at java.awt.Container.preferredSize(Container.java:1558)
    at java.awt.Container.getPreferredSize(Container.java:1543)
    at javax.swing.JComponent.getPreferredSize(JComponent.java:1617)
    at javax.swing.JRootPane$RootLayout.layoutContainer(JRootPane.java:910)
    at java.awt.Container.layout(Container.java:1401)
    at java.awt.Container.doLayout(Container.java:1390)
    at java.awt.Container.validateTree(Container.java:1473)
    at java.awt.Container.validate(Container.java:1448)
    at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:379)
    at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:113)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    There are no complaints about anything within my code, it's all GUI related whenever I make a bind() or rebind() call.
    Again, any help here would be great... cause this one's just beating me.
    Thanks!

    Maybe you want to change that worker thread to
    not do RMI but anything else (dummy data) to see if it really is RMI, I doubt it, I think you are updating some structures that have to do with swing GUI and hence you will hang.
    Just check this out.

  • RMI with JDBC

    Hello,
    this is the first time that I work with RMI.
    In fact it isn't so hard.
    But I've made an interface that do the operations on my database.
    Do I also have to program a locking mechanism?
    Does anybody made such a system, or what do you recommand.
    I want to make a simpel program that uses a database on another pc.
    tnx

    Hi Twims
    Im asking if you could make me a favor... As I can see you know RMI with JDBC... And at this moment I need a client and server programs to connect to a database, execute SQL commands and retrieve information to client.
    If you could send me those programs please do it to [email protected] or [email protected]
    Thanks in advance
    ANDRES GONZALEZ

  • RMI Client on Linux issue.

    I am facing Java RMI problem on Suse Linux.
    RMI server running on solaris and RMI client running on Solaris ---> works fine
    RMI server running on solaris and RMI client running on Linux ---> gives error
    Pls note that RMI server running fine. When invoking remote method from RMI client on Suse Linux, I get following error.
    Java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
    java.lang.ClassNotFoundException: RemoteVtskImpl_Stub
    Any help/pointers will be useful.

    Even we tried setting the CLASSPATH to point to those jar files. But still the problem persist.
    At run time is there any way to see what all the _stub files are downloaded in the JVM at the client machine (linux machine in our case) from the server machine (solaris machine in our case).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • New @ RMI need help with  java.rmi.UnmarshalException: error unmarshalling

    Hi @ all out there,
    I'm new with Java RMI and have to write a EventSystem for an college project where clients can subscribe to a topic and get notified when someone publishes a message to the subscribed topic.
    At server-side I have a class called EventSystem that provides methods for subscribing and unsubscribing from topics, and also for posting messages (for publishers).
    To subscribe i thought that the client must specify the topic and also itself ( means that a client calls in this way: obj.subscribe("mytopic", this).
    The EventSystem handles a list of all clients, and whenever a new message is posted it goes trough all clients and invokes the handleMessage(String msg) method that all Clients have to provide.
    On my local machine without RMi this concept works just great.
    I now tried to get it working using RMI , but I get the following Exception when starting the client (the server starts fine) :
    Looking up for rmiregistry at 138.232.248.22:1099
    Subscriber exception:
    java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
            java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
            java.io.InvalidClassException: SubscriberImpl; SubscriberImpl; class invalid for deserialization
            at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:336)
            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:535)
            at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
            at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
            at java.lang.Thread.run(Thread.java:619)
            at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
            at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
            at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
            at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:178)
            at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132)
            at $Proxy0.subscribe(Unknown Source)
            at SubscriberImpl.main(SubscriberImpl.java:48)
    Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
            java.io.InvalidClassException: SubscriberImpl; SubscriberImpl; class invalid for deserialization
            at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:293)
            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:535)
            at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
            at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
            at java.lang.Thread.run(Thread.java:619)
    Caused by: java.io.InvalidClassException: SubscriberImpl; SubscriberImpl; class invalid for deserialization
            at java.io.ObjectStreamClass.checkDeserialize(ObjectStreamClass.java:713)
            at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1733)
            at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
            at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
            at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:306)
            at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:290)
            ... 9 more
    Caused by: java.io.InvalidClassException: SubscriberImpl; class invalid for deserialization
            at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:587)
            at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1583)
            at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
            at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
            ... 13 moreI googled now for 2 hours but can't resolve the problem alone. As far as I can understand I have to serialize Objects that I want to send to the server, right?
    So how can i do this? I've never used serialization till now.
    any ideas how to solve this problem?
    greets from italy and sorry for my very weak english
    bd_italy

    A class has been modified after deployment. Stop the Registry, clean, recompile, and redeploy.

  • Replication on rmi server

    Hi,
    I m working on rmi client/server chat application and I would like to make my server replicated (e.g having a group of servers), so when it crashes the connection must jump to another server without losing any data and without the client noticing the crashing. I know that there are two kinds of replication (Passive/ active ) but I have no idea how to do it. Is anyone who could help me with this and give me any references(either for passive or active)?
    Thanks.
    p.s Please is important

    Note to others. This is a duplication/continuation of:
    [http://forums.sun.com/thread.jspa?threadID=5431836]

  • How to run RMI in Internet

    Hi ,
    iam running RMI server in vsnl public ipaddress like :121.*.*.*;
    when i run the client in vsnl network it is working fine.iam trying to run this in another network like airtel network it is not connecting.
    is there any solution?
    bez i need to run my application anywhere from the world in any network.

    Basically you need to download the RMI plugin from:
    http://www.genady.net/rmi/v16/main.html
    You can either get a license from them, or it only works for 14 days from the date you download the software (so if you changed your computer date....)
    You download the zip file, and put it in your eclipse directory (just follow the steps). It generates all the rmi classes for you automatically.
    I don't think it's required for working with RMI--you could probably get rmic and generate the class files yourself, the plugin just makes the process simpler, and I believe you can also monitor the registry, which is a nice feature.

  • RMI with SSH

    As I understand it, RMI listens on port 1099 and opens other ports upon a connection. This is why we have to open ports 1099 and >1023 on the server firewall. Which is great for all the users on the LAN.
    The site will only let us connect to this system through SSH (port 22). We might be able to use ssh to create a poor mans VPN to connect to RMI as in: ssh -L 1234:localhost:1099 user@remotehost. This fails to work because RMI uses more than just port 1099. If it were something like telnet, ssh -L 1234:localhost:23 user@remotehost it would just work.
    What I think I need is something running on the remote server which connects to port 1099 and listens on a port, for example, 1098. We could then connect with ssh -L 1234:localhost:1098 user@remotehost and packets would be passed to the appropriate RMI connection. Any ideas on how this could be done AND if it could work.
    **CRITICAL: I am not interested in changing the application running RMI at all. It works for everthing the end users need and don't fix it if it isn't broken. In any case, this isn't just about RMI, there are three non-RMI apps which do the same thing, so one solution would be used for all four of them.

    As I understand it, RMI listens on port 1099 and opens other ports upon a connection.No. The RMI Registry listens at port 1099 unless you tell it otherwise. Remote objects listen at system-chosen ports unless you specify a specific port when constructing/exporting them. You can use port 1099 for everything if:
    1. You create the Registry via LocateRegistry.createRegistry() in the same JVM that exports your remote objects.
    2. You cite port 1099 when constructing (super(1099)) or exporting (UnicastRemoteObject.exportObject(obj, 1099)) remote objects.
    Having done that, the only server-side port you need to be concerned with is 1099. That's a reserved IANA port number and it should be possible to get it opened in the firewall.
    And neither RMI nor TCP 'opens other ports' on inbound connections.

  • RMI server double identity

    I have 2 PC in a small LAN, both with Windows XP professional.
    The machine acting as server has 2 IP adresses: the first one, static, from a permanent ADSL connection (213.155...), the second one from the LAN ethernet connection (192.168.0.1).
    The machine acting as client is a notebook, which sometimes is linked to the LAN with an ethernet connection, and sometimes is directly connected to the WAN by modem connection.
    Well, in the first case (LAN) RMI dialog works fine.
    But in the second case (direct modem connection to WAN), things don't work.
    RMI client tries to contatct the server using it's WAN IP addess (213.155..), and after a while it gets a time-out exception for connection to node 192.168.0.1 (i.e. the LAN server IP address, currently unused).
    Why does the RMI server, receiving a connection request on it's WAN address, try to assume the alternate LAN identity ?

    I've found the solution.
    The problem can be avoided inserting in the server application a statement like this:
    System.setProperty("java.rmi.server.hostname", <WAN IP address>);
    before binding the Implementation class in registry.
    Hope this will help somebody.
    Luigi Fonti

  • Accessing codebase through http (RMI)

    Hi
    I am C prgrammer and now badly stuck wid my new found luv- java!
    I am working on RMI, where I have a simple client program, sending Hi, Hellos to my server program. Then I created a new class in my rmi client side and tried to send it through the interface to the server. Server gave unmarshelling errors.. which i guess is bcoz it doesnt know about the classes in client side. I follwed similar threads here, and could make out that i must specify a codebase visible to the server where it can see the client files..
    I created a policy file in the server as this-
    grant codeBase "file:/E:/work/java/"{
    permission java.security.AllPermission;
    permission java.net.SocketPermssion "*","accept,connect,resolve";
    My client fils are in E:/work/java ...
    I am getting errors in server side--
    Exception in thread "RMI TCP Connection(1)-127.0.0.1" java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:2014 accept,resolve)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
    and client says--
    java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
    java.io.EOFException
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:203)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:343)
    at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
    at rmi.client.RmiClient.main(RmiClient.java:33)
    Caused by: java.io.EOFException
    i know I have done a blunder there.. I also followed from prev threads that I have to specify the codebase as a URL, but again I dont know how to make my client files accessilbe through http ? my files are in say E:/work/java/client directory.... how to access this through URL?
    also i tried this on linux where my files are in root/client/ ..
    Can you java Gurus help me in solving this, in both the windows and linux versions..
    Your help is gr8ly anticipated
    thankssss

    Thanks..
    But the thing is if I specify my policy file as
    grant { 
    permission java.security.AllPermission;
    permission java.net.SocketPermission "*","accept,connect,resolve";
    I can send simple messages from client to server..
    But when i try to put the code base as
    grant codeBase "file:///E:/client/"{
    permission java.security.AllPermission;
    permission java.net.SocketPermission "*","accept,connect,resolve";
    It always gives the error
    Exception in thread "main" java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:3232 connect,resolve)
         at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
         at java.security.AccessController.checkPermission(AccessController.java:427)
         at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
         at java.lang.SecurityManager.checkConnect(SecurityManager.java:1034)
         at java.net.Socket.connect(Socket.java:513)
    Can you tell me what am i missing...?
    My server code looks like this-
    public static void main(String args[])
    try{
         System.setProperty("java.security.policy", "E:\\work\\java\\client\\x.policy");
         if (System.getSecurityManager()==null){
    System.setSecurityManager(new RMISecurityManager());
    Thankss

  • Accessing codebase through http in RMI

    Hi
    I am C prgrammer and now badly stuck wid my new found luv- java!
    I am working on RMI, where I have a simple client program, sending Hi, Hellos to my server program. Then I created a new class in my rmi client side and tried to send it through the interface to the server. Server gave unmarshelling errors.. which i guess is bcoz it doesnt know about the classes in client side. I follwed similar threads here, and could make out that i must specify a codebase visible to the server where it can see the client files..
    I created a policy file in the server as this-
    grant codeBase "file:/E:/work/java/"{
    permission java.security.AllPermission;
    permission java.net.SocketPermssion "*","accept,connect,resolve";
    My client fils are in E:/work/java ...
    I am getting errors in server side--
    Exception in thread "RMI TCP Connection(1)-127.0.0.1" java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:2014 accept,resolve)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
    and client says--
    java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
    java.io.EOFException
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:203)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:343)
    at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
    at rmi.client.RmiClient.main(RmiClient.java:33)
    Caused by: java.io.EOFException
    i know I have done a blunder there.. I also followed from prev threads that I have to specify the codebase as a URL, but again I dont know how to make my client files accessilbe through http ? my files are in say E:/work/java/client directory.... how to access this through URL?
    also i tried this on linux where my files are in root/client/ ..
    Can you java Gurus help me in solving this, in both the windows and linux versions..
    Your help is gr8ly anticipated
    thankssss

    Any time you see this:
    java.security.AccessControlException: access denied (XXX)for any XXX you need to add the permission XXX inside the brackets to your security .policy file. The syntax required is similar but not identical - read the Javadocs.

  • RMI Exception Propagation

    I have a distributed app implemented in RMI. Sometimes when a client invokes a function on the server using the API provided, and the function call results in an exception (NullPointer, ArrayOutOfBounds etc) the exception is propagated all the way to the client even if the client is only catching RemoteException.
    Here's what I want to do:
    Have only User-defined exceptions propagated to the client. All other exceptions, should remain at the server level where I can handle them (log them, send an alert out etc). The API has hundreds of functions and I do not like the idea of putting try/catch in all of the functions in my *Impl classes. Is there an easier way to do this? Can someone explain how exception propagation works in RMI? Can I somehow propagate only UDF exceptions to the client and have the rest stay at the server even if the client uses try{...} catch(Exception e} ?
    I have googled this issue a lot of times and have failed to find an answer to this.
    I appreciate any help at all!
    Thanks.

    Here's what I want to do:
    Have only User-defined exceptions propagated to the
    client. All other exceptions, should remain at the
    server level where I can handle them (log them, send
    an alert out etc). The API has hundreds of functions
    and I do not like the idea of putting try/catch in
    all of the functions in my *Impl classes. Is there an
    easier way to do this? Can someone explain how
    exception propagation works in RMI? Can I somehow
    propagate only UDF exceptions to the client and have
    the rest stay at the server even if the client uses
    try{...} catch(Exception e} ?Exception propagation in RMI works just as you have experienced it. Any RuntimeException, Error, RemoteException, or declared exception that happens inside the server method is propagated to the client. You can't change this. I agree with cajo's idea of using a proxy around the stub to filter for you, but this will still mean that exceptions are logged &c at the client rather than at the server. You can watch & log exceptions at the server via sun.rmi.server.stackTrace=true.

  • RMI Excpetion

    Hi guys, I already works with RMI another times, but I don't know why the program is not working properly.
    I have a very simple program and I am trying to start and test the rmi server object, but when I try to do the Naming.bind the follow exception is throws:
    java.rmi.ServerException: Server RemoteException; nested exception is:
    java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
    java.lang.ClassNotFoundException: StockControlServerInterfaceImpl_Stub
    at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:343)
    at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
    at java.rmi.Naming.rebind(Naming.java:160)
    at TestClass.main(TestClass.java:23)
    Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
    java.lang.ClassNotFoundException: StockControlServerInterfaceImpl_Stub
    Caused by: java.lang.ClassNotFoundException: StockControlServerInterfaceImpl_Stub
    ps: I am sure it my interface extends Remote and my server exnteds UnicastRemoteObject, and I am sure that my stub class was generated using rmic compiler and it is in the same path at the "main" method.
    Someone know how to fix it?!!? Thanks
    Thanks

    Hi guys, I am here again, I was reading another posts and try to find a solution for this problem but this is really complicated. Here is my source code
    try{
                System.out.println("Starting the StockControlServerInterface...");
                StockControlServerInterfaceImpl stockControlServer = new StockControlServerInterfaceImpl();
                Naming.rebind("//localhost/Stock", stockControlServer);
                System.out.println("StockControlServerInterface was up and running.");           
            }//end try
            //catch(ClassNotFoundException cnfe){
            //    cnfe.printStackTrace();
            //}//end catch
            catch(RemoteException re){
                re.printStackTrace();
            }//End catch       
            catch(MalformedURLException mue){
                mue.printStackTrace();
            }//end catchI get the error when try to rebind/bind the server. I already try everything, use the java.rmi.server.codebase set the directory on CLASSPATH, start the rmiregistry at the same dir but NOTHING works, please HELP!!!!

Maybe you are looking for