How to Call Geronimo 2.2 Local EJB using JNDI


Permalink 09:31:30 pm, by david Email , 428 words, 60296 views   English (US)
Categories: SOA Solutions in South East Asia

How to Call Geronimo 2.2 Local EJB using JNDI

I had searched high and low for a solution to this. Seems like all the solution examples on Geronimo’s web site were using annotations and everything else I looked at seemed to draw a complete blank. Never being one to give up that easily I decided to hack my way through it. The first trick to be aware of is that like all the other services in Geronimo, the OpenEJB services are installed into the server by means of a resource adapter GBean. This doesn’t matter that much other than that you need to consider this when searching for a solution. So the first thing I did was set up an initial context in my EJB client code (the scenario is Session EJB calls another session EJB using local interface). The following code fragment shows how to set up the initial context call:


Properties props = new Properties();
      Context ic = new InitialContext(props);

Note that I use “org.openejb.client.LocalInitialContextFactory” as the JNDI context factory class.

The second interesting fact has to do with the way in which OpenEJB exposes JNDI resources. When an EJB is deployed with both local and remote interfaces in most containers the java:comp/env namespace is used to provide access to local interface EJB resources. In Geronimo 2.2 with OpenEJB this definitely does not work at all. What actually happens is that an additional EJB interface is exposed as a “Local” interface. For example if I had deployed an EJB with the following components:

1) FooSessionEJBLocal - local interface
2) FooSessionEJBRemote - remote interface
3) FooSessionEJBBean - the actual session bean

… then OpenEJB will expose FooSessionEJBBean (the remote bean) and another curiously named EJB FooSessionEJBBeanLocal (the local bean). Only the latter can be cast to the FooSessionEJBLocal interface so for example when performing a lookup your code should look like this:


try {
  Properties props = new Properties();
  props.setProperty("java.naming.factory.initial", "org.openejb.client.LocalInitialContextFactory");
  Context ic = new InitialContext(props);
  FooSessionEJBLocal localFoo =  ic.lookup("FooSessionEJBBeanLocal");;
} catch (Exception e){
  ... do whatever

Note that the lookup is for “FooSessionEJBBeanLocal” and not “FooSessionEJBLocal". Also note that if you try to bind the remote EJB (FooSessionEJBBean) you can do so but that transactional context of using local EJB will not be managed by JTA (this is important if your code is dependent on operations within the context of the current container transaction).

Truth be told I was amazed that nobody on any of the Geronimo mailing lists had figured this out or had posted a workable solution.

Trackback address for this post:

This is a captcha-picture. It is used to prevent mass-access by robots.
Please enter the characters from the image above. (case insensitive)

Comments, Trackbacks, Pingbacks:

Comment from: Toronto Local SEO Service [Visitor] ·
Heya! I'm at work surfing around your blog from my new iphone 3gs!
Just wanted to say I love reading through your blog and look forward to all your posts!
Keep up the great work!
PermalinkPermalink 07/15/15 @ 20:16
Comment from: landscapting [Visitor] ·
I am regular visitor, how are you everybody? This article posted at this website is actually
PermalinkPermalink 11/13/15 @ 10:53
Comment from: seo services [Visitor] ·
An outstanding share! I have just forwarded
this onto a coworker who has been doing a little homework on this.
And he actually bought me breakfast due to the fact that I found
it for him... lol. So allow me to reword
this.... Thanks for the meal!! But yeah, thanks for spending
some time to talk about this topic here on your blog.
PermalinkPermalink 11/21/15 @ 09:48
Hello there! This article could not be written any
better! Going through this article reminds me of
my previous roommate! He continually kept preaching
about this. I most certainly will forward this article to
him. Pretty sure he's going to have a great read. Thanks
for sharing!
PermalinkPermalink 11/22/15 @ 20:07
Comment from: seo service [Visitor] ·
Hey there! I've been following your blog for
some time now and finally got the courage to go ahead and give you a shout out from Dallas Tx!
Just wanted to say keep up the good work!
PermalinkPermalink 11/24/15 @ 21:27
Comment from: seo service [Visitor] ·
Thank you for the auspicious writeup. It in fact was a amusement account it.

Look advanced to more added agreeable from you! By the way, how could we
PermalinkPermalink 11/24/15 @ 21:30
Comment from: seo service [Visitor] ·
Hi to every one, the contents present at this web site are
in fact awesome for people experience, well, keep up the nice work fellows.
PermalinkPermalink 11/24/15 @ 22:35
Comment from: รับทำ SEO [Visitor] ·
Heya i am for the primary time here. I came across this board and I
find It truly helpful & it helped me out a
lot. I'm hoping to offer something again and help others such as you helped me.
PermalinkPermalink 11/30/15 @ 06:35
Comment from: chemicals lab [Visitor] ·
Hurrah, that's what I was searching for, what a stuff!
present here at this blog, thanks admin of this web page.
PermalinkPermalink 12/09/15 @ 22:37
Comment from: shoes [Visitor] ·
Amazing blog! Is your theme custom made or did you download it from
somewhere? A theme like yours with a few simple tweeks would really make my blog jump out.
Please let me know where you got your design. Thanks
PermalinkPermalink 12/13/15 @ 00:45
Comment from: Alysa [Visitor] ·
Смотрите лучше здесь:
ландшафтный дизайн (Ollie)
PermalinkPermalink 05/20/17 @ 22:29
Comment from: Sylvia [Visitor] ·
Эрофорс купить в Украине
EroForce — капсулы для потенции,
которые оказываўт комплексное воздействие на мужской организм.
Это средство способно решить множество
проблем, начиная с ослабления либидо и заканчивая полной импотенцией.
Препарат снова вернёт радость от секса.

Капсулы Eroforce практически не имеўт аналогов по своему воздействиў
и обладаўт массой достоинств по сравнениў с похожими средствами:
быстрый длительный эффект;
натуральный состав;
усиление либидо;
капсулы не просто маскируўт, а излечиваўт и
устраняўт проблему полностьў;
продлеваўт половой акт;
делаўт ощущения более яркими;

не имеўт противопоказаний;
удобны в применении.
PermalinkPermalink 06/01/17 @ 10:35

Leave a comment:

Your email address will not be displayed on this site.
Your URL will be displayed.

Allowed XHTML tags: <p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, span, bdo, br, em, strong, dfn, code, samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small>
(Line breaks become <br />)
(Set cookies for name, email and url)
(Allow users to contact you through a message form (your email will NOT be displayed.))
This is a captcha-picture. It is used to prevent mass-access by robots.
Please enter the characters from the image above. (case insensitive)

Hosted by:
hosted by PWS Consulting

The South East Asia SOA Weblog

The intention of this blog is to collect thoughts on the issues, paradigms, process, vendors, solutions, project and any other item related service oriented architecture in South East Asia.

June 2017
Sun Mon Tue Wed Thu Fri Sat
 << <   > >>
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30  


XML Feeds

What is RSS?

Who's Online?

  • Guest Users: 48