2 Replies Latest reply on Jul 19, 2006 12:05 PM by Joao Mota

    Unable to do a lookup for a Context in Sun One from within J

    Joao Mota Newbie

      Hello,

      im having trouble with the configuration required to do a lookup of a context in a Sun One from my web-application that is running inside JBoss. What im trying to to do is getting a QueueConnectionFactory and a Queue. I have done a small client application to test the lookups and configuration outside of Jboss and it works ok, but when running inside Jboss 4.03-sp1 doesn't.

      the relevant code snip (with replaced ips and jndi paths)

      Properties env = new Properties();
       env.put("java.naming.factory.initial", "com.sun.appserv.naming.S1ASCtxFactory");
       env.put("java.naming.provider.url", "iiop://xpto:7000");
       Context jndiContext = null;
       try {
      
       jndiContext = new InitialContext(env);
      
       QueueConnectionFactory connectionFactory = (QueueConnectionFactory) jndiContext
       .lookup("Path/QueueConnectionFactory");
      
       Queue queue = (Queue) jndiContext.lookup("Path/MessageQueue");
      
       } catch (NamingException e) {
       System.out.println("Could not create JNDI API " + "context: " + e.toString());
       e.printStackTrace();
       }


      i keep getting Path not Bound Exceptions

      The problem is that the InitialContext is ignoring the properties i pass to it, in particular the java.naming.factory.initial, and return to me the local InitialContext.

      I have tried the following:
      changed the value of conf/jndi.properties to use org.jboss.iiop.naming.ORBInitialContextFactory instead of org.jnp.interfaces.NamingContextFactory but the situation didn't changed.

      also tried to use the ExternalContextMBean

      <mbean code="org.jboss.naming.ExternalContext"
       name="jboss.jndi:service=ExternalContext,jndiName=Path/MessageQueue">
       <attribute name="JndiName">external/MessageQueue</attribute>
       <attribute name="CacheContext">true</attribute>
       <attribute name="RemoteAccess">true</attribute>
       <attribute name="Properties">
       java.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory
       java.naming.factory.host=iiop://xpto
       java.naming.factory.port=7000
       </attribute>
       <attribute name="InitialContext">javax.naming.InitialContext</attribute>
       </mbean>
      
      
       <mbean code="org.jboss.naming.ExternalContext"
       name="jboss.jndi:service=ExternalContext,jndiName=Path/QueueConnectionFactory">
       <attribute name="JndiName">external/QueueConnectionFactory</attribute>
       <attribute name="CacheContext">false</attribute>
       <attribute name="RemoteAccess">true</attribute>
       <attribute name="Properties">
       java.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory
       java.naming.factory.host=iiop://xpto
       java.naming.factory.port=7001
       </attribute>
       <attribute name="InitialContext">javax.naming.InitialContext</attribute>
      
       </mbean>
      


      and done the lookups by "external/QueueConnectionFactory" but kept getting external not bound, even thou the jndi view show them:

      +- external (class: org.jnp.interfaces.NamingContext)
       | +- QueueConnectionFactory (class: javax.naming.Context)
       | | +- SerialContextProvider (class: com.sun.corba.se.internal.iiop.CDRInputStream_1_0$1)
       | | | +- ejb (class: com.sun.jndi.cosnaming.CNCtx)
       | | | | +- mgmt (class: com.sun.jndi.cosnaming.CNCtx)
       | | | | | +- MEJB (class: com.sun.corba.se.internal.iiop.CDRInputStream_1_0$1)
       | +- MessageQueue (class: javax.naming.Context)
       | | +- SerialContextProvider (class: com.sun.corba.se.internal.iiop.CDRInputStream_1_0$1)
       | | | +- ejb (class: com.sun.jndi.cosnaming.CNCtx)
       | | | | +- mgmt (class: com.sun.jndi.cosnaming.CNCtx)
       | | | | | +- MEJB (class: com.sun.corba.se.internal.iiop.CDRInputStream_1_0$1)
       ...
       +- queue (class: org.jnp.interfaces.NamingContext)
       | +- testQueue (class: org.jboss.mq.SpyQueue)
      


      Im able to do a lookup on the queue Context and on the testQueue.


      How can i set up things to do the lookups?

      thank you,
      Joao