Bind RMI object to JNDI

InitialContext ctx = new InitialContext ();
ctx.rebind ("wwlhp", remoteObject);Does the JNDI tree and remoteObject reside in the same JVM?
Can i use JNDI without J2EE platform?
Can some one give me a piece of code illustrating rebinding in server side and looking up in client side.

import javax.naming.*;
import java.util.*;
public class Server{
public static void main(String[]args){
try{
Hashtable env=new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.rmi.registry.RegistryContextFactory");
env.put(Context.PROVIDER_URL,"rmi://servername");
Context ctx=new InitialContext(env);
//create an instance of remote object
RemoteIF i=new RemoteImpl();
ctx.rebind("common name",ri);
}catch(Exception ex){}
The client needs to create a context as well, as above, the lookup
RemoteIF ri=(RemoteIF)ctx.lookup("common name");
The Stub classes must be available to the client as well
start rmiregistry
start the server
off you go with the client

Similar Messages

  • Bind remote object to JNDI tree

    I want to create a JNDI tree in the same JVM with remote object, and then I have two problem:
    1> Should I bind remote object or its stub to the JNDI tree?
    2> How to look up the JNDI tree to get the binded stub from the client side? (Suppose server ip is 192.168.99.42)
    I hope a gentleman would give me a piece of code, so i would be much clearer. Thanks a lot!

    Hi,
    Refer http://java.sun.com/products/jndi/tutorial/objects/storing/remote.html
    -amol

  • Binding RMI object at startup in cluster

    Hi
    While I have seen similar postings perhaps someone could provide clarity. I have
    two nodes in a WL 6.1 cluster. I have a class that implements the ServletContextListener
    interface and is invoked on deployment of my app. This class binds checks for
    the existence of a bound object and if not found binds one. The first node binds
    correctly. When I start the managed server it does not find the bound object.
    Is this because the replication was not quick enough? The bound object is n clusterable
    RMI object. The idea here is that should the first node fail the second node,
    which keeps checking in the interim, will find no bound object and bind one.

    Does xyzImpl extend UnicastRemoteObject by any chance? If so, delete the exportObject() call, it is already exported by its constructor (i.e. when its constructor calls super()).

  • How to bind an object to JNDI tree in iAS?

    Hi all,
    When I try to bind a string object to jndi tree, the following exception
    occurs:
    javax.naming.NamingException: Unable to get object instance from reference.
    Roo
    t exception is javax.naming.NamingException: Can't bind instance of class
    java.lang.String
    at com.netscape.server.jndi.RootContext.bindCtx(Unknown Source)
    at com.netscape.server.jndi.RootContext.rebind(Unknown Source)
    at com.netscape.server.jndi.RootContext.rebind(Unknown Source)
    at javax.naming.InitialContext.rebind(InitialContext.java:385)
    at jsp.APPS.bmx.test2._jspService(test2.java:76)
    at jsp.APPS.bmx.test2.service(test2.java:42)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    at
    com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown
    Source)
    The code fragment is:
    Context ctx = new InitialContext();
    String str = "hell,every one!";
    ctx.rebind("abc", str);
    Can anyone give some help? Thanks in advance.
    Johnson

    To bind an object into the JNDI tree check the documentation here:
    http://e-docs.bea.com/wls/docs81/jndi/jndi.html#475702
    If this is to be used by all your applications that you deploy on the server check out the startup/shutdown class documentation here:
    http://edocs.bea.com/wls/docs81/ConsoleHelp/startup_shutdown.html
    Cheers
    IV

  • Clustering rmi objects

    Hi all,
    I am looking for some information about clustering RMI objects. I have read as much
    as I can find about it, not much seems to be in the wl docs.
    I have read that if the server that bound the rmi object into jndi goes down, the
    rmi server will no longer work. When I tested this out, the server seemed to continue
    working and using the node in the cluster that was still running.
    I am wondering what the difference between declaring the RMI object to be clusterable
    and setting the WLContext.REPLICATE_BINDINGS flag to false when creating the context
    to bind the RMI objects, and binding a seperate RMI object into the tree, one for
    each node in the cluster.
    is there some docs I can read about this? Thanks for any information you can give
    me about this.
    -chris

