BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to get Entity local home interface

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder Enterprise
View previous topic :: View next topic  
Author Message
Danny Wang
Guest





PostPosted: Tue Oct 07, 2003 1:00 am    Post subject: How to get Entity local home interface Reply with quote



Hi,
I'm writing a small entity bean and seesion bean example but with no
luck.
My prj has one CMP 2.0 entity bean "Account" and one session bean
"Teller". In the Teller there is a createAccount(String name) (remote)
to actually call Account's interface to create the account.
Following is the snippet from Teller.createAccount:

public void createAccount(java.lang.String name) throws
javax.ejb.CreateException {
try {
javax.naming.Context context = new javax.naming.InitialContext();
Object ref = sessionContext.lookup("Account"); //run time error,
throw an NamingEexception
checkingHome = (bank.CheckingaccountHome) ref;
}
catch(javax.naming.NamingException e) {
throw new javax.ejb.EJBException("Cound not find entity: ", e);
}

checkingaccount = checkingHome.create(name);
}
}

Any one can kindly tell me what I did wrong? The other part of the
session bean works fine.

Danny Wang

Back to top
Bulent KISKAC
Guest





PostPosted: Tue Oct 07, 2003 2:02 am    Post subject: Re: How to get Entity local home interface Reply with quote



Hi,
I think you have to add a reference to your session bean's EJB local
References section. Double click on the Teller under the EJB module, then
you will see a new window for Session bean, then go EJB local References tab
click Add button, write ejb/Account in the edit box then click OK. Check
isLink checkbox, select Account from Link pop-down menu, then save. After
change your code like that

Object ref = sessionContext.lookup("java:comp/env/ejb/Account");

I hope it works

"Danny Wang" <wxg250 (AT) yahoo (DOT) com> wrote

Quote:
Hi,
I'm writing a small entity bean and seesion bean example but with no
luck.
My prj has one CMP 2.0 entity bean "Account" and one session bean
"Teller". In the Teller there is a createAccount(String name) (remote)
to actually call Account's interface to create the account.
Following is the snippet from Teller.createAccount:

public void createAccount(java.lang.String name) throws
javax.ejb.CreateException {
try {
javax.naming.Context context = new javax.naming.InitialContext();
Object ref = sessionContext.lookup("Account"); //run time error,
throw an NamingEexception
checkingHome = (bank.CheckingaccountHome) ref;
}
catch(javax.naming.NamingException e) {
throw new javax.ejb.EJBException("Cound not find entity: ", e);
}

checkingaccount = checkingHome.create(name);
}
}

Any one can kindly tell me what I did wrong? The other part of the
session bean works fine.

Danny Wang




Back to top
Danny Wang
Guest





PostPosted: Tue Oct 07, 2003 2:26 am    Post subject: Re: How to get Entity local home interface Reply with quote



Thank you, Bulent. It still doesn't work after I added the link.
the lookup code still throws a NamingException.
Any more hint?

Danny

Bulent KISKAC wrote:

Quote:
Hi,
I think you have to add a reference to your session bean's EJB local
References section. Double click on the Teller under the EJB module, then
you will see a new window for Session bean, then go EJB local References tab
click Add button, write ejb/Account in the edit box then click OK. Check
isLink checkbox, select Account from Link pop-down menu, then save. After
change your code like that

Object ref = sessionContext.lookup("java:comp/env/ejb/Account");

I hope it works

"Danny Wang" <wxg250 (AT) yahoo (DOT) com> wrote in message
news:3f82102a (AT) newsgroups (DOT) borland.com...

Hi,
I'm writing a small entity bean and seesion bean example but with no
luck.
My prj has one CMP 2.0 entity bean "Account" and one session bean
"Teller". In the Teller there is a createAccount(String name) (remote)
to actually call Account's interface to create the account.
Following is the snippet from Teller.createAccount:

public void createAccount(java.lang.String name) throws
javax.ejb.CreateException {
try {
javax.naming.Context context = new javax.naming.InitialContext();
Object ref = sessionContext.lookup("Account"); //run time error,
throw an NamingEexception
checkingHome = (bank.CheckingaccountHome) ref;
}
catch(javax.naming.NamingException e) {
throw new javax.ejb.EJBException("Cound not find entity: ", e);
}

checkingaccount = checkingHome.create(name);
}
}

Any one can kindly tell me what I did wrong? The other part of the
session bean works fine.

Danny Wang






Back to top
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder Enterprise All times are GMT
Page 1 of 1

 
 


Powered by phpBB © 2001, 2006 phpBB Group
.