Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Inject EntityManagerFactory on @Webservlet

Hello.

  I am coding a small webapp with the help of Maven and Jetty. I'm
having a hard time trying to inject the EntityManagerFactory inside a
Servlet (@Webservlet):

@WebServlet("/test")
public class TestServlet extends HttpServlet {

	@PersistenceUnit(unitName="pu")
	private EntityManagerFactory emf;

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
           emf... // is null

        }

It's always null. In the other hand
Persistence.createEntityManagerFactory("pu") works.

Am i doing anything wrong here?

Thank you!

Luciano G Santos


Back to the top