OC4J: looking up problem...


EJB programming & troubleshooting: OC4J: looking up problem...

  1. OC4J: looking up problem... (3 messages)

    I am relatively new to EJB (my second week now in fact). I hope my problem will be easy for most of you and am grateful for your help.

    I am deploying a number of EJBs onto OC4J using Oracle 9i JDeveloper. I have no problem looking up the EJBs from a client computer with the code like:

        Properties props = new Properties();
        props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
        props.setProperty(Context.PROVIDER_URL, "ormi://lil8m:23792/gavin");
        props.setProperty(Context.SECURITY_PRINCIPAL, "admin");
        props.setProperty(Context.SECURITY_CREDENTIALS, "admin");
        try {
          // Get the JNDI initial context
          InitialContext ctx = new InitialContext(props);

          // Get a reference to the Home Object which we use to create the EJB Object
          Object objJNDI = ctx.lookup("comp/env/ejb/Inventory");

          // Now cast it to an InventoryHome object
          InventoryHome objInventoryHome = (InventoryHome)PortableRemoteObject.narrow(objJNDI,InventoryHome.class);

    /* System.out.println("Getting NodeHome...");
          NodeHome home = (NodeHome)PortableRemoteObject.narrow(ctx.lookup("comp/env/ejb/Node"),NodeHome.class);

    However, when I am trying to do the same look up from one of the deployed EJBs (to get access to another EJB on the same server in the same application) it comes back with the javax.naming.NameNotFoundException exception.

    Guys, could you point me at what I am doing wrong?

    I also tried to specify no context environment but that did not work either.

    Thanks in advance for your help!


    Threaded Messages (3)

  2. OC4J lookup[ Go to top ]

    Hi Alexei,

    Try to lookup the NodeHome using java:comp/env/ejb/Node instead.

  3. OC4J: looking up problem...[ Go to top ]


    Create the InitialContext object with out any parameters
    (ic = new InitialContext()).

    If all the EJBs are part of the same application, this shoudl work.
  4. OC4J: looking up problem...[ Go to top ]

    The info given by you is not sufficient. Please copy your ejb code which is calling another ejb once. With that we can check whether code is correct or not.