Ok I have been looking around and I think things are clearer now.

First the fact that POJOs are involved is irrelevant, if a class is called from a 
session bean the code is running within the session bean, nothing more than that.

The reason for asking for additional deployment descriptors was to check for any typos 
that you might have missed, in the past I have spent time on similar issues not 
noticing one character is different.  I now know that this is not your issue here, 
although the typos in your post proved how easy they are to make.

I did a search on Google and found the following article: -

http://www.developer.com/java/ejb/article.php/3069981

Are you using the EJB connection factory described in the article?  This basically 
means that the code you are looking at is not your lookup code, it is calling a method 
that modifies the name to perform the lookup.

home = initialContext.lookup("java:comp/env/ejb/" + 
  |                   ejbReferenceComponent);

The component is being looked up in the java:comp/env namespace, the way to get 
references into this namespace is by using the ejb-local-ref elements in the session 
bean definition.

Also requiring /ejb/ in the name means that the value for <ejb-ref-name> must contain 
ejb/

This basically means that for every session bean you need to ejb-ref every other 
component that it is going to make use of.

I would reccomend that you scrap the EJB Connection factory or change it so that it is 
not based on a singleton as the design is flawed and I think that this is leading to 
your problem.

Consider the following scenario:- 

You have three session beans A, B, and C

A has a ref to C.  B does not have a ref to anything.

A is executed first, it calls 'lookupByLocalEJBReference' to obtain a reference to C.  
As A has a link to C the lookup works and the home interface C is placed in the cache.

B is then executed and also calls 'lookupByLocalEJBReference' to obtain a reference to 
C, as the EJB Connection factory is a singleton B uses the same instance as A.  The 
home interface to C is in the cache so is returned to C and everything appears to be 
working fine.

How it stops working

If B was to be called first and attempt to lookup C when the cache is empty the JNDI 
lookup would be performed.  However as B does not contain the link to C the lookup 
will fail and the NamingException will be thrown.



Also FYI when adding ejb-ref or ejb-local-ref elements for components defined in the 
same deployment descriptor you do not need to add anything to the JBoss deployment 
descriptor, having a <ejb-link> element is enough information for JBoss to find the 
correct component.

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

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


-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM. 
Deadline: Sept. 13. Go here: http://sf.net/ppc_contest.php
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to