• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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">
<ejb-ref-name>ejb/HelloJavaHome</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>HelloJavaHome</home>
<remote>HelloJava</remote>
<ejb-link>HelloJava</ejb-link>
</ejb-ref>

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,

j2ee.jar
bootstrap.jar
ejbcontainer.jar
lmproxy.jar
naming.jar
namingclient.jar
ras.jar
server.jar
wsexception.jar
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,

//////////////////////////////////
index.jsp
-------------

<%@ 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 = "";

try{
if(name != null) {

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
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\index_jsp.java:67: 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\index_jsp.java:68: 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic