• 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

EJB reference not bound in JSP

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1st thing:
"ku916"-
Welcome to the JavaRanch! Please adjust your displayed name to match the JavaRanch Naming Policy.
You can change it here.
Thanks! and again welcome to the JavaRanch!
2nd thing:
Check out the [URL=http://www.javaranch.com]UBB Code tags[/b] -- they're very slick when you surround a chunk of source code with [code] tags it preserves the whitespace and makes your code easier to read.
[ July 11, 2002: Message edited by: Jessica Sant ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic