On 5/31/2013 10:14 AM, Romain Manni-Bucau wrote:
And if you lookup java:global/jdbc/**MyDataSource it works?

Yes it works, also if I do a ctx.lookup("java:global/jdbc").listbindings(), is there as well, but If I do ctx.lookup("java:global").listbindings() , there is no "jdbc" context there, which I find odd. Also the bean I'm using to test this is nowhere to be found in "java:", it's in "openejb:" though, which also has objects/context not found anywhere else.

I just thought that if I could use a resource/object in my EJB, it would be logically found by looking recursively through the InitialContext tree, but that is not true.

basically tomee is done of multiple context apparently merged (for lookup).
Your datasource is in the globale context whenre the simple context us the
internal one (may depend on your envrt) and the java: is the bean java: one

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/5/31 Fawzib Rojas <[email protected]>

I have a datasource resource added in tomee.xml (java:global/jdbc/**
MyDataSource)

AFAIK, a Context is like a directory for objects, you enter the path you
find the object, so I made a function to walk through the context tree.

When I try to walk the InitialContext, is always empty (why, shouldnt the
"java:" context be there?)

When I try context.lookup("java:") I get:
    1) module (Context)
         a) global (Context)
     2) global (Context)
     3) comp (Context)
         a) env (Context)
         b) other objects (ORB/TimerService, etc)
     4) app (Context)

But my datasource is not inside java:global, I imagine there should be a
jdbc context inside java:global (#2) with my datasource inside but there
isnt. Yet if I lookup("java:global/jdbc"), my datasource is listed.



Reply via email to