File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes getting EJB over JNDI context Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "getting EJB over JNDI context" Watch "getting EJB over JNDI context" New topic

getting EJB over JNDI context

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
First what we use:
We have on one computer a Jboss Server and additional to that a tomcat server in an own jvm.
Now we want to access the EJB's in the Jboss container from a servlet container on a different computer. The Servlet we use is The servlet is the InterestServlet from JBoss manual examples. The webapp works fine when starting JBoss with integrated tomcat..
The source is:
public void init() throws ServletException
Properties props=new Properties();
props.put("java.naming.factory.url.pkgs","org.jboss.naming rg.jnp.interfaces");
// Get a naming context
InitialContext jndiContext = new InitialContext(props);
// Get a reference to the Interest Bean
line 45: Object ref = jndiContext.lookup("java:comp/env/ejb/Interest");
// Get a reference from this to the Bean's Home interface
interestHome = (InterestHome) PortableRemoteObject.narrow(ref, InterestHome.class);
catch(Exception e)
throw new ServletException("Failed to lookup java:comp/env/ejb/Interest", e);
But we got the following error:
javax.naming.NameNotFoundException: comp not bound
at org.jnp.server.NamingServer.getBinding(
at org.jnp.server.NamingServer.getBinding(
at org.jnp.server.NamingServer.getObject(
at org.jnp.server.NamingServer.lookup(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Thx Oliver
[ September 23, 2002: Message edited by: Oliver Refle ]
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
Do you have java:comp/env/ejb/Interest mapped as an ejb-ref in your web applications deployment descriptors?
Try changing java:comp/env/ejb/Interest to the EJB's actual JNDI name and see if that works.
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
what we tried before is that we used the built-in tomcat server of jboss. There the same code worked. So i think the mapping should be correct.
On the other hand we are also not able to browse the JNDI directory with a tool like Netbeans JNDI Browser from an other computer.
Any other idea ?
I agree. Here's the link:
subject: getting EJB over JNDI context
It's not a secret anymore!