Hi,

I have a really simple EJB3 sample adapted from the Trailblazer application. 
I have a Servlet (ExampleServlet.java) that does a lookup of a Stateless 
Session Bean (TestServiceImpl.java).

The lookup code is
anonymous wrote :  
  | Context jndiContext = new jndiContext();
  | TestService ts = (TestService)jndiContext.lookup("TestServiceImpl");
  | 

When I do this I get a javax.naming.NameNotFoundException: TestServiceImpl not 
found.

When I print out the JNDI context from the Servlet, I do not see 
TestServiceImpl or anything related to my beans.

My application is packaged as a single ear file (example.ear) which contains

anonymous wrote : 
  | application.xml
  | jboss-app.xml
  | app.jar
  | ....TestService.java
  | .....TestServiceImpl.java
  | .....Persistence.xml
  | web.war
  | .....ExampleServlet.class
  | ......MyJSP.jsp
  | ......web.xml
  | 

My TestServiceImpl class looks like

anonymous wrote : 
  | @Stateless
  | @Local(TestService.class)
  | @LocalBinding(jndiBinding="TestServiceImpl")
  | public class TestServiceImpl implements TestService
  |      public int add(int i, int j)
  |      { return i+j;
  |      }
  | }
  | 

The @Local and at @LocalBinding are recent additions. Initially I 
did not have them and tried the following context lookups to 
no avail.

anonymous wrote : 
  | TestService ts = 
(TestService)jndiContext.lookup("example/TestServiceImpl/local");
  | 
  | Note: my ear file is example.ear
  | 
  | TestService ts = (TestService)jndiContext.lookup("TestServiceImpl/local");
  | 
  | 

When I deploy the ear file (example.ear) into JBoss (I am using JBoss 4.0.4) I 
get no errors and the Servlet and JSP invoke fine.


My persistence.xml file is:

anonymous wrote : 
  | 
  | ....<persistence-unit name="example">
  | ..........<jta-data-source>java:/DefaultDS</jta-data-source>
  | ......</persistence-unit>
  | 
  | 

My application.xml file is: (ignore the dots in "module" and "web" below... 
    I needed those to prevent this forum software from getting confused)
anonymous wrote : 
  | .... usual XML headers ....
  | <display-name>Example Application</display-name>
  | <module.>
  | .....app.jar
  | </module.>
  | <module.>
  | ......<web.>
  | .............<web-uri>web.war</web-uri>
  | ..............<context-root>Example</context-root>
  | ......</web.>
  | </module.>
  | 


My jboss-app.xml file is
anonymous wrote : 
  | ... usual XML headers...
  | <jboss-app>
  | ....<loader-repository>
  | ...........example:app=ejb3
  | .....</loader-repository>
  | </jboss-app>
  | 

My jboss-web.xml file is
anonymous wrote : 
  | .... usual XML headers
  | <jboss-web>
  | ....<security-domain>java:/jaas/other</security-domain>
  | </jboss-web>
  | 

My web.xml file is
anonymous wrote : 
  |    .... usual XML headers
  |    <web-app>
  |    ......<display-name>Example</display-name>
  |    ......
  |    ............<servlet-name>ExampleServlet</servlet-name>
  |                   
...........<servlet-class>web.other_servlets.ExampleServlet</servlet-name>
  |     ......
  | 
  | 
  |     .......<servlet-mapping>
  |     ............<servlet-name>ExampleServlet</servlet-name>
  |     ............<url-pattern>/do/*</url-pattern>
  |     .......<servlet-mapping>
  | 
  |   </web-app>
  | 


I have been struggling over this for the past 2 days, so any help will be 
greatly appreciated..

My current hypotheses are
1) Some configuration error that I cannot pick up
2) The stateless session bean (ExampleServiceImpl) is being 
       registered in some naming context the the Servlet does not 
       have access to.
3) The stateless session bean is not getting registered at all (despite 
      no errors on deploy).

thanks,

Ranjit



View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3950254#3950254

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3950254


_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to