Here is an example from J2EE tutorial:
http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/BMP4.html#63437
public void setEntityContext(EntityContext context) {
this.context = context; customerIds = new ArrayList();
try {
makeConnection();
Context initial = new InitialContext();
Object objref =
initial.lookup("java:comp/env/ejb/Customer");customerHome =
(CustomerHome)PortableRemoteObject.narrow(objref,
CustomerHome.class);
} catch (Exception ex) {
throw new EJBException("setEntityContext: " +
ex.getMessage());
}
}While not the definitive source, the spec is vague in this regard. In any case, I have been doing home lookups in setEntityContext() ever since I started using EJB, and have not had any problems. This was working ok under Orion 1.5.3, but stopped working now.
I would not mind refactoring the code, but I have over 75 EJB beans in my system, and I don't want to risk adding new bugs. Besides, at this point I am not convinced that this is a bug on my part. The footnote states that access to the Beans is not allowed due to the fact that the TX context is not defined. This makes sence, however, looking up an object from JNDI tree should not be a problem. As far as I know, no TX is required for accessing JNDI.
-AP_
Juan Pablo Lorandi wrote:
I've seen some of the code I have running on Orion 2.0.2 and while I can initialize the InitialContext in that method, I'm not looking up beans there. I have a separate method which loads/discards home references and attempts to cache them as well.
Reviewing the spec, java:comp/env access IS allowed, but Enterprise Beans access isn't allowed (except for the bean's own Home interfaces). Thus, they comply to the spec, and "fixing" this for you would mean to break the spec, IMHO.
Can't you just refactor the code?
My 2c, JP
=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff EJB-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
-- -AP_ http://www.myprofiles.com/member/profile/apara_personal http://www.myprofiles.com/member/profile/apara_business
=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff EJB-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
