This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accsessing EJB in the web application

 
Alka S.
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic