users@glassfish.java.net

Is there a vendor independent way of accessing EJBs from a standalone client?

From: Ryan <ryan.j_at_vacode.com>
Date: Thu, 22 Feb 2007 03:43:27 -0600

Hi,

I'm working at setting up an application client and am having some
difficulty accessing EJBs on the server. I'm running my client using an
application client container and am trying it out on a few different
application servers.

However, I'm having difficulty finding a way to lookup EJBs in a vendor
independent manner. Specifically, almost every doc I can find has some
variation of:

Context initialContext = new InitialContext();
Object ref = initialContext.lookup("some vendor specific name here");

If I replace "some vendor specific name here" with the proper vendor
specific name for each app server and re-deploy everything works.

At first I thought I could use application-client.xml to name each EJB
and have the container(s) take care of the mapping, but I haven't had
any luck with this approach. I tried something like this (relevant
parts only):

<ejb-ref>
        <ejb-ref-name>ejb/test1234/ConnectionTester</ejb-ref-name>
        <ejb-ref-type>Session</ejb-ref-type>
        <remote>domain.ejb.interfaces.ConnectionTesterRemote</remote>
</ejb-ref>

When I deploy to Glassfish using the above I end up with a JNDI name of
"ejb/test1234/ConnectionTester" and can look it up using
"java:comp/env/ejb/test1234/ConnectionTester".

However, when I try to deploy to Geronimo, I get the following error
(while deploying):

org.apache.openejb.OpenEJBException: Cannot find bean
"ejb/test1234/ConnectionTester" referenced by bean "GeronimoEnc".

Obviously I'm missing something because Glassfish appears to use
'ejb-ref-name' as a type of alias for the EJB name while Geronimo thinks
it contains the name of an existing EJB.

Maybe I'm just not thinking clearly tonight, but isn't there some kind
of simple, standard way of looking up an EJB from a standalone client?
Is vendor independence even a realistic goal (that's what the spec is
for right)?

Thanks in advance for any help,
Ryan

P.S. Sorry for the formatting :-(