users@glassfish.java.net

RE: Cross reference between EJB's in the same application

From: Ori Dagan <ori.dagan_at_gmail.com>
Date: Sat, 25 Jul 2009 22:09:54 +0200

Actually I was too quick to celebrate.

 

Using beanName did allow me to deploy the app, but on runtime, when I’m
trying to access the bean, I am getting:

“javax.naming.NamingException: Lookup failed for 'java:module/Ejb1’”

Which make sense because the bean is in a different module and should be
looked up in ‘java:app/war1/Ejb1’.

 

According to this, the global JNDI names could and should be used also for
local interfaces:

http://docs.sun.com/app/docs/doc/820-7627/gipjf?a=view

 

Any one has a clue how this could be done?

 

Thanks,

Ori

 

From: Martin Gainty [mailto:mgainty_at_hotmail.com]
Sent: Saturday, July 25, 2009 4:57 PM
To: Users GlassFish.dev.java.net
Subject: RE: Cross reference between EJB's in the same application

 

use bean-name instead of mapped-name

mapped-name: Specifies the product-specific name of the target Remote EJB.
In SUN's case, this refers to the global JNDI name of the target Remote EJB.
Not applicable for local interfaces because beanName() can always be used.

bean-name: ejb-name (*not* global JNDI name) of the target ejb within the
application. This can be used whenever the target ejb is defined within
the same application as the referencing component, regardless of local vs.
remote. The only time it can't be used is if the @EJB refers to a Remote
interface (3.0 or 2.x) that is defined outside the application.
use bean-name for ejbs within application

https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html

accessing EJBs in TC or Resin
https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#nonJavaEEwebcontaine
rRemoteEJB

hth
Martin Gainty
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte
Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht
dient lediglich dem Austausch von Informationen und entfaltet keine
rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von
E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.

Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
destinataire prévu, nous te demandons avec bonté que pour satisfaire
informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie
de ceci est interdite. Ce message sert à l'information seulement et n'aura
pas n'importe quel effet légalement obligatoire. Étant donné que les email
peuvent facilement être sujets à la manipulation, nous ne pouvons accepter
aucune responsabilité pour le contenu fourni.







  _____

From: ori.dagan_at_gmail.com
To: users_at_glassfish.dev.java.net
Date: Sat, 25 Jul 2009 17:21:06 +0200
Subject: Cross reference between EJB's in the same application

Hi,

 

I’m trying to deploy an EAR with two WARs. Each WAR has a local interface
EJB and a proxy to the other WAR’s EJB.

Here is the code:

 

war1:

 

@Stateless

public class Ejb1 implements War1interface

{

      @EJB(mappedName="java:app/war2/Ejb2")

      War1interface ejb;

 

      @Override

      public void do1()

      {

      }

}

 

war2:

 

@Stateless

public class Ejb2 implements War2interface

{

      @EJB(mappedName="java:app/war1/Ejb1")

      War1interface ejb;

 

      @Override

      public void do2()

      {

      }

 

}

 

When trying to deploy, I’m getting:

“Error: Unresolved <ejb-link>: war1.war#Ejb1”

 

Actually, this can also be reproduced without cyclic referencing. If I
remove the EJB annotation from Ejb2, then the ear get deployed fine. On the
other hand, if I remove the EJB annotation from Ejb1, I am getting the same
error. This leads me to believe that it has to do with the order the ejb
container is publishing the EJB’s.

 

I am using glassfish v3 preview b56.

 

Is this a bug or am I missing something here?

 

Thanks,

Ori

 

 

 

  _____

Windows Live™ SkyDrive™: Store, access, and share your photos. See how.
<http://windowslive.com/Online/SkyDrive?ocid=TXT_TAGLM_WL_CS_SD_photos_07200
9>