4 Replies Latest reply on Sep 8, 2008 8:12 AM by jaikiran

    JBoss Returns java.naming.Reference instead of the actual ob

      Hello,
      I am running JBoss 4.0.2. I have 2 instances of JBoss A & B
      A has HAJNDI and JMS on it
      B is A's client.
      B looks up a queue on A over JNDI using Spring (2.0.5, JmsTemplate) and gets a java.naming.Reference object. It then bombs because it expects a queue.
      When I try to lookup the same object from a stand-alone java application, I get a reference to SpyQueue and all is well.
      For what it is worth, I tried to trace the NamingServer. For requests from JBoss, it goes to NamingServer but for request from the stand-alone application, it goes to TreeHead.
      I am at the end of my rope here. I would really appreciate any help I can get.
      Thank you

        • 1. Re: JBoss Returns java.naming.Reference instead of the actua
          jaikiran

          Please post the entire exception stacktrace, your JNDI lookup code (along with the jndi name you are using) and also the output of JNDI tree (follow the steps mentioned here http://wiki.jboss.org/wiki/DisplayTheJNDITreeWithTheJMXConsole)

          While posting the logs or xml content or code, remember to wrap it in a code block using the Code button in the message editor window and please hit the Preview button to make sure your post is correctly formatted

          • 2. Re: JBoss Returns java.naming.Reference instead of the actua

            Jaikiran,
            Thank you very much for your time and interest.
            JBoss - 4.0.2, Java 1.5.10
            I got Spring completly out of the eqation to keep this straight. I wrote a lookup for to the testQueue (I think the queue came with stock JBoss). This is the standalone version. I simply run it from Eclipse. -
            This works OK

            /**
             *
             */
            package jndi.tryit;
            
            import java.util.Hashtable;
            
            import javax.jms.Queue;
            import javax.naming.Context;
            import javax.naming.InitialContext;
            import javax.naming.NamingException;
            
            public class LookupJBossJmsQueue {
             public static void main(String[] args) {
             // Set up environment for creating the initial context
             Hashtable env = new Hashtable();
             env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
             env.put(Context.PROVIDER_URL, "jnp://localhost:1100");
             env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
             try {
             Context ctx = new InitialContext(env);
             Object jndiObject = ctx.lookup("queue/testQueue");
             Queue queue = (Queue) jndiObject;
             System.out.println("Looked up this Object: " + jndiObject);
            
             } catch (NamingException e) {
             // TODO Auto-generated catch block
             System.out.println("Exception in " + "main " + e);
             }
             }
            }
            
            

            Here is the code running from inside a JBoss MBean. At this point it is simply looking up the queue, not actually trying to send anything to the queue. This "client JBoss" is running on the same machine as the "server JBoss" with client using "ports-02" port mapping. Both JBoss are version 4.0.2
            It prints the line "Got the object as class java.jms.Reference"
            This does NOT work
             public void sendObjectMessage(Serializable payload) {
             Hashtable<String, String> env = new Hashtable<String, String>();
             env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
             env.put(Context.PROVIDER_URL, "jnp://localhost:1100");
             env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
             try {
             Context ctx = new InitialContext(env);
             Object jndiObject = ctx.lookup("queue/testQueue");
             if (jndiObject instanceof Queue) {
             Queue queue = (Queue) jndiObject;
             log.debug("Got the object as a Queue");
             }else{
             log.debug("Got the object as " + jndiObject.getClass());
             }
            
             } catch (NamingException e) {
             log.error("Error looking up" + e);
             }
             }
            

            Here is the JNDI tree on JMS server
            java: Namespace
             +- jaas (class: javax.naming.Context)
             | +- JmsXARealm (class: org.jboss.security.plugins.SecurityDomainContext)
             | +- jbossmq (class: org.jboss.security.plugins.SecurityDomainContext)
             | +- HsqlDbRealm (class: org.jboss.security.plugins.SecurityDomainContext)
             +- TransactionPropagationContextImporter (class: org.jboss.tm.TransactionPropagationContextImporter)
             +- JmsXA (class: org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl)
             +- JBossCorbaNaming (class: org.omg.CosNaming.NamingContextExt)
             +- DefaultDS (class: javax.sql.DataSource)
             +- StdJMSPool (class: org.jboss.jms.asf.StdServerSessionPoolFactory)
             +- TransactionManager (class: org.jboss.tm.TxManager)
             +- JBossCorbaPOA (class: org.omg.PortableServer.POA)
             +- TransactionPropagationContextExporter (class: org.jboss.tm.TransactionPropagationContextFactory)
             +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
             +- DefaultJMSProvider (class: org.jboss.jms.jndi.JNDIProviderAdapter)
             +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
             +- JBossCorbaInterfaceRepositoryPOA (class: org.omg.PortableServer.POA)
             +- Mail (class: javax.mail.Session)
             +- JBossCorbaORB (class: org.omg.CORBA.ORB)
             +- 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)
            
            Global JNDI Namespace
             +- HASessionState (class: org.jnp.interfaces.NamingContext)
             | +- Default (class: org.jboss.ha.hasessionstate.server.HASessionStateImpl)
             +- jmx (class: org.jnp.interfaces.NamingContext)
             | +- invoker (class: org.jnp.interfaces.NamingContext)
             | | +- RMIAdaptor (proxy: $Proxy37 implements interface org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface org.jboss.jmx.adaptor.rmi.RMIAdaptorExt)
             | +- rmi (class: org.jnp.interfaces.NamingContext)
             | | +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class: javax.naming.LinkRef)
             +- JAXR (class: org.apache.ws.scout.registry.ConnectionFactoryImpl)
             +- HTTPXAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
             +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
             +- UserTransactionSessionFactory (proxy: $Proxy11 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
             +- HTTPConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
             +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
             +- invokers (class: org.jnp.interfaces.NamingContext)
             | +- pkhanwale-lt (class: org.jnp.interfaces.NamingContext)
             | | +- iiop (class: org.jboss.invocation.iiop.IIOPInvoker)
             +- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
             +- UILXAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
             +- UIL2XAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
             +- HAPartition (class: org.jnp.interfaces.NamingContext)
             | +- PKPartation (class: org.jboss.ha.framework.server.HAPartitionImpl)
             +- queue (class: org.jnp.interfaces.NamingContext)
             | +- A (class: org.jboss.mq.SpyQueue)
             | +- testQueue (class: org.jboss.mq.SpyQueue)
             | +- ex (class: org.jboss.mq.SpyQueue)
             | +- DLQ (class: org.jboss.mq.SpyQueue)
             | +- D (class: org.jboss.mq.SpyQueue)
             | +- C (class: org.jboss.mq.SpyQueue)
             | +- B (class: org.jboss.mq.SpyQueue)
             +- topic (class: org.jnp.interfaces.NamingContext)
             | +- testDurableTopic (class: org.jboss.mq.SpyTopic)
             | +- testTopic (class: org.jboss.mq.SpyTopic)
             | +- securedTopic (class: org.jboss.mq.SpyTopic)
             +- console (class: org.jnp.interfaces.NamingContext)
             | +- PluginManager (proxy: $Proxy38 implements interface org.jboss.console.manager.PluginManagerMBean)
             +- UIL2ConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
             +- HiLoKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory)
             +- UILConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
             +- UUIDKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.uuid.UUIDKeyGeneratorFactory)
            

            What am i doing wrong? Do you need more information?

            • 3. Re: JBoss Returns java.naming.Reference instead of the actua

              Jaikiran, thanks again for taking a look at this but for this instance, I think I figured it out (after much debuging). I ASSUMED that my client JBoss will automatically have access to jbossall-client.jar. That as I know now was a silly assumption, like most assumptions. For what it is worth, I debuged my standalone code and my JBoss code. They followed the same path until NamingManager, line 303, at which time the JBoss client tried to load ObjectFactory from reference and bombed since it couldn't load the class. On the standalone side, I had included it in the classpath. My solution - add jbossall-client.jar to my "jboss client" 's lib directory. It works now. Obviously, if this is not the way to solve it, please correct me, but I think this was a classpath issue. Commets/corrections will be greatly appreciated

              • 4. Re: JBoss Returns java.naming.Reference instead of the actua
                jaikiran

                 

                "pskhanwale" wrote:
                Obviously, if this is not the way to solve it, please correct me, but I think this was a classpath issue. Commets/corrections will be greatly appreciated


                What you have done is correct. I remember discussing a similar issue in the forum (long time back) where the classpath was missing the required jar file, which resulted in the java.naming.Reference object being returned.