Re: warp persist, guice & wicket: use warp persist during wicket application startup to load db objects

2010-05-13 Thread Edward Zarecor
I think this questions was resolved on the Guice list.  Correct me if I'm
wrong.  This is the thread:

http://groups.google.com/group/google-guice/browse_thread/thread/78ffb08353f4dcf

The thread was somewhat messy, so the upshot is:

A good worked example of persistence outside the context of a
request/response cycle is available via the JWeekend LegUp DataInitializer
Class.

Get a Wicket/Guice/Warp archetype from here:

http://jweekend.co.uk/dev/LegUp


If the data you are loading isn't changing, you could load it on start up
and detach your hibernate objects or cache the data in any number of other
ways so that it is still available after the loading session has closed.
WorkManager, 
http://code.google.com/p/warp-persist/wiki/WorkManager,
would
be the appropriate way to load data outside of Request/Response cycle in a
web application.

Also see this:
http://www.wideplay.com/transactionsemantics,
see the section on "Custom
Units of Work."

Ed.

On Thu, May 13, 2010 at 12:09 PM, nino martinez wael <
nino.martinez.w...@gmail.com> wrote:

> Maybe mark your servlet listener as transactional?
>
> 2010/5/11 Christoph Grün :
> > 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 like to access Hibernate Daos. I am getting the error:
> >
> >  org.hibernate.HibernateException: No session currently bound to
> execution
> > context
> >
> >at
> >
> org.hibernate.context.ManagedSessionContext.currentSession(ManagedSessionCon
> > text.java:50)
> >
> >at
> >
> org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.j
> > ava: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, so that I can load the
> > database objects and use them for incoming HTTP requests?
> >
> > 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);
> >
> >}
> >
> >
> >
> >
> >
> >
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: warp persist, guice & wicket: use warp persist during wicket application startup to load db objects

2010-05-13 Thread nino martinez wael
Maybe mark your servlet listener as transactional?

2010/5/11 Christoph Grün :
> 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 like to access Hibernate Daos. I am getting the error:
>
>  org.hibernate.HibernateException: No session currently bound to execution
> context
>
>                at
> org.hibernate.context.ManagedSessionContext.currentSession(ManagedSessionCon
> text.java:50)
>
>                at
> org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.j
> ava: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, so that I can load the
> database objects and use them for incoming HTTP requests?
>
> 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);
>
>    }
>
>
>
>
>
>

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: warp persist, guice & wicket: use warp persist during wicket application startup to load db objects

2010-05-11 Thread Igor Vaynberg
if this was spring i would tell you that you need to start a
transaction, which in turn will bind a hibernate session to a
threadlocal context. it probably works in a request because you have a
filter that does that for you, so look at that filter and see what it
does.

-igor

On Tue, May 11, 2010 at 7:40 AM, Christoph Grün  wrote:
> 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 like to access Hibernate Daos. I am getting the error:
>
>  org.hibernate.HibernateException: No session currently bound to execution
> context
>
>                at
> org.hibernate.context.ManagedSessionContext.currentSession(ManagedSessionCon
> text.java:50)
>
>                at
> org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.j
> ava: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, so that I can load the
> database objects and use them for incoming HTTP requests?
>
> 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);
>
>    }
>
>
>
>
>
>

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



warp persist, guice & wicket: use warp persist during wicket application startup to load db objects

2010-05-11 Thread Christoph Grün
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 like to access Hibernate Daos. I am getting the error: 

 org.hibernate.HibernateException: No session currently bound to execution
context

at
org.hibernate.context.ManagedSessionContext.currentSession(ManagedSessionCon
text.java:50)

at
org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.j
ava: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, so that I can load the
database objects and use them for incoming HTTP requests?

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);

}