• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing ejb's with local home and remote interfaces

 
Sub swamy
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sub swamy
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12186
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Sub swamy
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rohit Bhagwat
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic