Binding RMI-IIOP Remote Object in RMI Registry through JNDI

hi friends
I am writing RMI-IIOP Remote Object, both server program, and client program
are java programs. Through JNDI (with cosnaming name service), my program is working.
But what i want is, I want to use JNDI (with rmi registry name service) for my RMI-IIOP Remote Object ( and not RMI -JRMP Remote Object). Both my server
program and client programs are java(and not corba)
I am not getting this, while starting server its showing some error
Is it not possible to bind rmi-iiop remote object in rmi registry through jndi, why

because you are supposed to use the COSNaming service with IIOP. Even if you could bind an IIOP remote object into an RMIRegistry the clients wouldn't be able to use it because the RMI Registry doesn't do the extra processing that the COSNaming service does with IIOP references.

Similar Messages

  • Java.lang.ClassCastException: Cannot narrow remote object weblogic.rmi.inte

    Hi,
    I am trying to deploy ejb3.0 on weblogic 10 server. I am able to find the JNDI name of the stateless session bean correctly, but getting an exception while narrowing it down. My ejb3.0 client is a standalone java client. I am trying to access the stateless session ejb3.0 bean.Please help me. i have been trying it for many days.
    thanks in advance,
    Sanjeev
    [sanpraka@localhost certEjb]$ java -cp ./:/usr/weblogic/bea/wlserver_10.0/server/lib/weblogic.jar:/usr/weblogic/bea/wlserver_10.0/server/lib/wlclient.jar com.titan.clients.Client
    Object is weblogic.rmi.internal.BasicRemoteRef - hostID: '5337880647112897730S:127.0.0.1:[7001,7001,-1,-1,-1,-1,-1]:wl_server:examplesServer', oid: '302', channel: 'null'
    java.lang.ClassCastException: Cannot narrow remote object weblogic.rmi.internal.BasicRemoteRef - hostID: '5337880647112897730S:127.0.0.1:[7001,7001,-1,-1,-1,-1,-1]:wl_server:examplesServer', oid: '302', channel: 'null' to com.titan.travelagent.TravelAgentRemote
    at weblogic.corba.server.naming.ReferenceHelperImpl.narrow(ReferenceHelperImpl.java:206)
    at weblogic.rmi.extensions.PortableRemoteObject.narrow(PortableRemoteObject.java:88)
    at weblogic.iiop.PortableRemoteObjectDelegateImpl.narrow(PortableRemoteObjectDelegateImpl.java:32)
    at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
    at com.titan.clients.Client.main(Client.java:24)
    [sanpraka@localhost certEjb]$

    We have a similar problem. We have a web application (on server A) that invokes an EJB on a remote server (server B). This works fine, until we deploy another web application to server A at which point the existing web application starts to throw java.lang.ClassCastException when narrowing the remote EJB interface. The exception starts to be thrown at the moment the latter web application is deployed - start is not required.
    The latter web application contains (actually in APP-INF/lib) the old version of the EJB remote interface, that somehow gets to be loaded into the classpath of the existing web application. The solution is to delete the old version of the EJB remote interface from APP-INF/lib of the latter web application (we didn't need it anyway), but it would be interesting to know in which circumstances classes can get mixed between enterprise applications.
    I failed to reproduce the error in simple scenario, so this does not happen always.

  • ClassCastException ; javax.rmi.Portable.Remote.Object. narrow(Unknown Sour

    Hi Guys,
    This is my First post, I am in a deep trouble with the following exception. Initially I was getting
    javax.naming.NoInitialContextException:
    Need to specify class name in
    environment or system property, or as an applet parameter
    I added few lines of code in the .java file. and set the classpath to j2ee.jar
    Hashtable env = new Hashtable();
    env.putContext.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
    env.put(Context.PROVIDER_URL, "iiop://localhost:3700");
    Context initctx = new InitialContext(env);
    I was able to get through that error. But then now i am stuck up with the new runtime error .
    java.lang.ClassCastException
    at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(Unknown Source)
    at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
    at AdviceClient.go(AdviceClient.java:24)
    at AdviceClient.main(AdviceClient.java:11)
    I have tried to figure out myself but with little vain. I am using
    Sun One App Server( j2sdkee 1.4 ) with Windows XP.
    I am waiting for a positive response.
    I am pasting the code of my Client
    AdviceClient.java
    import javax.naming.* ;
    import java.rmi.* ;
    import javax.rmi.* ;
    import HeadFirst.* ;
    import javax.ejb.* ;
    public class AdviceClient {
    public static void main( String[] args ) {
    new AdviceClient( ).go( ) ;
    public void go( ) {
    try {
    Hashtable env = new Hashtable();
    env.putContext.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
    env.put(Context.PROVIDER_URL, "iiop://localhost:3700");
    Context initctx = new InitialContext(env);
    Object o = ic.lookup("Advisor") ;
    AdviceHome home = ( AdviceHome ) javax.rmi.PortableRemoteObject.narrow( o, HeadFirst.AdviceHome.class ) ;
    Advice advisor = (Advice )home.create( ) ;
         System.out.println(advisor.getTheMessage( ) ) ;
    } catch( Exception ex ) {
         ex.printStackTrace( );
    I am starting the default server and deploying the session Stateless beans.

    Hi Shivakanth,
    Please follow the guidelines in our EJB FAQ for writing a stand-alone java cilent that accesses ejbs :
    https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html
    --ken                                                                                                                                                                                                                                                                                                                                                                               

  • Error when pass remote object in RMI

    I am using RMI, I have implemented a server, this server provide a method to return back a Database object, client use this Database to manipulate database, the Database extends UnicastRemoteObject. in client code, I use a variable to hold the returned reference, the code is like: database = server.register(), but here I got an error like this:
    java.lang.ClassCastException: njproducts.server.DatabaseProxy_Stub
    at njproducts.server.ServerImpl_Stub.register(Unknown Source)
    at njproducts.client.DatabaseAdapter.<init>(DatabaseAdapter.java:54)
    at njproducts.client.MainFrame.main(FBNFrame.java:162)
    is there somebody can help me on this?

    Not without you psoting some code.
    Possible problem: Difference between object type being returned, vs the type of the reference (i.e., the method that returns an object should have a return type of the interface name).

  • RMI-IIOP Example for Java SE 6

    Hi.
    Can someone provide me an example (link or code) of how to write an RMI-IIOP remote object, bind it to jndi (glassfish) and then call it from within the glassfish application server (I'm calling from an EJB).
    The guide available at http://java.sun.com/javase/6/docs/technotes/guides/rmi-iiop/tutorial.html is unfortunately not helpful because it the code there does not work when binding the remote object in glassfish JNDI (using empty InitialContext constructor) as opposed to the orbd daemon that is described in the guide.
    Am I not allowed to bind RMI-IIOP objects in glassfish application server JNDI, i.e. do I have to use orbd?
    Do you have to generate stubs for the remote objects in Java SE6? The tutorial says to do it but the exception I get on glassfish application server is not from the _<interface-name>Stub.java but rather from <interface-name>_DynamicStub.java.
    Any help is greatly appreciated!

    Are you trying to create an RMI-IIOP server inside an
    Application Server (Glassfish)?I'm not really sure about how it all works but I don't think so. I am exporting my Remote objects (using PortableRemoteObject) from a standalone Java SE client app. Relating this to normal RMI I had assumed that this automatically started an RMI-IIOP server on an anonomous port, although I now see that the javadoc says that the export method only "Makes a server object ready to receive remote calls.", whatever that means. So if calling the export method doesn't start an RMI-IIOP server then I'm guessing I would have to start one, and then yes, if possible, I would like to do it in glassfish and avoid starting up more applications.
    I am guessing I am missing something fundamental here..
    The tutorial uses the JNDI Registry (tnameserv). (and
    it works fine)Is that what is automatically started when glassfish application server is started?
    Have you looked into using a Portable Object Adapter?No, I have not. I want to keep it as simple and close to regular RMI though, so if possible I would like to avoid POA.

  • Screwey rmi-iiop behavior

    I got the rmi-iiop example code to work just fine, but I tried extending
    it a little and strangeness ensues. Here's what I did:
    I'm using a stock weblogic 6.0 install on solaris 8 (sparc). I added
    the following new method to the Trader interface:
    public void func(javax.naming.Name n) throws RemoteException;
    and I added the implementation of that method to TraderBean like so:
    public void func(javax.naming.Name n) {
    System.out.prinltn("n [" + n + "]");
    I then added a call to the new Trader function to the end of the
    example() method in Client, just before the trader is removed:
    try {
    com.sun.jndi.ldap.LdapName lname =
    new com.sun.jndi.ldap.LdapName("a=b");
    trader.func(lname);
    } catch (javax.naming.NamingException ne) {
    ne.printStackTrace();
    Then I compiled everything using the supplied build.sh, copied the
    ejb_over_iiop.jar into config/mydomain/applications, and ran
    startWebLogic.sh int the config/mydomain directory to start the server.
    I then run the client like so (using the 1.3 java version included with
    weblogic 6.0):
    java -cp
    /opt/bea/wlserver6.0/config/examples/clientclasses:/opt/bea/wlserver6.0/config/mydomain/applications:/opt/bea/wlserver6.0/lib/weblogic.jar
    examples.rmi_iiop.ejb.rmi_iiop.Client iiop://localhost:7001
    And I get the following output:
    Beginning statelessSession.Client...
    Creating a trader
    Buying 100 shares of BEAS.
    Buying 200 shares of MSFT.
    Buying 300 shares of AMZN.
    Buying 400 shares of HWP.
    Selling 100 shares of BEAS.
    Selling 200 shares of MSFT.
    Selling 300 shares of AMZN.
    Selling 400 shares of HWP.
    There was an exception while creating and using the Trader.
    This indicates that there was a problem communicating with the server:
    java.rmi.RemoteException: CORBA UNKNOWN 0 No; nested exception is:
    org.omg.CORBA.UNKNOWN: minor code: 0 completed: No
    End statelessSession.Client...
    Basically the call to the new method fails, and the server communication
    error it produces doesn't provide much information. So question #1 is,
    what's going on here?
    And here's the really weird part: if I change the method signatures in
    Trader and TraderBean so that the argument type is the concrete class
    com.sun.jndi.ldap.LdapName instead of the interface javax.naming.Name
    (which does extend java.io.Serializable, incidentally), it works fine!
    I tried this with my own interfaces and concrete classes, and I get the
    same strange behavior: calling methods with interface argument types on
    the ejb via rmi-iiop fails with the above cryptic error, but methods
    with concrete argument types work fine.
    I also tried this out on a non-ejb rmi-iiop server object using jdk 1.3
    but not weblogic. In that case both interfaces and concrete method
    argument types work just fine.
    Now I'm wondering if this could be a bug in weblogic.ejbc's iiop
    generation. Can anyone else verify this problem?
    Edwin Park
    [email protected]

    Comments in line...
    Edwin Park wrote:
    I got the rmi-iiop example code to work just fine, but I tried extending
    it a little and strangeness ensues. Here's what I did:
    I'm using a stock weblogic 6.0 install on solaris 8 (sparc). I added
    the following new method to the Trader interface:
    public void func(javax.naming.Name n) throws RemoteException;
    and I added the implementation of that method to TraderBean like so:
    public void func(javax.naming.Name n) {
    System.out.prinltn("n [" + n + "]");
    I then added a call to the new Trader function to the end of the
    example() method in Client, just before the trader is removed:
    try {
    com.sun.jndi.ldap.LdapName lname =
    new com.sun.jndi.ldap.LdapName("a=b");
    trader.func(lname);
    } catch (javax.naming.NamingException ne) {
    ne.printStackTrace();
    Then I compiled everything using the supplied build.sh, copied the
    ejb_over_iiop.jar into config/mydomain/applications, and ran
    startWebLogic.sh int the config/mydomain directory to start the server.
    I then run the client like so (using the 1.3 java version included with
    weblogic 6.0):
    java -cp
    /opt/bea/wlserver6.0/config/examples/clientclasses:/opt/bea/wlserver6.0/config/mydomain/applications:/opt/bea/wlserver6.0/lib/weblogic.jar
    examples.rmi_iiop.ejb.rmi_iiop.Client iiop://localhost:7001
    And I get the following output:
    Beginning statelessSession.Client...
    Creating a trader
    Buying 100 shares of BEAS.
    Buying 200 shares of MSFT.
    Buying 300 shares of AMZN.
    Buying 400 shares of HWP.
    Selling 100 shares of BEAS.
    Selling 200 shares of MSFT.
    Selling 300 shares of AMZN.
    Selling 400 shares of HWP.
    There was an exception while creating and using the Trader.
    This indicates that there was a problem communicating with the server:
    java.rmi.RemoteException: CORBA UNKNOWN 0 No; nested exception is:
    org.omg.CORBA.UNKNOWN: minor code: 0 completed: No
    End statelessSession.Client...
    Basically the call to the new method fails, and the server communication
    error it produces doesn't provide much information. So question #1 is,
    what's going on here?
    Marshaling through the interface apparently fails. What orb are you using on the client?
    >
    And here's the really weird part: if I change the method signatures in
    Trader and TraderBean so that the argument type is the concrete class
    com.sun.jndi.ldap.LdapName instead of the interface javax.naming.Name
    (which does extend java.io.Serializable, incidentally), it works fine!It appears that marshaling an interface (or abstract class) fails, but marshaling a concrete class succeeds.
    >
    >
    I tried this with my own interfaces and concrete classes, and I get the
    same strange behavior: calling methods with interface argument types on
    the ejb via rmi-iiop fails with the above cryptic error, but methods
    with concrete argument types work fine.
    I also tried this out on a non-ejb rmi-iiop server object using jdk 1.3
    but not weblogic. In that case both interfaces and concrete method
    argument types work just fine.
    Now I'm wondering if this could be a bug in weblogic.ejbc's iiop
    generation. Can anyone else verify this problem?I'll look into this.
    >
    >
    Edwin Park
    [email protected]

  • Comparing performance of CORBA/RMI/RMI-IIOP

    I would like to compare CORBA, RMI and RMI-IIOP.
    Is there any s/w available, pref open source, in java to perforam benchmarking in some or all of the three.
    Anything which also supports C++ would be a plus.
    I know there is some data already available, but I would like to be able to perform my own tests on my platform. prob linux and linux cluster.

    CORBA is supported by Windows machines (Windows XP/2000 as I know of it) and other APIs may be bought or included in some enterprise applications.
    RMI and CORBA are about as fast as each other. RMI-IIOP is slower then RMI and CORBA, however, it can sometimes go a little faster depending on deployment and environment.

  • Error passing a remote object in a rmi function call

    Hi,
    I've a problem passing an UnicastRemoteObject extended object in a rmi function call. I get the following error
    java.lang.IllegalArgumentException: argument type mismatch
    I've 2 Remote Objects: GalaxyRegistration and Station. I want to pass a Station Object as argument in a function from GalaxyRegistration. Does anyone know what the problem is?
    Here is the code:
    public class GalaxyRegistration
    extends UnicastRemoteObject
    implements GalaxyRegistrationInterface, Galaxy {
         public GalaxyRegistration() throws RemoteException {
         public void add(Station station) throws RemoteException {
              stations.addElement(station);
              System.out.println("Add Station " + station.getName());
    public class Station
    extends UnicastRemoteObject
    implements StationInterface {
         SystemInfo system;
         public Station(String name, String description, Coordinate position, Profile profile)
    throws RemoteException {
              system = new SystemInfo(name, description, position, profile);
    public class StationServer {
         Station station;
         public void run() {
              // create new Station
              System.out.println("Create new Station:");
              // register and bind new station
              try     {
                   station = new Station(name, descr, location, profile);
                   System.out.println("Station created ...");
                   GalaxyRegistrationInterface registry =
                             (GalaxyRegistrationInterface)
                             Naming.lookup
    ("//localhost/GalaxyRegistration");
                   System.out.println("Registry looked up ...");               
                   // >>>>>>>> NEXT LINE IS THE ERROR LINE <<<<<<<<<<<<<<     
                   registry.add(station);
              } catch(Exception e) {
                   System.out.println(e);
    }

    regardless of any other problems in your code, neither of the objects which you are subclassing from UnicastRemoteObject call the superclass constructor, which is a pretty basic flaw - in this case, it will lead to neither of these objects being exported properly.

  • RMI and Threads: Calling wait() on a remote object

    I created a counter as a remote object.
    Multiple clients are displaying the counter value.
    If one of the clients increments the counter, I want the displayed counter value on every client to be updated to the new value (of the counter on the server).
    Therefore every client starts a new thread to "listen" for changes of the countervalue. I wanted to call the wait() method on the remote object (the remote counter). But i think it will be called on the stub instead of on the actual remote object.
    Therefore i created a extra method waitForChange() on the remote object.
    public void waitForChange() throws RemoteException, InterruptedException {
         synchronized(this) {
              wait();
    This method only calls the wait() method. Now I'm sure it's called on the remote object and not on the stub.
    This works, but my question is: is there a better way to do this?
    Code:
    ==========================================
    The remote interface
    ==========================================
    import java.rmi.Remote;
    import java.rmi.RemoteException;
    public interface RemoteCounter extends Remote {
         void incrementCounter() throws RemoteException;
         int getCounterValue() throws RemoteException;
         void waitForChange() throws RemoteException, InterruptedException;
    } ==========================================
    The implementation of the remote interface
    ==========================================
    import java.rmi.*;
    import java.rmi.activation.*;
    import RemoteCounter;
    public class RemoteCounterImpl extends Activatable
         implements RemoteCounter {
         private static final long serialVersionUID = 1L;
         private int counter = 0;
         protected RemoteCounterImpl(ActivationID id, MarshalledObject data) throws RemoteException {
              super(id, 0);
         public void incrementCounter() throws RemoteException {
              synchronized(this) {
                   counter++;
                   notifyAll(); //Inform all clients of the new countervalue;
         public void waitForChange() throws RemoteException, InterruptedException {
              synchronized(this) {
                   wait();
         public int getCounterValue() throws RemoteException {
              return counter;
    }==========================================
    A piece of code registering the remote object
    ==========================================
    ActivationDesc desc = new ActivationDesc(agi, "RemoteCounterImpl", codebase, data);
    //Register with rmid
    RemoteCounter counter = (RemoteCounter)Activatable.register(desc);
    // Bind the stub to a name in the registry running on 1099
    Naming.bind("Counter", counter);==========================================
    The panel containing a button, a label
    which starts a new thread listening for
    counter value changes
    ==========================================
    import javax.swing.*;
    import java.awt.Dimension;
    import java.awt.event.*;
    import java.rmi.*;
    import org.personal.exam.services.RemoteCounter;
    public class PanelCounter extends JPanel {
         private static final long serialVersionUID = 1L;
         JLabel labelX = new JLabel("Press testbutton");
         Thread t;
         RemoteCounter remoteCounter;
         public PanelCounter()     {
              try {
                   jbInit();
              } catch(Exception e) {
                   e.printStackTrace();
         private void jbInit() throws Exception
              this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
              this.setPreferredSize(new Dimension(450,300));
              // The securityManager is required to make is possible
              // to download classes from the server
              if (System.getSecurityManager() == null) {
                   System.setSecurityManager(new RMISecurityManager());
              //Create a testButton to increment the counter          
              JButton testButton = new JButton("Increment");
              testButton.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent arg0) {
                        incrementCounter();
              this.add(testButton);
              //Add a label to display the counter value
              this.add(labelX);
              // Create thread to listen for counter value changes
              try {
                   remoteCounter = (RemoteCounter)Naming.lookup("Counter");
                   CounterValueChecker cvl = new CounterValueChecker(labelX, remoteCounter);
                   //Start a thread to listen for changes of the countervalue
                 t = new Thread(cvl);
                 t.start();
              } catch(Exception e) {
                   e.printStackTrace();
              this.setVisible(true);
         private void incrementCounter() {
              String message = "error";
              try {
                   remoteCounter.incrementCounter();
                   message = "Current value is " + remoteCounter.getCounterValue();
              } catch(Exception e) {
                   System.out.println("Test Exception: " + e.getMessage());
                   e.printStackTrace();
              labelX.setText(message);
    }==========================================
    The runnable implementation used by the
    thread to wait for counterchanges
    ==========================================
    import java.rmi.RemoteException;
    import javax.swing.JLabel;
    import org.apache.log4j.Logger;
    import RemoteCounter;
    public class CounterValueChecker implements Runnable {
         private JLabel counterLabel;
         private RemoteCounter remoteCounter;
         public boolean keepChecking= true;
         private Logger logger = Logger.getLogger(this.getClass());
         public CounterValueChecker(JLabel counterLabel, RemoteCounter remoteCounter){
              this.counterLabel = counterLabel;
              this.remoteCounter = remoteCounter;
         public void run() {
              while(keepChecking) {
                   int newVal = -1;
                   synchronized(remoteCounter) {
                        try {
                             //remoteCounter.wait();
    //this does not work. I think because the wait() method is called on the
    //stub instead of on the actual remote object
                             remoteCounter.waitForChange();
                        } catch (InterruptedException e) {
                             keepChecking = false;
                             break;
                        } catch (RemoteException re) {
                             re.printStackTrace();
                        try {
                             newVal = remoteCounter.getCounterValue();
                        } catch (RemoteException re) {
                             re.printStackTrace();
                        counterLabel.setText("New value: " + newVal);
    }This is just a little test. Actually I want to notify clients of changes in data displayed in a Table. If one client saves one record of the data, i want the new record to be displayed immediatly on all clients that are viewing the same data.

    I've been doing some reading about RMI and callback.
    As I understand it, there's a remote object is running on the client now as wel. And the server makes a call to the client.
    But now the server makes a call to one client.
    And the point is, I want all clients to be updated with the new value.
    Does this mean, I have to keep a list with references to all clients connected to the server?
    I my code the notifyAll() method causes all waiting Threads (running on several clients) to wake up and do something (getting the new counter value).

  • Over technologies rather than RMI to pass remote objects

    Hi,
    Just a general question about remote objects. Currently I am familiar with RMI, IIOP and JMS to pass remote objects. What other technologies are available? in particular, technologies for passing remote objects between different software systems?
    Just a simple response detailing the names would be great, gives me something to research then.
    thanks

    ofcourse passing over socket is always an option. Sure in that case you will have to serialize the object yourself or make a mini-protocol of some kind.
    In our project we also use XML to pass object between C++ and Java world, instead of using CORBA.

  • A rmi problem about exporting a remote object

    here is the code:
    public interface Hello extends Remote {
    String sayHello() throws RemoteException;
    public class HelloImpl extends UnicastRemoteObject
    implements Hello {
    public HelloImpl() throws RemoteException {
    super();
    public String sayHello() {
    return "Hello World!";
    public static void main(String args[]) {
    if (System.getSecurityManager() == null) {
         System.setSecurityManager(new RMISecurityManager());
    try{
         HelloImpl obj = new HelloImpl();
         Naming.rebind("//192.168.10.2:2001/HelloServer", obj);
         System.out.println("HelloServer bound in registry");
    }catch (Exception e) {
         System.out.println("HelloImpl err: " + e.getMessage());
    e.printStackTrace();
    public class HelloClient{
    public static void main(String[] args){
    Hello obj = null;
    String message="nobody say hello to me";
    if (System.getSecurityManager() == null) {
         System.setSecurityManager(new RMISecurityManager());
    try {
         obj = (Hello)Naming.lookup("//192.168.10.2:2001/HelloServer");
         message = obj.sayHello();
    }catch (Exception e) {
         System.out.println("exception: "+e.getMessage());
         e.printStackTrace();
    System.out.println(message);
    where 192.168.10.2 is the ip address of my computer.
    i'm using an mini-http server provided by sun,that is,ClassFileServer
    here is my command lines:
    java examples.classServer.ClassFileServer 2003 d:\java\rmi
    start rmiregistry 2001
    java -Djava.rmi.server.codebase=http://192.168.10.2:2001/
    -Djava.security.policy=server.policy HelloImpl
    then encountered the exception.
    can someone tell me how can i export the HelloImpl and
    make it can be invoked by client.
    thanks a lot!

    thank you for your reply,i tried it again like below:
    java examples.classServer.ClassFileServer 2001 d:\java\rmi
    start rmiregistry
    java -Djava.rmi.server.codebase=http://192.168.10.2:2001/
    -Djava.security.policy=server.policy HelloImpl
    java HelloClient
    but could not work,the exception raised at the client point is like that:
    java.rmi.Naming.lookup(unknown source)....
    i want to know how could the client know how to contact with
    rmiregistry,where the client trying to lookup(//192.168.10.2:2001/HelloServer)
    while rmiregistry running on the port 1099.
    thank you!

  • Help needed to move a java.rmi.Remote object.....

    Hi,
    I have an object extending java.rmi.Remote on a server. I want to get it onto a client (ie the actual object, not a reference to the object on the server).
    The catch (isn't there always one):
    The client must only get class definitions/interface definitions from the java.rmi.server.codebase
    (ie I don't want to use a network classloader).
    Anyone any ideas?
    Kev.

    If you have a class that implements java.rmi.Remote then the objects of that class by definition are available for Remote access (ie, they are passed by reference). Remote objects can't be passed by value. However, if you want objects of a particular class to be passed by value you could have the class implement java.io.Serializable instead of java.rmi.Remote.
    Hope this helps.

  • Rmi and reference to remote object

    how I can obtain a reference to a remote object and not its value?

    This will happen automatically once it is exported and you return it from the server via an RMI call, e.g. Naming.lookup() or as the result of another remote method.

  • Can't update remote object (RMI)

    I have made a class "A" that implements a remote interface "RI". I then rebind it to the rmiregistry:
    RI bob = new A();
    Naming.rebind("bob",bob);Class A has a few methods that I call that changes som private fields.
    After some time I start another class B that makes a look up:
    RI found  = (RI)Naming.lookup("//localhost/bob");But the private fields have not been changed in this looked up object.
    Is it necessary to call rebind each time I make a change to a remote object??

    If you'd stick to the same thread instead of starting a new one all over the place you'd find that I've already answered this question three days ago: http://forum.java.sun.com/thread.jspa?threadID=770735&messageID=4393030#4393030
    Can you stick to that thread please.

  • Error while using RMI IIOP

    Hi all,
    this is my client code which access EJB 2.1 and SUN JES AS 8.1 using RMI IIOP
    i get the remote home interface well but when i use home.create(), it retruns null.
    can anyone help me???
    Here is the coding,
    Properties props = new Properties();
    //props.put("javax.rmi.CORBA.UtilClass",
    // "com.sun.corba.ee.impl.javax.rmi.CORBA.Util");
    props.put("org.omg.CORBA.ORBClass","com.ooc.OBServer.ORB");
    props.put("org.omg.CORBA.ORBSingletonClass","com.ooc.CORBA.ORBSingleton");
    props.put(Context.INITIAL_CONTEXT_FACTORY,
    "com.sun.jndi.cosnaming.CNCtxFactory");
    props.put(Context.PROVIDER_URL, "iiop://10.24.17.68:3360"); // the port of the application server
    props.put("ooc.orb.service.NameService",
    "corbaloc:iiop:10.24.17.68:3360/NameService");
    String[] args = null;
    ORB orb = ORB.init(args, props);
    Context ctx;
    Object obj;
    try {
    ctx = new InitialContext(props);
    System.out.println("RMI: 1");
    obj = ctx.lookup("ejb/NewSessionBean");
    System.out.println("RMI: 2");
    System.out.println("object name: "+obj.getClass().getName());
    System.out.println("object class loader: "+obj.getClass().getClassLoader());
    NewSessionRemoteHome home = (NewSessionRemoteHome) PortableRemoteObject.
    narrow(obj, NewSessionRemoteHome.class);
    System.out.println("Interface name: "+home.getClass().getName());
    System.out.println("RMI: 3: " + home.toString());
    if (home == null){
    System.out.println("home is null");
    NewSessionRemote remo = (NewSessionRemote)home.create();
    System.out.println("RMI: 4");
    remo.printText("Welcome to RMI world"); //the message send by the client
    System.out.println("The sending of RMI is succeed");
    } catch (Exception ex) {
    System.out.println("exception starts:");
    ex.printStackTrace();
    System.out.println("Exception occurs. Exception: " + ex.getMessage());
    Here is the traces,
    RMI: 1
    RMI: 2
    object name: com.ooc.CORBA.StubForObject
    object class loader: null
    Interface name: fr.teleca.orangebenchosa.cdrstat._NewSessionRemoteHome_Stub
    RMI: 3: IOR:000000000000004b524d493a66722e74656c6563612e6f72616e676562656e63686f73612e6 36472737461742e4e657753657373696f6e52656d6f7465486f6d653a30303030303030303030303 0303030300000000000010000000000000188000102000000000c31302e32342e31372e3638000d2 0000000000056afabcb00000000260000003f00000009533141532d4f52420000000000000002000 00008526f6f74504f41000000001237353732393838353136303237353936380000000000000d010 d0bede7dc000000000001ff140000000000070000000100000020000000000001000100000002050 10001000100200001010900000001000101000000002600000002000200000000000300000016000 000000000000c31302e32342e31372e3638000d1600000000000300000016000000000000000c313 02e32342e31372e3638000d1300000000001f0000000400000003000000200000000400000001000 000210000007c000000000000000100000000000000240000001e000000660000000000000001000 0000c31302e32342e31372e3638000d1600400000000000000008060667810201010100000017040 1000806066781020101010000000764656661756c740004000000000000000000000100000008060 66781020101010000000f
    exception starts:
    java.lang.ClassCastException
    at com.sun.corba.se.internal.iiop.ShutdownUtilDelegate.isLocal(Unknown Source)
    at javax.rmi.CORBA.Util.isLocal(Unknown Source)
    at fr.teleca.orangebenchosa.cdrstat._NewSessionRemoteHome_Stub.create(Unknown Source)
    at fr.teleca.orangebenchosa.servicelogic.CallHandler$EndState.sendCDRStat(CallHand ler.java:1385)
    at fr.teleca.orangebenchosa.servicelogic.CallHandler$EndState.start(CallHandler.ja va:1047)
    at com.appium.TAS.SessionContainer.StatefulObject.enterState(StatefulObject.java)
    at fr.teleca.orangebenchosa.servicelogic.CallHandler.access$4800(CallHandler.java: 61)
    at fr.teleca.orangebenchosa.servicelogic.CallHandler$SuccessfulLogicState.routeRes (CallHandler.java:902)
    at com.appium.TAS.SessionComponents.CallControl.a.exec(a.java)
    at com.appium.Basement.Synchronization.Asynchronizer.d(Asynchronizer.java)
    at com.appium.Basement.Synchronization.g.run(g.java)
    Exception occurs. Exception: null

    Hi ejp,
    because my stand alone client application runs on telecom server which uses orbacus. It calls the remote method on sun AS using RMI IIOP
    I specifed the properties of the client to use SUN AS naming services.
    I added j2ee.jar and appserv-rt.jar in my client program. but i dont know eventhough i specified the Util properties to use as below
    props.put("javax.rmi.CORBA.UtilClass","com.sun.corba.ee.impl.javax.rmi.CORBA.Util");
    props.put("org.omg.CORBA.ORBClass", "com.sun.corba.ee.impl.orb.ORBImpl");
    props.put("org.omg.CORBA.ORBSingletonClass", "com.sun.corba.ee.impl.orb.ORBSingleton");
    props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
    props.put(Context.PROVIDER_URL,"iiop://10.24.17.68:3360"); // the port of the application server
    props.put("ooc.orb.service.NameService", "corbaloc:iiop:10.24.17.68:3360/NameService");
    ORB orb = ORB.init(args,props);
    Context ctx;
    Object obj;
    try {
    ctx = new InitialContext(props);
    obj= ctx.lookup("ejb/NewSessionBean");
    NamingEnumeration ne = ctx.listBindings("ejb");
    while (ne.hasMore()) {
    System.out.println("Binding: " + ne.next());
    System.out.println("object name"+obj.getClass().getName());
    System.out.println("object class loader"+obj.getClass().getClassLoader());
    NewSessionRemoteHome home=(NewSessionRemoteHome)PortableRemoteObject.narrow(obj,NewSessionRemoteHome.class);
    System.out.println("Interface name: "+home.getClass().getName());
    NewSessionRemote remo=home.create();
    System.out.println("Remote name: "+remo.getClass().getName());
    remo.printText("Welcome"); //the message send by the client
    } catch (Exception ex) {
    ex.printStackTrace();
    but it uses J2SE Util. Is there any other workaround to do?
    Thanks
    mdb

Maybe you are looking for