4 Replies Latest reply on Apr 29, 2002 4:37 PM by G. Reno

    Unable to obtain object reference in separate JVM

    G. Reno Newbie

      We are using a standalone version of Tomcat 4.0.3 with a standalone version of JBoss 2.4.4 so that we may split our web tier from our ejb tier.
      We are running a simple example to verify functionality.
      On the Tomcat web container we have a jsp which calls a Java bean that in turn references an EJB located on the JBoss ejb container.
      The EJBs deploy fine. No errors.
      When we access the jsp through the browser the web container generates this exception: javax.naming.NameNotFoundException: Name calcs is not bound in this Context

      What are we missing here?

      Here are all the calcs references:

      === from Java bean in Tomcat web container JVM ======
      InitialContext ctx = new InitialContext();
      Object objref = ctx.lookup("calcs");

      ==== from server.xml in Tomcat web container JVM ====
      -- in our Context area --

      ===== from web.xml in Tomcat web container JVM ======
      <!-- EJB Reference -->
      Calc Bean

      ==== from ejbjar.xml in JBoss ejb container JVM =====

      Calc Session Bean


      ==== the Tomcat web container JVM error message =====
      javax.naming.NameNotFoundException: Name calcs is not bound in this Context
      at org.apache.naming.NamingContext.lookup(NamingContext.java:811)
      at org.apache.naming.NamingContext.lookup(NamingContext.java:194)
      at org.apache.naming.SelectorContext.lookup(SelectorContext.java:183)
      at javax.naming.InitialContext.lookup(InitialContext.java:347)
      at ClientCode.JBonusBean.(JBonusBean.java:27)

        • 2. Re: Unable to obtain object reference in separate JVM
          G. Reno Newbie

          Adrian, thanks.

          This got us a little further but not quite there.

          We started Tomcat with the -nonaming option and then encountered the following exception:
          javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial

          We searched on NoInitialContextException and found this:

          So we copied all of these jars into CATALINA_HOME/lib and
          added java.naming.provider.url=localhost:1099 to jndi.properties but we still are getting the NoInitialContextException. Now nothing seems to make this go away now.

          Also here is a jndi listing:
          java:comp namespace of the Bonus bean:
          +- env (class: org.jnp.interfaces.NamingContext)
          | +- jdbc (class: org.jnp.interfaces.NamingContext)
          | | +- Bonus[link -> java:/BonusDS] (class: javax.naming.LinkRef)

          java:comp namespace of the Calc bean:
          +- env (class: org.jnp.interfaces.NamingContext)

          java: Namespace
          +- jaas (class: javax.naming.Context)
          +- TransactionPropagationContextImporter (class: org.jboss.tm.TransactionPropagationContextImporter)
          +- JmsXA (class: org.jboss.jms.ra.JmsConnectionFactoryImpl)
          +- MinervaSharedLocalCMFactory (class: org.jboss.pool.connector.jboss.MinervaSharedLocalCMFactory)
          +- BonusDS (class: org.jboss.pool.jdbc.xa.XAPoolDataSource)
          +- StdJMSPool (class: org.jboss.jms.asf.StdServerSessionPoolFactory)
          +- MinervaXACMFactory (class: org.jboss.pool.connector.jboss.MinervaXACMFactory)
          +- TransactionManager (class: org.jboss.tm.TxManager)
          +- TransactionPropagationContextExporter (class: org.jboss.tm.TransactionPropagationContextFactory)
          +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
          +- DefaultJMSProvider (class: org.jboss.jms.jndi.JBossMQProvider)
          +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
          +- Mail (class: javax.mail.Session)
          +- MinervaDS (class: org.jboss.pool.connector.jdbc.JDBCDataSource)
          +- timedCacheFactory (class: javax.naming.Context)
          Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy
          +- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory)
          +- comp (class: javax.naming.Context)
          +- MinervaNoTransCMFactory (class: org.jboss.pool.connector.jboss.MinervaNoTransCMFactory)

          Global JNDI Namespace
          +- TopicConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
          +- jmx (class: org.jboss.jmx.server.JMXAdaptorImpl)
          +- bonus (proxy: $Proxy2 implements Beans.BonusHome (no security manager: RMI class loader disabled))
          +- Calc (proxy: $Proxy3 implements Beans.CalcHome (no security manager: RMI class loader disabled))
          +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
          +- UserTransactionSessionFactory (class: org.jboss.tm.usertx.server.UserTransactionSessionFactoryImpl)
          +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
          +- invokers (class: org.jnp.interfaces.NamingContext)
          | +- Calc (class: org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker)
          | +- bonus (class: org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker)
          +- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
          +- UILXAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
          +- RMIXAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
          +- queue (class: org.jnp.interfaces.NamingContext)
          | +- D (class: org.jboss.mq.SpyQueue)
          | +- C (class: org.jboss.mq.SpyQueue)
          | +- B (class: org.jboss.mq.SpyQueue)
          | +- A (class: org.jboss.mq.SpyQueue)
          | +- controlQueue (class: org.jboss.mq.SpyQueue)
          | +- testQueue (class: org.jboss.mq.SpyQueue)
          | +- ex (class: org.jboss.mq.SpyQueue)
          | +- DLQ (class: org.jboss.mq.SpyQueue)
          | +- F (class: org.jboss.mq.SpyQueue)
          | +- E (class: org.jboss.mq.SpyQueue)
          +- topic (class: org.jnp.interfaces.NamingContext)
          | +- example (class: org.jboss.mq.SpyTopic)
          | +- testTopic (class: org.jboss.mq.SpyTopic)
          | +- bob (class: org.jboss.mq.SpyTopic)
          +- UILConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
          +- servercollector (class: org.jboss.management.ServerDataCollector)
          +- RMIConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
          +- jmx:xxxxxxxxxxxx:rmi (class: org.jboss.jmx.server.RMIConnectorImpl)
          +- QueueConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)

          What are we missing to get rid of the NoInitialContextException?
          Also, I don't understand in jndi why the CalcHome is shown as Calc instead of calcs. I thought that the <jndi-name> element overrode the <ejb-name> element in the namespace. Also does the "RMI class loader disabled" have any bearing?

          Thanks again.

          • 3. Re: Unable to obtain object reference in separate JVM
            Matt Newbie

            I think the solution is to change


            to java.naming.provider.url=hostRunningJBoss:1099 From the description you gave, your splitting web content and EJB content over two hosts. So the naming context factory in Tomcat needs to know the jndi server url.

            • 4. Re: Unable to obtain object reference in separate JVM
              G. Reno Newbie

              That is the ultimate goal, but for testing we still have the two servers located on the same machine so localhost will work for now.