[jboss-user] [EJB 3.0] - EJB reference in Servlet always null

buki79 do-not-reply at jboss.com
Tue Mar 10 18:30:57 EDT 2009


Hi,


I use JBoss 4.2.2 on Mac OS with JDK 1.5. 

First, I created a Session:

@Stateful(name="ViewerBean")
  | public class ViewerBean implements Viewer,
  | 		ViewerLocal{
  | 

Then I want to call the bean from a servlet:


  | public class ViewerServlet extends HttpServlet {
  | 	
  | 	//inject EJB	
  | 	@EJB(mappedName="ViewerBean")	
  | 	private ViewerBean bean;
  | 	
  | 	private static final long serialVersionUID = 1L;
  |        
  |  
  | 	/**
  | 	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
  | 	 */
  | 	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  | 		try {
  | 			List events = bean.getEvents();
  | ...
  | 

I haven't added anything to the ejb-jar.xml as the annotations should be sufficient. But everytime I want to call bean.getEvents() I get a NullPointerException.

I have an EJB3 project created in eclipse, as well as an EAR project. Both are deployed on the same server and the EAR client program references the EJB3 project, so I can use the ViewerBean in the client.

Is this correct? Could you give me any hints on what I'm actually missing? 

Best regards,

Andreas



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

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



More information about the jboss-user mailing list