wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Accsessing EJB in the web application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Accsessing EJB in the web application" Watch "Accsessing EJB in the web application" New topic
Author

Accsessing EJB in the web application

Alka S.
Greenhorn

Joined: Nov 29, 2003
Posts: 26
I am using Tomcat as web server and Weblogic as application server.
I have deployed EJBs on Weblogic. I have to use these EJBs in Jsps (Action classes). Code is as follows
As MVC architecture I am calling EJB in ction class
public ActionForward execute(ActionMapping actionMapping,ActionForm actionForm,HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
{
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL, "tc://localhost:7001");
Context initCtx = new InitialContext(p);
Object obj = initCtx.lookup("myFacilityService");
FacilityServiceHome home = (FacilityServiceHome)PortableRemoteObject.narrow(obj,
FacilityServiceHome.class);
//Create the remote interface instance
FacilityService cli = home.create();
cli.getAllFacility();
httpServletRequest.setAttribute("FacilityList", cli.getAllFacility());
}
In jsp
Integer val = (Integer)request.getAttribute("FacilityList");
String counrVal = " ";
if (val != null)
counrVal = val.toString();
I have copied ejb jar file which is deployed on weblogic on WEB_INF-lib folder and added in JBuilder for required libraries. It is coplling properly but while running it is giving erroras follows -
Error -----------------------------------Cannot instantiate class: weblogic.jndi
.WLInitialContextFactory
After copying weblogic.jar in Tomact - common - lib folder it is giving error null.
Can anybody knows the above problem?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accsessing EJB in the web application
 
Similar Threads
NoInitialContextException
NullPointerException at StubGenerator.getStubOnClient
Class cast Exception
Remote Home lookup from tomcat 5.0 to Weblogic 8.1
IBM RAD 7 EJB lookup failure, NameNotFoundException