3 Replies Latest reply on Aug 27, 2003 7:39 AM by mattygiedt

    Remote lookup from MDB

    mattygiedt

      Here is my situation.

      I have 2 JBoss instances, the first using an MDB to listen to a JMS queue and call SS EJBs managed by the second.

      I am getting the standard javax.naming.NameNotFoundException when performing the lookup of the SS EJB from the MDB.

      I have a security policy (everything) and jndi.properties (default) present on both instances.

      The first instance (MDB) uses port 1098, the second (SS) uses port 1099 for JNDI. Both instances are run on the same server. Both instances start without an error.

      The SS EJB is successfully deployed and the jboss.xml file for it looks like:

      <?xml version="1.0"?>


      <enterprise-beans>

      <ejb-name>IPBrokerBean</ejb-name>
      <jndi-name>IPBrokerHome</jndi-name>
      <resource-ref>
      <res-ref-name>jdbc/XAMSSQLDS</res-ref-name>
      <jndi-name>java:/XAMSSQLDS</jndi-name>
      </resource-ref>

      </enterprise-beans>


      The code in the MDB to call the remote SS EJB follows:

      public final String ISO_ENCODING = "ISO-8859-1";
      public final String JNDI_URL = "jnp://localhost:1099";
      public final String JNDI_FACTORY = "org.jnp.interfaces.NamingContextFactory";
      public final String JNDI_PREFIXES = "org.jboss.naming:org.jnp.interfaces";

      //
      // Get a handle to the Session Bean's home
      //

      Hashtable env = new Hashtable();
      env.put( Context.PROVIDER_URL, JNDI_URL );
      env.put( Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY );
      env.put( Context.URL_PKG_PREFIXES, JNDI_PREFIXES );
      InitialContext ctx = new InitialContext( env );

      home = (IPBrokerHome)PortableRemoteObject.narrow(
      ctx.lookup("IPBrokerHome"), IPBrokerHome.class );

      Thanks in advance for your help,
      -Matt

        • 1. Re: Remote lookup from MDB

          What do you get when you see when you list the enumeration
          on the context.

          Regards,
          Adrian

          • 2. Re: Remote lookup from MDB
            mattygiedt

            Here is the new code:

            Hashtable env = new Hashtable();
            env.put( Context.PROVIDER_URL, JNDI_URL );
            env.put( Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY );
            env.put( Context.URL_PKG_PREFIXES, JNDI_PREFIXES );
            InitialContext ctx = new InitialContext( env );

            NamingEnumeration ne = ctx.list( ctx.getNameInNamespace() );

            while( ne.hasMore() )
            {
            System.err.println( ne.next() );
            }

            home = (IPBrokerHome)PortableRemoteObject.narrow(
            ctx.lookup("IPBrokerHome"), IPBrokerHome.class );

            -------------------------------------------------

            and here is the result:

            08:57:36,888 ERROR [STDERR] UserTransaction: org.jboss.tm.usertx.client.ClientUserTransaction
            08:57:36,888 ERROR [STDERR] invokers: org.jnp.interfaces.NamingContext
            08:57:36,888 ERROR [STDERR] UserTransactionSessionFactory: org.jboss.tm.usertx.server.UserTransactionSessionFactoryImpl

            --------------------------------------------------

            Obviously the EJB is not in the context. That could mean (I think) two things:

            1. the EJB isn't being bound to the JNDI tree in the SS JBoss instance
            2. I'm not getting the right context

            I know that the SS bean is being deployed as I have a test that, when run in the same JVM, can obtain the home interface to the bean through a default call to new InitialContext(). But, this isn't really accessing the JNDI tree because of the commented out line in jndi.properties, right?

            So now I'm really confused.

            TIA,
            -Matt

            • 3. Re: Remote lookup from MDB
              mattygiedt

              So the problem is that the bean is not being deployed into the JNDI tree on my second JBoss instance.

              Thanks for the enumeration tip!

              -Matt