1 Reply Latest reply on Aug 5, 2003 6:39 AM by Bernd Zeitler

    Same bean, different JNDI... How?

    null null Newbie

      I have one bean that I wish to deploy across multiple databases.

      I understand that I have to just deploy it multiple times with an appropriate jndi-name in the bean. This I understand (so far). The problem I'm having is that some of my beans need to talk to other beans.

      So, for example, I have bean A, and bean A needs to create bean B during a particular operation. It currently executes code like this.

      private BLocalHome lookupB() throws NamingException {
      Context initial = new InitialContext();
      Object objref = initial.lookup("B");
      return (BLocalHome) objref;

      Now the problem is, if I have an A from 'java:comp/env/ejb/M/A" - I want it to access "java:comp/env/ejb/M/B".

      Conversely, if I have java:comp/env/ejb/N/A I want it to access java:comp/env/ejb/N/B.

      I can't see any obvious way of discerning which bean is which, and this is totally befuddling me. I've looked at a couple of examples on the web and they don't seem to handle this level of dependance.

        • 1. Re: Same bean, different JNDI... How?
          Bernd Zeitler Expert

          Deploy shared resources global, use different loader-repositories for duplicate resources (classes e.g. your bean classes with differen deployment descriptors and jndi names).
          Configure your beans to use the ByValueInvoker when calling a bean located in another loader-repository.
          Read the DTDs of the deployment descriptors to learn more about the configuration of your beans. There are also many thread in this forum covering this issue.