[jboss-user] [JNDI/Naming/Network] - Re: JBoss Returns java.naming.Reference instead of the actua

pskhanwale do-not-reply at jboss.com
Sun Sep 7 19:16:46 EDT 2008


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?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4174872#4174872

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4174872



More information about the jboss-user mailing list