• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problems with EJB3.0... (continued)  RSS feed

Kevin P Smith
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I posted on here a couple of days ago about problems I was having deploying EJB3.0 on teh Sun WebApp 9.0.
Whilst I've mnaged to deploy my EJB & Client (SimpleServlet) as seperate modules (web.war & ejb.jar) I am still
having trouble getting the Servlet to connect with the EJB...

I have chosen the XML deployment descriptor route over Annotation because it seems easier for changing
(especially during development) also I'm not keen on having this sort of info in the actual code.

Below are (what I think) are the relivent files and code bits, could someone please help me understand why the
Servlet is throwing the 'NameNotFoundException' Exception when connecting to the SampleModel bean.

Any help would be Cheers


try {
InitialContext cxt = new InitialContext();
SampleRemote remote = (SampleRemote)cxt.lookup("java:comp/env/ejb/SampleModel");
System.out.println("Name: "+remote.getName());
} catch (NamingException NEx) {
System.out.println("Naming Exception: "+NEx);

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<ejb-jar xmlns = "http://java.sun.com/xml/ns/javaee" version="3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
Sample Bean for testing

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 9.0 EJB 3.0//EN'

Naming Exception: javax.naming.NameNotFoundException: No object bound to name java:comp/env/ejb/SampleModel|#]
Fabian Gutierrez
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

the sun application server has a jndi tree explorer, there you can check what is the actual path for that bean.

Shailesh Kini
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Keith,

web.xml and ejb-jar.xml looks OK. However the text in <jndi-name> in sun-ejb-jar.xml does not match with <ejb-ref-name> in web.xml. Can you please change the sun-ejb-jar.xml <jndi-name>samplemodel</jndi-name> to <jndi-name>ejb/samplemodel</jndi-name>.

I am not sure if the jndi names are case sensitive but it always helps to make sure to use the same case when looking up for the jndi name in the servlet as defined in web.xml and sun-ejb-jar.xml.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!