Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • 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 ...
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!