[jboss-user] [JNDI/Naming/Network] - Self referencing Session Bean

magicroomy do-not-reply at jboss.com
Wed May 27 03:58:51 EDT 2009


Hi,
in our JEE App (JEE5) we got several Session Beans (Stateless). Some SBs need others. Every SB got a @Stateless (name=...) Annotation.
Every SB uses JNDI Lookup to get References to the others SBs.
Therefore a @EJB Annotation is placed for the SB Class to indicate the need for other SBs.

Example SB1 needs to access methods of SB2.

@Stateless (name="SB1")
@EJB( name = "SB2", beanInterface = SB2.class)
class SB1
{
...
    JNDIlookup("java:comp/env/SB2") ;


@Stateless (name="SB2")
class SB2
{
...


Everything works fine here. No problem.
Now SB1 needs to call a method from itself, but not via simple method call but also via a JNDI-lookup-up instance, to be able to have a different transactiontype
Question #1 is: does SB1 need a @EJB Annotation to itself?

If Answer is yes there is the second question:
Question #2: How is the @EJB Ref specified.

I tried:

@Stateless (name="SB1")
@EJB( name = "SB1", beanInterface = SB1.class)
class SB1
{
...
    JNDIlookup("java:comp/env/SB1") ;

Already in the deployment phase JBoss complains (Name SB1 => CMManagement):

DEPLOYMENTS MISSING DEPENDENCIES:
  Deployment "jboss.j2ee:ear=EJB30Reference.ear,jar=sb.jar,name=CMManagement,service=EJB3" is missing the following dependencies:
    Dependency "<UNKNOWN jboss.j2ee:ear=EJB30Reference.ear,jar=sb.jar,name=CMManagement,service=EJB3>" (should be in state "Described", but is actually in state "** UNRESOLVED Demands 'jndi:EJB30Refer
ence/CMManagement/remote-de.heitec.ejb3.cm.model.sb.CMManagement' **")
  Deployment "jboss.j2ee:ear=EJB30Reference.ear,jar=sb.jar,name=CMManagement,service=EJB3_endpoint" is missing the following dependencies:
    Dependency "jboss.j2ee:ear=EJB30Reference.ear,jar=sb.jar,name=CMManagement,service=EJB3" (should be in state "Configured", but is actually in state "PreInstall")

DEPLOYMENTS IN ERROR:
  Deployment "<UNKNOWN jboss.j2ee:ear=EJB30Reference.ear,jar=sb.jar,name=CMManagement,service=EJB3>" is in error due to the following reason(s): ** UNRESOLVED Demands 'jndi:EJB30Reference/CMManagement
/remote-de.heitec.ejb3.cm.model.sb.CMManagement' **

If i introduce mappedName in the @Stateless and the @EJB everything works, but i do not want to use mappedName if not really necessary.

Any Ideas what the "correct" way is for a SB to  reference itself?

Greetings, 
Volker



View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4233488#4233488

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4233488



More information about the jboss-user mailing list