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.
sun-ejb-jar.xml --------------- <?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' 'http://www.sun.com/software/dtd/appserver/sun-ejb-jar_3_0-0.dtd'> <sun-ejb-jar> <display-name>Sample</display-name> <enterprise-beans> <unique-id>1</unique-id> <ejb> <ejb-name>SampleModel</ejb-name> <jndi-name>samplemodel</jndi-name> </ejb> </enterprise-beans> </sun-ejb-jar> </xml>
server.log ---------- [#|2007-10-10T11:37:38.400+0100|INFO|sun-appserver-pe9.0|javax.enterprise.system.stream.out|_ThreadID=11;_ThreadName=httpWorkerThread-8080-0;| Naming Exception: javax.naming.NameNotFoundException: No object bound to name java:comp/env/ejb/SampleModel|#]
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.