Accessing EJBs from Servlets in a WSAD

Hi,

i am using WebSPhere studio Application Developer IDE and a Test Version of WebSphere 5.0 to deploy and run enterprise application which has a Web Module packaged as a .WAR file and EJB Module packed as a EJB .jar file now can any one tell me if i want to access the session bean from a Servlet then how can i achieve it in this enterprise application as i tried by writing the JNDI Lookup code segment inside the Servlet class itself but when deploy the application it is not finding the package name space of Home and Remote Interface of my EJB as both are different modules of the same Enterprise Archive in a WebSphere Studio Application Developer 5.0 so please help me regarding this.

Thanks,

Parshva Kamdar.

[742 byte] By [pkamdar2000a] at [2007-11-27 3:38:39]
# 1
If the bean is properly bound to the JNDI name, then the lookup should work. It doesnt matter whether the servlet is in the same module, or different module.
enigma_y2k1a at 2007-7-12 8:41:59 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

thanks,

so can u just mention the code snippet for the JNDI Lookup and i guess i should put it inside doGet() or doPost() method of servlet right as per the requirement and should i first compile and deploy the web application containing servlet WAR file individually before deploying jar or it will not be needed as both the EJB module and the web module both are packages as a single EAR file so direct deployment of EAR file would be sufficient enough?

Please guide me,

Regards,

Parshva Kamdar.

pkamdar2000a at 2007-7-12 8:41:59 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

Hi:

You could get the EJB lookup code anywhere if you do a search on Google.

But before that check if you project references are properly set accordingly and

secondly just check whetehr the jar loading policy is loading your ejb's first before your ear project. project dependency.

Avadhoot Sawant.

Message was edited by:

garava

garavaa at 2007-7-12 8:41:59 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4

Hi,

i developed and deployed one Stateful Session Bean application and kept the client in the same src folder inside ejbModule directory of the project and the module is giving the expected output when accessed using the JNDI exploerer but when i tried using a simple java client application and inside main method i wrote the JNDI lookup code so at that time after running this client it is giving the exception as below.

javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial

at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:652)

at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:255)

at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:292)

at javax.naming.InitialContext.lookup(InitialContext.java:359)

at src.SampleClient.main(SampleClient.java:21)

so any guidelines for this problem would be appericiated.

Regards,

Parshva Kamdar.

Exception in thread "main"

pkamdar2000a at 2007-7-12 8:41:59 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...