wood burning stoves 2.0*
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
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "getting EJB over JNDI context" Watch "getting EJB over JNDI context" New topic
Author

getting EJB over JNDI context

Anonymous
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
{
try
{
Properties props=new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
props.put(Context.PROVIDER_URL,"<IPADDRESS>:1099");
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(NamingServer.java:495)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
at org.jnp.server.NamingServer.getObject(NamingServer.java:509)
at org.jnp.server.NamingServer.lookup(NamingServer.java:253)
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.
Anonymous
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: http://aspose.com/file-tools
 
subject: getting EJB over JNDI context