usage of hibernate connection in wicket application (during startup)

14 views
Skip to first unread message

Christoph

unread,
May 10, 2010, 5:35:20 AM5/10/10
to warp-core
Hi all!
I am using Wicket together with Hibernate and Warp-persist/servlet. In
my Init class, I have registered following two methods below. However,
it seems that I can access database objects via DAOs only as soon as a
request is sent to the server. I would like to use them before (during
start up of the wicket application) in order to load some objects from
the database, which are shared across the application.

Currently, I am getting the error: Exception starting filter
wicket.catadvisor
org.hibernate.HibernateException: No session currently bound to
execution context when running a @finder method to return some
database objects.
How do I need to configure warp-persist in order to use it in wicket
applicaiton in the init() method during startup?

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.

yaniv kessler

unread,
May 15, 2010, 1:35:48 AM5/15/10
to warp...@googlegroups.com
Hi Christoph,

IF you are using Open Session In View (session per http request) you need to look into using the WorkManager, if you need a hibernate session outside the scope of an http request.

Hope this helps,

Yaniv Kessler

nino martinez wael

unread,
Jun 1, 2010, 9:55:25 AM6/1/10
to warp...@googlegroups.com
you can also look into how the legup wicket archetype does use guice
initializer..

mvn archetype:generate -B
-DarchetypeCatalog=http://legup.googlecode.com/svn/repo/archetype-catalog.xml
-DarchetypeArtifactId=wicket-warp-jpa-archetype
-DarchetypeGroupId=com.jweekend -DarchetypeVersion=0.8.2
-DgroupId=com.mycompany -DartifactId=mycompany -Dversion=1.0-SNAPSHOT
-Dpackage=com.mycompany

or here http://www.jweekend.com/dev/LegUp

2010/5/10 Christoph <chri...@gmx.at>:

Reply all
Reply to author
Forward
0 new messages