dinesh707
dinesh707

Reputation: 12582

How to Inject Hibernate Session into a Servlet inside Tapestry?

I have a HttpServlet inside tapestry project. But I think it is not recognized as a part of IoC. So when I do an @inject it does not work. It ends up throwing a null pointer exception. Any suggestion about how to inject the same hibernate session.

Upvotes: 2

Views: 272

Answers (1)

dinesh707
dinesh707

Reputation: 12582

Inside the servlet doPost() method I did the following.

Registry registry = (Registry)
getServletContext().getAttribute(TapestryFilter.REGISTRY_CONTEXT_NAME);         
hbSession = registry.getService(Session.class);

Upvotes: 2

Related Questions