This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Unable to access Local SLSB from app client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Unable to access Local SLSB from app client " Watch "Unable to access Local SLSB from app client " New topic
Author

Unable to access Local SLSB from app client

Karnati Sudhakar
Ranch Hand

Joined: Aug 26, 2008
Posts: 270

Hi,

I am trying to access local state less session bean from app client.Code is as below:

PracticeBean.java



PracticeLocal.java



and the client code:

Main.java





and the error i am getting is :

javax.naming.NameNotFoundException: PracticeLocal not found
at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:216)
at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:188)
at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:74)
at com.sun.enterprise.naming.RemoteSerialContextProviderImpl.lookup(RemoteSerialContextProviderImpl.java:129)
at sun.reflect.GeneratedMethodAccessor161.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:154)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:687)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:227)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1846)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1706)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:1088)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:223)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:806)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)


can any body suggest whats wrong i am doing here?

Regards
Sudhakar


Regards
Sudhakar
Treimin Clark
Ranch Hand

Joined: Nov 12, 2008
Posts: 757
How if you replace


with

Raf Szczypiorski
Ranch Hand

Joined: Aug 21, 2008
Posts: 383
For example, Glassfish v2 doesn't bind local beans to JNDI. So, it is impossible to access local beans from client. This is not required by the specs, anyways, as it is a completely different JVM, and local really means local.
Treimin Clark
Ranch Hand

Joined: Nov 12, 2008
Posts: 757
Raf, is it ok to use "PracticeLocal" instead of "ejb.PracticeLocal" ?
Karnati Sudhakar
Ranch Hand

Joined: Aug 26, 2008
Posts: 270

Treminin,

Both PracticeLocal and ejb.PracticeLocal are not working.

For example, Glassfish v2 doesn't bind local beans to JNDI. So, it is impossible to access local beans from client. This is not required by the specs, anyways, as it is a completely different JVM, and local really means local.


so i cant access local session beans through initialContext. What about through SessionContext? any idea?

How can i access local session bean other than through annotations.

Thanks for your reply Raf and Treminin

Regards
Sudhakar
Raf Szczypiorski
Ranch Hand

Joined: Aug 21, 2008
Posts: 383
You cannot access it using SessionContext - it uses JNDI under the hood. Also, SessionContext is not available to an application client to my knowledge. Apart from annotations, you can do it the old school way - ejb-jar.xml.
Karnati Sudhakar
Ranch Hand

Joined: Aug 26, 2008
Posts: 270

You cannot access it using SessionContext - it uses JNDI under the hood. Also, SessionContext is not available to an application client to my knowledge. Apart from annotations, you can do it the old school way - ejb-jar.xml


Just checked the specs regarding EJBContext and it says that we cannot use this outside the container environment.

Thanks Raf for your help.

Regards
Sudhakar
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
Hm, I don't know, but I think it does not make sense to access Local beans from app clients, because an app client is running from a different JVM.

Please correct me if I'm wrong, I understand that "Local" means the same "JVM", not the same machine.


SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
Raf Szczypiorski
Ranch Hand

Joined: Aug 21, 2008
Posts: 383
You're correct ;-)
Treimin Clark
Ranch Hand

Joined: Nov 12, 2008
Posts: 757
Treimin Clark wrote:Raf, is it ok to use "PracticeLocal" instead of "ejb.PracticeLocal" ?
Raf Szczypiorski
Ranch Hand

Joined: Aug 21, 2008
Posts: 383
If you cannot lookup local beans, obviously neither will work ;-)
Treimin Clark
Ranch Hand

Joined: Nov 12, 2008
Posts: 757
yes, but if I can?
Karnati Sudhakar
Ranch Hand

Joined: Aug 26, 2008
Posts: 270

If you cannot lookup local beans, obviously neither will work ;-)


I doubt this because i tried with remote session beans but it did not work.It is working only when you give the fully qualified class name.

Regards
Sudhakar
Marcin Faryna
Greenhorn

Joined: Jul 16, 2009
Posts: 15
If your client is stand-alone application you must use Remote or Webservice interface to invoke EJB3 bean.


SCJP 6, SCBCD 5
 
Consider Paul's rocket mass heater.
 
subject: Unable to access Local SLSB from app client