This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Errors invoking EJB deployed on websphere from the JSP client running on Tomcat  RSS feed

Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to use JSP running on Tomcat as client to EJB application deployed on websphere.

I have created a folder by name 'myclient' under "C:\Program Files\Apache Group\Tomcat 4.1\webapps". I also created subfolders 'WEB-INF' and 'lib' under 'myclient'. I have added an ejb reference in web.xml file under 'WEB-INF' as below.

<ejb-ref id="EjbRef_1">

I have placed client jar of my EJB application in 'lib' folder along with other jar files that are picked up from websphere runtime enviromment to interact with EJB deployed on websphere. These jar files include,

myappclient.jar (client jar file of my EJB application)

I have written a sample JSP file to execute it in Tomcat which interacts with EJB on websphere. The JSP code snippet to communicate with EJB is,


<%@ page import="java.util.Hashtable" %>

<%@ page import="javax.ejb.EJBHome" %>
<%@ page import="javax.ejb.EJBObject" %>

<%@ page import="javax.naming.Context" %>
<%@ page import="javax.naming.InitialContext" %>

<%@ page import="HelloJavaHome" %>
<%@ page import="HelloJava" %>

String name = request.getParameter("name");
String greeting = "";

if(name != null) {

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "");
env.put(Context.PROVIDER_URL, "iiop://localhost:2809");
InitialContext initContext = new InitialContext(env);
System.out.println("Initial contect created");
Object obj = initContext.lookup("java:comp/env/ejb/HelloJavaHome");
System.out.println("Lookup successful");
HelloJavaHome home = (HelloJavaHome) javax.rmi.PortableRemoteObject.narrow(obj,HelloJavaHome.class);
HelloJava remote = home.create();
greeting = remote.getGreeting(name);

System.out.println("Greeting :" + greeting);

catch(Exception e){
greeting = e.getMessage();



I am getting below compilation errors when I invoked index.jsp after I have started both websphere and tomcat servers.

[javac] Compiling 1 source file
[javac] C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\myclient\ cannot access javax.ejb.EJBHome
[javac] file javax\ejb\EJBHome.class not found
[javac] HelloJava remote = home.create();
[javac] ^
[javac] C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\myclient\ cannot access javax.ejb.EJBObject
[javac] file javax\ejb\EJBObject.class not found
[javac] greeting = remote.getGreeting(name);
[javac] ^
[javac] 2 errors

I appreciate if somebody could help me fixing the above errors ASAP. Thanks in advance
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!