    bwit <[email protected]> wrote:
    In article <[email protected]>, [email protected]
    says...
    Hi all,Hi Chris.
    I am looking for some information about clustering RMI objects. I haveread as much
    as I can find about it, not much seems to be in the wl docs.
    I have read that if the server that bound the rmi object into jndi goesdown, the
    rmi server will no longer work. When I tested this out, the server seemedto continue
    working and using the node in the cluster that was still running.If a server offering an RMI object via JNDI goes down the binding to
    that object is removed from JNDI in all the other servers in the
    cluster. Other replicas of that object may be available and will
    continue to be used as you discovered.
    I am wondering what the difference between declaring the RMI object tobe clusterable
    and setting the WLContext.REPLICATE_BINDINGS flag to false when creatingthe context
    to bind the RMI objects, and binding a seperate RMI object into the tree,one for
    each node in the cluster.Marking the RMI object as clusterable causes WLS to generate a replica
    aware stub for it. This stub is aware of all the replicas of the object
    within the cluster and provides load balancing and failover. When you
    bind a RMI object on multiple servers with REPLICATE_BINDINGS set to
    false you have a bunch of individual, unrelated objects. Your clients
    must contact the particular server running the objects and there will be
    no load balancing or failover, all client calls will be serviced by the
    object on the server which supplied the stub.
    is there some docs I can read about this? Thanks for any informationyou can give
    me about this.I thought the WLS RMI Programmer's Guide was pretty clear about how this
    worked.
    Well, you are right, the docs are clear on what they talk about, but as I mentioned,
    when I marked the objects with REPLICATE_BINDINGS set to false, the client still
    sent a comma delimited list of servers to create the InitialContext, and we still
    observed load balancing, and what looked like failover. This is why we were confused,
    we expected to see only one server do all the work (the first in the comma delimited
    list), and for failures when that server was brought down. I will take a look at
    our configuration and make sure we didnt make a mistake someplace in here.
    Regards,
    Bob
    -chris

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

  • Trouble in storing and retrieving RMI object in Weblogic 7 JNDI tree.

