warp persist, guice & wicket: start warp persist before http request

10 views
Skip to first unread message

Christoph

unread,
May 11, 2010, 4:23:44 AM5/11/10
to warp-core
Hi all,

I am using Wicket together with Guice and Warp Persist/Servlet.
I have registered the PersistenceService in the contextInitialized
method. However, I would like to do some data loading from the
database when wicket starts, and need to use Hibernate Daos. I am
getting the error:

org.hibernate.HibernateException: No session currently bound to
execution context
at
org.hibernate.context.ManagedSessionContext.currentSession(ManagedSessionContext.java:
50)
at
org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:
591)
at
com.wideplay.warp.hibernate.SessionProvider.get(SessionProvider.java:
42)
at
com.wideplay.warp.hibernate.SessionProvider.get(SessionProvider.java:
32)

Using Hibernate from an HTTP request is no problem. How can I
configure Warp to use it directly from WicketApplication?

Thanks a lot, Christoph

public class Init extends WarpServletContextListener {

@Override
public void contextInitialized(ServletContextEvent event) {
super.contextInitialized(event);
INJ.getInstance(PersistenceService.class).start();
event.getServletContext().setAttribute("injector", INJ);
}

@Override
public void contextDestroyed(ServletContextEvent event) {
super.contextDestroyed(event);

}

--
You received this message because you are subscribed to the Google Groups "warp-core" group.
To post to this group, send email to warp...@googlegroups.com.
To unsubscribe from this group, send email to warp-core+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/warp-core?hl=en.

Dhanji R. Prasanna

unread,
Aug 5, 2010, 8:13:23 PM8/5/10
to warp...@googlegroups.com
You basically need the PersistenceFilter to appear above the WicketFilter. I think that should fix it.

Dhanji.
Reply all
Reply to author
Forward
0 new messages