[jboss-user] [EJB 3.0] New message: "EJB 3.0 - Injection via annotation into a servlet"

Riccardo Blumenthal do-not-reply at jboss.com
Tue Jan 26 09:36:07 EST 2010

User development,

A new message was posted in the thread "EJB 3.0 - Injection via annotation into a servlet":


Author  : Riccardo Blumenthal
Profile : http://community.jboss.org/people/neron17

Hello Community,
I am trying to get a web application working. Therefore I made a servlet, a stateless session bean and an interface for that bean. Now I am trying to get my bean injected (I think that is the correct expression?) into the servlet to call a function. I activate the servlet via a url - that is working. But as soon as I enter the code for the injection my JBoss throws an error on deploying.
I have tried numerous ways but nothing helped. I have spent 3 days on this now and it would be really helpful if there is any advice for what I am doing wong.
Ok, lets get a bit more precise.
I am using Eclipse 3.5 (also to generate the EAR file for the JBoss) and JBoss 5.0.1.GA
My servlet code looks as follows:
package com;
import java.io.IOException;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import com.session.PersonControllerEJBemote;
public class SnoopServlet extends HttpServlet 
     Logger logger = Logger.getLogger(SnoopServlet.class);
     PersonControllerEJBRemote personControllerEJB;
     public void doGet(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException

Stateless Session Bean:
package com.session;
import java.io.Serializable;
import java.util.Date;
import javax.ejb.Local;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.apache.log4j.Logger;
import org.apache.ws.scout.registry.infomodel.PersonNameImpl;
public class PersonControllerEJBImpl implements PersonControllerEJBLocal, Serializable
     private EntityManager em;
     private Logger logger = Logger.getLogger(PersonNameImpl.class);
     public void addPerson()
          System.out.println("Person added!");
     public String findPerson(int personId)


To reply to this message visit the message page: http://community.jboss.org/message/522316#522316

More information about the jboss-user mailing list