    I have created a simple server (BankImpl), implementing a RMI interface
    called Bank. A stub class (BankImpl_Stub.class) is generated from BankImpl
    class using
    "rmic -v1.2". Then I bind an instance of the BankImpl class to the JNDI tree
    in Weblogic
    server 7 under the name of "PeopleBank".
    After the binding, I can see the stub class in the JNDI tree, but with a
    different name: BankImpl_WLStub.class). when a
    client program is trying to lookup the stub associated with "PeopleBank", it
    failed with a puzzling message:
    java.io.NotSerializableException: BankImpl_WLStub
    Why a stub of a RMI object is not serializable? Does Weblogic needs a
    different rmic to generate RMI stubs?
    Thanks,
    Lian

    I have created a simple server (BankImpl), implementing a RMI interface
    called Bank. A stub class (BankImpl_Stub.class) is generated from BankImpl
    class using
    "rmic -v1.2". Then I bind an instance of the BankImpl class to the JNDI tree
    in Weblogic
    server 7 under the name of "PeopleBank".
    After the binding, I can see the stub class in the JNDI tree, but with a
    different name: BankImpl_WLStub.class). when a
    client program is trying to lookup the stub associated with "PeopleBank", it
    failed with a puzzling message:
    java.io.NotSerializableException: BankImpl_WLStub
    Why a stub of a RMI object is not serializable? Does Weblogic needs a
    different rmic to generate RMI stubs?
    Thanks,
    Lian

  • Unable to retreive RMI object bound to JNDI

    Hi
    I am trying to retrieve an rmi object that appears to have been sucessfully
    deployed to the weblogic server. Upon startup the nt command console shows
    the message below and the class name appears in the Distributed objects/rmi
    area in the Weblogic console.
    Invoking main-style startup Guid xxxxxx.GuidImpl
    However if I try to write a test client using either one of the following
    calls I get a NameNotFoundException.
    I have tried both the name Guid (which is what is in the startup entry) and
    the fully qualified name. They all have the same results.
    Sample calls:
    Naming.lookup("Guid");
    or
    getInitialContext();
    jndiContext.lookup("Guid");
    In my weblogic properties files I have the following entry:
    weblogic.system.startupClass.Guid=xxx.GuidImpl
    in the main of GuidImpl class I have the following entry:
    Naming.bind("xxx.Guid");
    any ideas as to what might be wrong?
    Thanks

    Hi, all:
    Currently I evaluate BEA Weblogic 6.1 server. I've read the "Programming
    WebLogic JNDI" section of the documentation for Weblogic server 6.1.
    However, I couldn't find the answer for my question. What problem I have
    now is that
    (1): How I can create a object in the Java VM when the Weblogic server
    startup? Note:
    This class need to read a property files and
    store all of properties information into its instance for the
    client program to lookup it later.
    (2): How can the previous created object to be bound in the Weblogic
    JDNI server and the bounded
    object can be shown up in the JDNI tree in the Weblogic server's
    console?
    (3): How do I code my servlet to lookup that object I
    just created in the step1? What configuration settings need to be
    done before Weblogic server is started?
    Because I am stopped by this problem, if anyone can give me the example
    code or some explanation of the solution ASAP,
    it would be very appreciated....Thanks in advance.......
    Merry Christmas
    Long

  • Unable to bind object in JNDI tree.

    While I try to bind a simple object in JNDI tree I get the following error.
    I have not used any cluster .
    Server : Web Logic 8.1 SP 6
    Jdk version 1.4.2 comes along with bea weblogic 8.1 sp 6
    Javax.naming.communicationException[
    Root exception is java.rmi.unmarshalException:
    Error unmarshalling arguments; nested exception is :
    Java.lang.ClassNotFoundException: com.examples.person : This error could indicate that a compound was deployed on a cluster member but not other members of that cluster. Make sure that any component deployed on a server that is part of a cluster is also deployed on a server that is part of a cluster is also deployed on all other member of that cluster.

    Is this somehow being called from the parameterless constructor?
    You sometimes have to wrap bits of code with in designer checks to stop em running.
    In c# that would be:
    if (!DesignerProperties.GetIsInDesignMode(this))
    // do your stuff only at runtime
    Please don't forget to upvote posts which you like and mark those which answer your question.
    My latest Technet article - Dynamic XAML

  • Bind a huge object to jndi tree in sun one 7

    Hi we are loading all the master tables in to objects at the app server startup (SUN ONE 7) and then binding the whole object to the jndi tree. All the tables data in text files comes to about 5 MB and the serilized object with data to about 8 MB. But when the app server tries to bind the object the app server process consumes over 500MB of ram and gives OutOfmemoryError as the total ram is 512MB. why is it consuming so much memory. It does bind an object of about 5 MB but when trying to lookup subsequent to the first lookup it fails. Is this a bug or what??? the same thing works perfectly with Weblogic and Websphere and also Weblogic is very efficient in memory consumption and response time is amazing. For a 5 MB object the lookup takes about 5Secs in Weblogic and about 15Mins in Sun One. We might have to drop the Sun One App Srv and go for Weblogic though we dont want. Kindly provide some guidance. Thanks in advance.

    Hi,
    Refer http://java.sun.com/products/jndi/tutorial/objects/storing/remote.html
    -amol

  • Using JNDI to bind any object

    Hi,
    I intend to bind a few objects in JNDI context so that they can later be just looked up and then used.
    I can use code like this:
    =========
    Hashtable env = new Hashtable();
    env.put(Context.PROVIDER_URL, SOME_PROVIDER_URL);
    env.put(Context.SECURITY_PRINCIPAL, "user");
    env.put(Context.SECURITY_CREDENTIAL, "passwd");
    Context ctx = new InitialContext(env);
    context.bind("name", object);
    =========
    This object can later be looked up. So far so good. However, this will bind the object in the same VM "only".
    Is there any way of calling something like:
    ====
    someOC4JClass.getNamingService().bind("name", object);
    ===
    so that the underlying naming service takes care of making this object available across JVMs?
    Any help/pointers will be highly appreciated.
    Thanks,
    Ravi

    Ravi -- Currently OC4J's internal JNDI is not a global JNDI shared by all OC4Js. One way to approach this problem would be to bind the objects in some global / common JNDI like OID.
    Thanks -- Jeff

  • Binding custom objects in weblogic JNDI

    I noticed that if I bind a custom object, the object is not available after the weblogic
    restart. Is there anyway to bind an object permanently in the weblogic JNDI..

    In article <[email protected]>, [email protected] says...
    Murali <[email protected]> wrote:
    I noticed that if I bind a custom object, the object is not available after the weblogic
    restart. Is there anyway to bind an object permanently in the weblogic JNDI..No.
    Perhaps what your trying to accomplish could be handled via a startup
    class that did the bind for you.
    Bob

  • Binding huge object to the jndi tree.

    Hi we are loading all the master tables in to objects at the app server startup (SUN ONE 7) and then binding the whole object to the jndi tree. All the tables data in text files comes to about 5 MB and the serilized object with data to about 8 MB. But when the app server tries to bind the object the app server process consumes over 500MB of ram and gives OutOfmemoryError as the total ram is 512MB. why is it consuming so much memory. It does bind an object of about 5 MB but when trying to lookup subsequent to the first lookup it fails. Is this a bug or what??? the same thing works perfectly with Weblogic and Websphere and also Weblogic is very efficient in memory consumption and response time is amazing. For a 5 MB object the lookup takes about 5Secs in Weblogic and about 15Mins in Sun One. We might have to drop the Sun One App Srv and go for Weblogic though we dont want. This same thing is working with about 4MB object in Sun One but takes about 45 Mins to 1 Hour to finish the serialization etc for jndi .Kindly provide some guidance.Thanks in advance.

    True. At the end I configured the value as a "server property". The cool thing about configuring the jndi tree is that it is replicated in a cluster.
    Obviously the values that I inserted affected all the applications, like the url of our SOA server.

  • Javax.naming.NameAlreadyBoundException: Failed to bind remote object

    I am getting an error while deploying wli-ejbs.ear file. This ear uses oracle thin drivers to connect to database. But while deploying i am receiving an error as below. Can anyone please help me to solve this problem?
    Deployer:149033]preparing application wli-ejbs on managed2_cvf01
    [Deployer:149033]preparing application wli-ejbs on managed1_cvf01
    [Deployer:149033]prepared application wli-ejbs on managed1_cvf01
    [Deployer:149033]prepared application wli-ejbs on managed2_cvf01
    [Deployer:149033]activating application wli-ejbs on managed1_cvf01
    [Deployer:149033]activating application wli-ejbs on managed2_cvf01
    [Deployer:149034]An exception occurred for task [Deployer:149026]Deploy application wli-ejbs on cvf01_cluster.: weblogic.management.DeploymentException:
    Exception:weblogic.management.ApplicationException: activate failed for calendar/oracle
    Module: calendar/oracle Error: Exception activating module: EJBModule(calendar/oracle,status=PREPARED)
    Unable to deploy EJB: RemoteCalendarBean from calendar/oracle:
    [EJB:011008]Unable to bind EJB Home Interface to the JNDI name: RemoteCalendarBean.
    javax.naming.NameAlreadyBoundException: Failed to bind remote object (ClusterableRemoteRef(704752282736664516S:172.24.206.163:[7003,7003,7004,7004,7003,7004,-1,0,0]:172.24.206.163:7003,172.24.206.163:7003:cvf01:managed1_cvf01 null)/948 [com.bea.wli.calendar.api.BusinessCalendarHome+javax.ejb.EJBHome+weblogic.ejb20.interfaces.RemoteHome]) to replica aware stub at RemoteCalendarBean(ClusterableRemoteRef(704752282736664516S:172.24.206.163:[7003,7003,7004,7004,7003,7004,-1,0,0]:172.24.206.163:7003,172.24.206.163:7003:cvf01:managed1_cvf01 [704752282736664516S:172.24.206.163:[7003,7003,7004,7004,7003,7004,-1,0,0]:172.24.206.163:7003,172.24.206.163:7003:cvf01:managed1_cvf01/944, -8505871579836432025S:172.24.206.163:[7005,7005,7006,7006,7005,7006,-1,0,0]:172.24.206.163:7003,172.24.206.163:7003:cvf01:managed2_cvf01/1008])/944 [com.bea.wli.calendar.api.BusinessCalendarHome+javax.ejb.EJBHome+weblogic.ejb20.interfaces.RemoteHome]); remaining name ''
    at weblogic.rmi.cluster.ClusterableRemoteObject.onBind(ClusterableRemoteObject.java:177)
    at weblogic.jndi.internal.BasicNamingNode.bindHere(BasicNamingNode.java:347)
    at weblogic.jndi.internal.ServerNamingNode.bindHere(ServerNamingNode.java:124)
    at weblogic.jndi.internal.BasicNamingNode.bind(BasicNamingNode.java:291)
    at weblogic.jndi.internal.WLEventContextImpl.bind(WLEventContextImpl.java:279)
    at weblogic.jndi.internal.WLContextImpl.bind(WLContextImpl.java:386)
    at weblogic.ejb20.deployer.ClientDrivenBeanInfoImpl.activate(ClientDrivenBeanInfoImpl.java:1141)
    at weblogic.ejb20.deployer.EJBDeployer.activate(EJBDeployer.java:1385)
    at weblogic.ejb20.deployer.EJBModule.activate(EJBModule.java:631)
    at weblogic.j2ee.J2EEApplicationContainer.activateModule(J2EEApplicationContainer.java:3315)
    at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:2194)
    at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:2167)
    at weblogic.management.deploy.slave.SlaveDeployer$ComponentActivateTask.activateContainer(SlaveDeployer.java:2503)
    at weblogic.management.deploy.slave.SlaveDeployer$ActivateTask.doCommit(SlaveDeployer.java:2421)
    at weblogic.management.deploy.slave.SlaveDeployer$Task.commit(SlaveDeployer.java:2138)
    at weblogic.management.deploy.slave.SlaveDeployer.commitUpdate(SlaveDeployer.java:676)
    at weblogic.drs.internal.SlaveCallbackHandler$2.execute(SlaveCallbackHandler.java:35)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)

    run the sync.bat file as mentioned in the instructions...
    or through EBCC(select sampleportal-project dir, app name "sampleportal")...
    good luck
    Vijay
    "ellen" <[email protected]> wrote:
    >
    I installed sampleportal and did all the changes according to the documents,
    when
    the server started, there is this error:
    Unable to deploy EJB: CatalogWebService from catalogwe.jar:
    Unable to bind EJB Home Interface to the JNDI name: sampleportal.BEA_commerce.CatalogWebService.
    The error was: javax.naming.nameAlreadyBoundException: Failed to bind remote
    object...to
    replica aware stub at CatalogWebService; remaining name'sampleportal.BEA_commerce'
    After the server started with the above error, I tried to run the app, here
    is what
    occured:
    PortalPersistenceManager: portal'sampleportal/sampleportal' not found.
    Has anybody seen this before?
    Ellen

  • RMI object bindings bot being replicated

              I have a two node cluster setup for testing. I am creating an RMI
              object on one server and binding it into the JNDI tree. I can see the
              binding on the server where the object was bound but I never see
              anything in the JNDI tree of the other server in the cluster.
              I have tried adding WLContext.REPLICATE_BINDINGS=true to my
              InitialContext. I've also tried compiling the RMI object with
              weblogic.rmic as clusterable. Neither seems to have made any
              difference.
              Any assistance will be appreciated.
              Thanks and regards,
              Bob
              

              Thanks for the reply. Please see my responses inline:
              In article <[email protected]>, [email protected]
              says...
              > Bob,
              >
              > A couple of questions
              > 1> Whether your multicast address is working properly? Perform the
              > multicast test and verify this.
              What is the multicast test? The console cluster monitor screen shows
              both servers sending and receiving message fragments. Both servers show
              zero for Lost Multicast Messages.
              > 2> How are you deploying the RMI object (to the cluster or individual
              > servers)?
              I'm not sure what you mean by "deploying the RMI object". The RMI
              object is created by a startup class and bound to the JNDI tree on one
              server in the cluster. It appears in the tree it where it was bound but
              not the tree on the other server.
              > 3> What version of WLS and Service pack are you using?
              WLS 6.1 SP1 Load3
              > 4> Could you try our sample example in the \cluster\rmi folder?
              This exhibits the same behavior I'm seeing in my app.
              Thanks for your help.
              Regards,
              Bob
              >
              >
              > Bob Withers wrote:
              >
              > > I have a two node cluster setup for testing. I am creating an RMI
              > > object on one server and binding it into the JNDI tree. I can see the
              > > binding on the server where the object was bound but I never see
              > > anything in the JNDI tree of the other server in the cluster.
              > >
              > > I have tried adding WLContext.REPLICATE_BINDINGS=true to my
              > > InitialContext. I've also tried compiling the RMI object with
              > > weblogic.rmic as clusterable. Neither seems to have made any
              > > difference.
              > >
              > > Any assistance will be appreciated.
              > >
              > > Thanks and regards,
              > > Bob
              >
              >
              

