You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Fernando Wermus <fe...@gmail.com> on 2010/09/03 19:10:15 UTC

rendering a page for an email: org.hibernate.HibernateException: createCriteria is not valid without active transaction

Hi all,
     I have coded the following to render a mail,


Application app;
try{
app=MyApplication.get();
}catch(Exception e){
app=new WicketTester().getApplication();
}
final Application app2=app;
final ExecutorService service = new ScheduledThreadPoolExecutor(1) {
@Override
protected void beforeExecute(final Thread t, final Runnable r) {
Application.set(app2);
};
@Override
protected void afterExecute(final Runnable r, final Throwable t) {
Application.unset();
}
};
service.submit(new ThreadMail(destinatarios, clazz, p));

But, I got a org.hibernate.HibernateException: createCriteria is not valid
without active transaction
when I tried to load an entity in a model to be used in the PageMail.

How can I attach the Transaction to the thread to get this working?

thanks in advance

-- 
Fernando Wermus.

www.linkedin.com/in/fernandowermus

Re: rendering a page for an email: org.hibernate.HibernateException: createCriteria is not valid without active transaction

Posted by Jeremy Thomerson <je...@wickettraining.com>.
On Fri, Sep 3, 2010 at 12:10 PM, Fernando Wermus
<fe...@gmail.com>wrote:

> Hi all,
>     I have coded the following to render a mail,
>
>
> Application app;
> try{
> app=MyApplication.get();
> }catch(Exception e){
> app=new WicketTester().getApplication();
> }
> final Application app2=app;
> final ExecutorService service = new ScheduledThreadPoolExecutor(1) {
> @Override
> protected void beforeExecute(final Thread t, final Runnable r) {
> Application.set(app2);
> };
> @Override
> protected void afterExecute(final Runnable r, final Throwable t) {
> Application.unset();
> }
> };
> service.submit(new ThreadMail(destinatarios, clazz, p));
>
> But, I got a org.hibernate.HibernateException: createCriteria is not valid
> without active transaction
> when I tried to load an entity in a model to be used in the PageMail.
>
> How can I attach the Transaction to the thread to get this working?
>
> thanks in advance
>
> --
> Fernando Wermus.
>
> www.linkedin.com/in/fernandowermus
>


This has nothing in particular to do with Wicket, and would be hard to
answer without knowing the details of what you are doing for transaction
management.

-- 
Jeremy Thomerson
http://www.wickettraining.com