In a servlet listener for my webapp, I'm using this:

    public void contextInitialized(ServletContextEvent aArg0)
    {
        System.setProperty(Context.INITIAL_CONTEXT_FACTORY,   
            "org.apache.openejb.client.LocalInitialContextFactory");
        System.err.println(">>>>>>> FULL JNDI TREE FROM STARTUP");
        try {
            InitialContext ic = new InitialContext();
            listContext("",ic);
        } catch (NamingException e) {
            System.err.println("Could not list tree."+e);            
        }
        System.err.println("<<<<<<< FULL JNDI TREE FROM STARTUP");              
  
    }

    private static final void listContext(String s, Context c) throws
NamingException
    {
        NamingEnumeration<NameClassPair> pairs = c.list("");
        for (; pairs.hasMoreElements();)
        {
            NameClassPair p = pairs.next();
            System.err.println(s+"/"+p.getName() + " " + p.getClassName());
            Object o = c.lookup(p.getName());
            if (o instanceof Context)
            {
                Context child = (Context) o; 
                listContext(s+"/"+p.getName(), child);
            }
        }
    }

And here's what I get:
/. java.lang.String
/openejb org.apache.openejb.core.ivm.naming.IvmContext
/openejb/ConfigurationInfoBusinessRemote
org.apache.openejb.core.ivm.naming.Busi
nessRemoteReference
/openejb/DeployerBusinessRemote
org.apache.openejb.core.ivm.naming.BusinessRemot
eReference
...and then other contexts created by my MDB/SB.

I don't see any /openejb/TransactionManager there.

        /Zog


David Blevins wrote:
> 
> 
> On Oct 8, 2008, at 12:37 PM, Zog wrote:
> 
>> I installed the openejb.war in tomcat-6.0.18 and my ear as a  
>> collapsed ear.
>> When I lookup objects in the JNDI tree, I realized that I can freely  
>> look up
>> injected resources (I use the <resource-ref> in ejb-jar.xml for ex  
>> for data
>> sources),
>> but non injected are failing - is this normal ?
>> Specifically, one of my ejb is doing
>> InitialContext ic = new InitialContext(); // Properly initialized  
>> with the
>> OpenEJB ICfactory
>> ic.lookup("openejb/TransactionManager");
>> and this always throws a NameNotFoundException.
> 
> Hmm.  If it was created with the LocalInitialContextFactory as so..
> 
>   Properties properties = new Properties();
>   properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,  
> "org.apache.openejb.client.LocalInitialContextFactory");
> 
>   InitialContext initialContext = new InitialContext(properties);
> 
> Then it should definitely work.  If it was done as so...
> 
>   InitialContext initialContext = new InitialContext();
> 
> Then I'm not as confident that it will work.  We have code in the  
> integration to add the "openejb" subcontext into the webapp's jndi  
> context, or so I thought.  I added code along these lines, but it's  
> been while and I can't recall the details.  Maybe in this second case  
> you have to lookup "java:openejb/TransactionManager".
> 
> Can you verify which technique you are using?
> 
> 
> -David
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/JNDI-lookup-in-Tomcat-tp19883726p19898308.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to