Maybe you are looking for

  • The compilation failed due to a Xilinx error (410)

    Hi Peeps, I'm trying to compile my FPGA code with the Cloud Compile Service. I have an FPGA code that compiles without any problems. When I put a DMA FIFO Node into this code, I get the following Xilinx compiler error: ERROR:HDLCompiler:410 - "/opt/a

  • Migrate from File Server Shared Drives to Document Libraries, while Keeping Modified and Created Date

    I am doing some file migration for a client, using SharePoint 2013 on prem. Whether copying files from a local or network drive, to a Document Library, or from Document Library to other Document Library, I want the option of preserving file dates and

  • Weird acting in Device Manager

    So my previous post didn't bear much fruit, but hopefully this new info i discovered can help solving my problem. Here's my situation. I'm using this Iphone 3g for the first time, meaning i need to connect to Itunes in order to activate it. Unfortuna

  • Criticial VLAN for Wireless Users

    Hi I have a setup were all users (LAN & WIRELESS) Are being authenticated using Dot1x with ACS In case of ACS failure (without a secondary one), I know i can configure the switch port on the LAN to have a critical VLAN, so in case ACS was detected as

  • Where does a developer download iOS5 beta for iPad?

    I'm a developer, but where exactly do I download iOS5 beta for iPad? In the Dev Center I only see the SDK for 4.3. Thanks.