Thomas,

I noticed another bug in the code you sent. Although what you have (with the
suggested changes) will most likely work in JBoss, it is not compliant with
the EJB specification. In the EJB 1.1 Specification section 5.9 on page 47
is the following:

A client program that is intended to be interoperable with all compliant EJB
Container implementations must use the
javax.rmi.PortableRemoteObject.narrow(...) method to perform type-narrowing
of the client-side representations of the home and remote interface.


To be compliant just change your code as follows:

InitialContext jndiContext = new InitialContext();
Object ref = jndiContext.lookup("java:comp/env/ejb/myBean");
BHome bHome = (BHome)PortableRemoteObject.narrow(ref, BHome.class);
B bean = bHome.create(pk);

Hope this helps,

-dain

-----Original Message-----
From: danch (Dan Christopherson) [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 17, 2001 10:02 AM
To: [EMAIL PROTECTED]
Subject: Re: [JBoss-user] Intrabean Call ?


   wrote:

> Hi,
> 
> documentation says:
> 
> public class ABean implements EntityBean {
> ...
> public void BusinessMethod(...) {
> ...
> 
> BHome home = (BHome)ctx.lookup("java:comp/env/ejb/myBean");
> B bean = home.create(pk);
> ...
> }
> }
> 
> My inside a SessionBean code looks like:
> 
> 
> 
> private SessionContext ctx;
> 
> public void setSessionContext(SessionContext sc)
> {
> this.ctx = sc;
> }
> 
> 
> public DocumentFragment getMassnahmeByID(long ID) throws RemoteException
> {
> MassnahmeHome m_home = 
> (MassnahmeHome)ctx.lookup("java:comp/env/entity/katalog/Massnahme");


this 'ctx' variable needs to be a JNDI context. Do this instead.
javax.naming.InitialContext initCtx = new javax.naming.InitialContext();
MassnahmeHome m_home = 
(MassnahmeHome)initCtx.lookup("java:comp/env/entity/katalog/Massnahme");




_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to