Local lookup for ejb beans

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Local lookup for ejb beans

Dignesh
Hi,

Can we use "openejb:global/global" as JNDI prefix when doing the local ejb lookup instead of "java:global".

The problem is in general that "new InitialContext()" is not always the same.It depends in which thread/classloader this call is made. As long as you call it within an EJB or Servlet and appropriate thread you see everything. I have logged the JNDI tree, once within an approriate thread/classloader and once outside it .So Can we use openejb:global/global as JNDI prefix to access the beans within the TomEE ?


Thank you,
Dignesh,
Reply | Threaded
Open this post in threaded view
|

Re: Local lookup for ejb beans

Romain Manni-Bucau
Hi

Le 8 avr. 2017 10:46, "Dignesh" <[hidden email]> a écrit :

Hi,

Can we use "openejb:global/global" as JNDI prefix when doing the local ejb
lookup instead of "java:global".



No






The problem is in general that "new InitialContext()" is not always the
same.It depends in which thread/classloader this call is made. As long as
you call it within an EJB or Servlet and appropriate thread you see
everything. I have logged the JNDI tree, once within an approriate
thread/classloader and once outside it .So Can we use openejb:global/global
as JNDI prefix to access the beans within the TomEE ?


Passing as context factory openejb one you would get stable names



Thank you,
Dignesh,



--
View this message in context: http://tomee-openejb.979440.
n4.nabble.com/Local-lookup-for-ejb-beans-tp4681498.html
Sent from the TomEE Dev mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: Local lookup for ejb beans

Dignesh
Hi Romain,
 I haven't understood what below means.
Passing as context factory openejb one you would get stable names

Does it mean I need to pass CONTEXT_FACTORY something similar to way i do the remote look up ?
"INITIAL_CONTEXT_FACTORY"="org.apache.openejb.client.RemoteInitialContextFactory"

Reply | Threaded
Open this post in threaded view
|

Re: Local lookup for ejb beans

Romain Manni-Bucau
Yes but in local lookup mode, see
http://tomee.apache.org/advanced/client/jndi.html

Le 8 avr. 2017 10:57, "Dignesh" <[hidden email]> a écrit :

> Hi Romain,
>  I haven't understood what below means.
> Passing as context factory openejb one you would get stable names
>
> Does it mean I need to pass CONTEXT_FACTORY something similar to way i do
> the remote look up ?
> "INITIAL_CONTEXT_FACTORY"="org.apache.openejb.client.
> RemoteInitialContextFactory"
>
>
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.
> n4.nabble.com/Local-lookup-for-ejb-beans-tp4681498p4681500.html
> Sent from the TomEE Dev mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: Local lookup for ejb beans

Dignesh
This post was updated on .
Hi Romain,
 I already did that passing .it did not work.Do we Need to add  some other property apart from context factory in local lookup mode ?
May I know the reason why we cannot use openejb:global/global?
Reply | Threaded
Open this post in threaded view
|

Re: Local lookup for ejb beans

Romain Manni-Bucau
Le 8 avr. 2017 12:57, "Dignesh" <[hidden email]> a écrit :

Hi Romain,
 I already did that passing that.it did not work.Do we Need to ass some
other property apart from context factory in local lookup mode ?


No

Maybe you dont use the right name?

May I know the reason why we cannot use openejb:global/global?


Sure: it is not bound, why should it work? All EJB are bound there but not
with global/global.





--
View this message in context: http://tomee-openejb.979440.
n4.nabble.com/Local-lookup-for-ejb-beans-tp4681498p4681504.html
Sent from the TomEE Dev mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: Local lookup for ejb beans

Dignesh
Hi Romain,
Below is the snip of code I have used.

Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.OpenEJBInitialContextFactory");
final Context ctx = new InitialContext(properties);


When I use openejb: global/global local jndi lookup is successful
Reply | Threaded
Open this post in threaded view
|

Re: Local lookup for ejb beans

Romain Manni-Bucau
It forces you to use tomee lookups and bypass contextuality (tomcat per
classloader context) yes. Then not sure i followed the naming of your
example but happy if it works.

However openejb/global and openejb/Deployment etc.. subtrees are internals
so not guanranteed to work

Le 8 avr. 2017 16:06, "Dignesh" <[hidden email]> a écrit :

> Hi Romain,
> Below is the snip of code I have used.
>
> Properties properties = new Properties();
> properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
> "org.apache.openejb.core.OpenEJBInitialContextFactory");
> final Context ctx = new InitialContext(properties);
>
>
> When I use openejb: global/global local jndi lookup is successful
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.
> n4.nabble.com/Local-lookup-for-ejb-beans-tp4681498p4681506.html
> Sent from the TomEE Dev mailing list archive at Nabble.com.
>