I'm running JBoss 3.0.1 with Tomcat 4.0.4 bundle. I have successfully deployed a EJB to Jboss and created 2 clients (java & JSP client).
For some reasons, I'm able to run the java client but when I try the JSP client (served by Tomcat) I get this error message
javax.servlet.ServletException: Name greetings is not bound in this Context
Below is the code for the 2 clients & web.xml
<----------- jsp client -------------->
<%@ page import="javax.naming.*,
java.util.*,
java.util.Hashtable,
javax.rmi.PortableRemoteObject,
com.stardeveloper.ejb.session.*"%>
<%
long t1 = System.currentTimeMillis();
InitialContext ctx = new InitialContext();
Object ref = ctx.lookup("ejb/First");
FirstHome home = (FirstHome) PortableRemoteObject.narrow (ref, FirstHome.class);
First bean = home.create();
String time = bean.getTime();
bean.remove();
ctx.close();
long t2 = System.currentTimeMillis();
%>
<html>
<head>
<style>p { font-family:Verdana;font-size:12px; }</style>
</head>
<body>
<p>Message received from bean = "<%= time %>".<br>Time taken :
<%= (t2 - t1) %> ms.</p>
</body>
</html>
<----------- java client ------------->
import javax.naming.*;
import com.stardeveloper.ejb.session.*;
import java.util.Hashtable;
import javax.rmi.PortableRemoteObject;
import com.stardeveloper.ejb.session.*;
class firstEJBclient {
public static void main(String[] args) {
try {
long t1 = System.currentTimeMillis();
InitialContext ctx = new InitialContext();
System.out.println("Got CONTEXT");
Object ref = ctx.lookup("ejb/First");
System.out.println("Got REFERENCE");
FirstHome home = (FirstHome) PortableRemoteObject.narrow (ref, FirstHome.class);
First bean = home.create();
String time = bean.getTime();
bean.remove();
ctx.close();
long t2 = System.currentTimeMillis();
System.out.println("Message received from bean = "+time+" Time taken : "+(t2 - t1)+" ms.");
}
catch (Exception e) {
System.out.println(e.toString());
}
}
}
<----------------- web.xml -------------------->
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<session-config>
<session-timeout>
1800
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>
firstEJB2.jsp
</welcome-file>
</welcome-file-list>
<ejb-ref>
<description>A reference to an entity bean</description>
<ejb-ref-name>ejb/First</ejb-ref-name>
<ejb-ref-type>Stateless</ejb-ref-type>
<home>com.stardeveloper.ejb.session.FirstHome</home>
<remote>com.stardeveloper.ejb.session.First</remote>
</ejb-ref>
</web-app>
Why is it not bound?