aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Accessing ejb's with local home and remote interfaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Accessing ejb Watch "Accessing ejb New topic
Author

Accessing ejb's with local home and remote interfaces

Sub swamy
Ranch Hand

Joined: Oct 02, 2002
Posts: 121
Wanted to test local ejb's i.e ejb's using local home and remote interfaces. Getting a message such as "NamingException : process not found".

The following is the piece of code used to test

1) Stateless session bean with remote client
2) Stateful session bean with local client

The client code is as below...



This piece of code is being executed from a separate window.

I'm able to do the lookup and access the Stateless session bean with remote client while i am NOT able to lookup stateful bean with local client. Is it because i am trying from a new window (command prompt). If so, how else do i access this EJB from a stand-alone client.

The JNDI names are being specified for both the beans during deploy time.

Env: J2EE Server 1.3 using deploy tool
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
A local client must be part of the same app as the EJB, so must be in the same EAR. What you can do is write a client EJB (let's call it EJBA) which locally calls your bean, and you then remotely call EJBA.

Remote client - (remote call) - EJBA - (local call) - stateful EJB


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Sub swamy
Ranch Hand

Joined: Oct 02, 2002
Posts: 121
The code below is what i tried - remote client accessing an EJB(not shown in code) which inturn tries to lookup another EJB with local interfaces.

The lookup to the second EJB is failing - get a "javax.naming.NameNotFoundException: process not found" - i have named the JNDI lookup variable as "process" during deploy time. The two EJB's are in the same .ear file.

Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Some comments ...

1. For a JNDI lookup within the server, there is no need to supply environment variables to InitialContext as the default values are correct.

2. Post your DDs.

3. Are you sure that you have got the correct name for your bean bound in the JNDI tree.
Sub swamy
Ranch Hand

Joined: Oct 02, 2002
Posts: 121
1. For a JNDI lookup within the server, there is no need to supply environment variables to InitialContext as the default values are correct.

Agreed.

2. Post your DDs.


Am using WSAD and deploying the resulting ear file in J2EE RI server.

3. Are you sure that you have got the correct name for your bean bound in the JNDI tree.

Yes. Am not including "java:comp/env/" from the AdviceBean since that gets included be default.


The following is the error obtained...


javax.naming.NameNotFoundException
at com.sun.enterprise.naming.TransientContext.resolveContext(TransientContext.java:226)
at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:149)
at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:63)
at org.omg.stub.com.sun.enterprise.naming._SerialContextProviderImpl_Tie._invoke(Unknown Source)
at com.sun.corba.ee.internal.corba.ServerDelegate.dispatch(ServerDelegate.java:355)
at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:255)
at com.sun.corba.ee.internal.iiop.LocalClientRequestImpl.invoke(LocalClientRequestImpl.java:101)
at com.sun.corba.ee.internal.corba.ClientDelegate.invoke(ClientDelegate.java:232)
at com.sun.corba.ee.internal.corba.ClientDelegate.invoke(ClientDelegate.java:274)
at org.omg.CORBA.portable.ObjectImpl._invoke(ObjectImpl.java:457)
at org.omg.stub.com.sun.enterprise.naming._SerialContextProvider_Stub.lookup(Unknown Source)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:120)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at com.external.AdviceBean.getAdvice(AdviceBean.java:71)
at com.external.AdviceBean_EJBObjectImpl.getAdvice(AdviceBean_EJBObjectImpl.java:22)
at com.external._AdviceBean_EJBObjectImpl_Tie._invoke(Unknown Source)
at com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatchToServant(GenericPOAServerSC.java:520)
at com.sun.corba.ee.internal.POA.GenericPOAServerSC.internalDispatch(GenericPOAServerSC.java:210)
at com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatch(GenericPOAServerSC.java:112)
at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:255)
at com.sun.corba.ee.internal.iiop.RequestProcessor.process(RequestProcessor.java:84)
at com.sun.corba.ee.internal.orbutil.ThreadPool$PooledThread.run(ThreadPool.java:99)
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Your lookup must be the EJB reference, ie ejb/ProcessLocal. Furthermore, where have you mapped ejb/ProcessLocal to the real JNDI name?
Sub swamy
Ranch Hand

Joined: Oct 02, 2002
Posts: 121
Thanks Roger Chung-Wee for your guidance.

Have been able to spot the error. Lookup was not the ejb ref name - once this was set right, the issue was resolved.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11402
    
  16

Subramanian PN,

Your name does not quite meet our naming guidelines. we require a real sounding first and last name. an inital for a FIRST name is ok.

You could simply reverse your display names, or fill out your last name. simply go here and you can fix it.

you can read our naming policy here.

Thanks!


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Sub swamy
Ranch Hand

Joined: Oct 02, 2002
Posts: 121
I am not sure how come my name goes against the naming policy when all this while there has been no such issues.

Anyways, i have changed my name.
Arijit Banerjee
Greenhorn

Joined: Jan 11, 2006
Posts: 1
Hey fred rosenberger,

Subramanian Narayanaswamy is a common name in his country. As it is un common to you, you might have thought all those(as I'm seeing rosenberger for the first time). I cound not figure out any problem with his naming.


Regards,<br />Arijit
Rohit Bhagwat
Ranch Hand

Joined: Dec 19, 2004
Posts: 205
Originally posted by Roger Chung-Wee:
Your lookup must be the EJB reference, ie ejb/ProcessLocal. Furthermore, where have you mapped ejb/ProcessLocal to the real JNDI name?


I verified that I used ejb/[JNDI-name] but still unable to get rid of NameNotFoundException while using local interface.
Can you please help me.
~Rohit
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing ejb's with local home and remote interfaces