users@glassfish.java.net

Re: Interop with Glassfish and other application servers

From: <glassfish_at_javadesktop.org>
Date: Thu, 20 Dec 2007 08:25:29 PST

Hi Chris,

> When deploying the EJB and the calling servlet within
> a single ear file i can inject the EJB in the servlet
> using the plan @EJB annotation without any problems.

Good start.

> When i split the ear into a war containing the
> servlet and a jar containing the EJB i can inject the
> EJB when i use the corbaname in the @EJB mappedName
> attribute and use the global JNDI name i specified
> with the @Stateless annotation's mappedName attribute
> in the EJB and deploy both archives on the same
> server instance. The injection on glassfish looks
> like this:
> @EJB(mappedName="corbaname:iiop:1.2_at_localhost:3700#NamedSecurityBean") private SecurityTest secTest;

When you have the ejb-jar and war deployed on the same server instance (or difference instances within a cluster), no need to use corbaname. A plain @EJB(mappedName="NamedSecurityBean") should work, since the global jndi-name NamedSecurityBean is unique server-wide. But using corbaname doesn't hurt anyway.


> But when i deploy the archives on different
> instances, even when they are of the same appserver
> type, the lookup fails. I am not using any ejb
> related tags in the web.xml and no deployment
> descriptors at all in the .jar file. The EJB
> interface is annotated as @Remote and the
> implementing bean as
> @Stateless(mappedName="NamedSecurityBean"). When
> listing all JNDI entries from a stand alone client i
> can see the NamedSecurityBean being displayed with
> exactly this name.

When the servlet access an EJB deployed on another glassfish server instance on the same or different host, and these 2 instances are not within a cluster, you need to use corbaname:
@EJB(mappedName="corbaname:iiop:1.2_at_host2:3700#NamedSecurityBean") private SecurityTest secTest;

-cheng

>
> Can anyone tell me, why this is only working within
> the same application server instance? I am really
> puzzled here, the JNDI name should be correct in my
> opinion since it was explicitly set in the @Stateless
> annotation.
>
> Thanks in advance, Chris
>
> Message was edited by: candlejack
[Message sent by forum member 'cf126330' (cf126330)]

http://forums.java.net/jive/thread.jspa?messageID=250997