Re: Guice 2 / WarpPersist & Wicket

2010-05-30 Thread nino martinez wael
Argh, hotkeys in gmail, and daughter jumping around , heres the code
notice the extra call in acessor method:

import org.apache.wicket.injection.web.InjectorHolder;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;

import com.google.inject.Inject;
import com.netdesign.codan.dao.PhoneDao;

public abstract class DetachableModelWithDao extends
LoadableDetachableModel implements IModel {

@Inject
private transient PhoneDao phoneDao;

public DetachableModelWithDao() {
InjectorHolder.getInjector().inject(this);
}

public PhoneDao getPhoneDao() {
InjectorHolder.getInjector().inject(this);
return phoneDao;
}

public void setPhoneDao(PhoneDao phoneDao) {
this.phoneDao = phoneDao;
}

}


2010/5/31 nino martinez wael :
> As workaround for now I am doing this, but are a very ugly way:
>
>
>
> 2010/5/31 nino martinez wael :
>> Okay tried moving the @Inject from the setter to the field
>> declaration, still not working. Tried to add the keyword transient to
>> the field, still not working :/ Im a little lost here for once..
>> Remember it's only when my loadable detachable models are called the
>> 2nd time, on first load it works.. The injector part of the ldms look
>> like this, and im on wicket 1.4.9:
>>
>> import org.apache.wicket.injection.web.InjectorHolder;
>>
>> import com.google.inject.Inject;
>> import com.netdesign.codan.dao.PhoneDao;
>>
>> public class ClassWithDao {
>>
>>        public ClassWithDao() {
>>
>>                InjectorHolder.getInjector().inject(this);
>>        }
>>
>>       �...@inject
>>        private transient PhoneDao phoneDao;
>>
>>        public PhoneDao getPhoneDao() {
>>                return phoneDao;
>>        }
>>
>>        public void setPhoneDao(PhoneDao phoneDao) {
>>                this.phoneDao = phoneDao;
>>        }
>>
>> }
>>
>>
>> 2010/5/28 nino martinez wael :
>>> Hi Guys
>>>
>>> I wanted to try out the now working wicket injector holder for my
>>> webapp. But I keep getting:
>>> "java.lang.IllegalStateException: EntityManager is closed
>>>     at 
>>> org.hibernate.ejb.EntityManagerImpl.getSession(EntityManagerImpl.java:66)
>>>     at 
>>> org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:93)"
>>>
>>> I've traced it so far that it's not an issue with page creation or
>>> page reloads. But seems to be when my detachablemodels or
>>> datasources(inmethod) are being loaded. It's like the entity manager
>>> gets closed after a request and never opened again.
>>>
>>> I followed this guide:
>>> http://www.atomicgamer.com/dev/2009/10/wicket-guice-2-0-warp-persist-2-0/
>>>
>>> web.xml looks like this:
>>>
>>>        
>>>                warpPersistFilter
>>>                
>>> com.wideplay.warp.persist.PersistenceFilter
>>>        
>>>
>>>        
>>>                warpPersistFilter
>>>                /*
>>>        
>>>
>>>        
>>>                wicket.WicketWarp
>>>                /*
>>>        
>>>
>>> And my warpmodule like this:
>>>
>>>                Module warpModule = PersistenceService.usingJpa().across(
>>>                                UnitOfWork.REQUEST).forAll(
>>>                                Matchers.annotatedWith(Transactional.class), 
>>> Matchers.any())
>>>                                .buildModule();
>>>
>>> WicketApplication:
>>>       �...@override
>>>        protected void init() {
>>>                super.init();
>>>                addComponentInstantiationListener(new 
>>> GuiceComponentInjector(this,
>>>                                getGuiceInjector()));
>>>        }
>>>        protected Injector getGuiceInjector() {
>>>                return Guice.createInjector(new Module());
>>>        }
>>>
>>>
>>> In advance thanks, and please ask if I forgot something. Otherwise I
>>> have to roll back and ask a singleton for the dao each time and that
>>> would be really undesirable.
>>>
>>> -Nino
>>>
>>
>

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



Re: Guice 2 / WarpPersist & Wicket

2010-05-30 Thread nino martinez wael
As workaround for now I am doing this, but are a very ugly way:



2010/5/31 nino martinez wael :
> Okay tried moving the @Inject from the setter to the field
> declaration, still not working. Tried to add the keyword transient to
> the field, still not working :/ Im a little lost here for once..
> Remember it's only when my loadable detachable models are called the
> 2nd time, on first load it works.. The injector part of the ldms look
> like this, and im on wicket 1.4.9:
>
> import org.apache.wicket.injection.web.InjectorHolder;
>
> import com.google.inject.Inject;
> import com.netdesign.codan.dao.PhoneDao;
>
> public class ClassWithDao {
>
>        public ClassWithDao() {
>
>                InjectorHolder.getInjector().inject(this);
>        }
>
>       �...@inject
>        private transient PhoneDao phoneDao;
>
>        public PhoneDao getPhoneDao() {
>                return phoneDao;
>        }
>
>        public void setPhoneDao(PhoneDao phoneDao) {
>                this.phoneDao = phoneDao;
>        }
>
> }
>
>
> 2010/5/28 nino martinez wael :
>> Hi Guys
>>
>> I wanted to try out the now working wicket injector holder for my
>> webapp. But I keep getting:
>> "java.lang.IllegalStateException: EntityManager is closed
>>     at 
>> org.hibernate.ejb.EntityManagerImpl.getSession(EntityManagerImpl.java:66)
>>     at 
>> org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:93)"
>>
>> I've traced it so far that it's not an issue with page creation or
>> page reloads. But seems to be when my detachablemodels or
>> datasources(inmethod) are being loaded. It's like the entity manager
>> gets closed after a request and never opened again.
>>
>> I followed this guide:
>> http://www.atomicgamer.com/dev/2009/10/wicket-guice-2-0-warp-persist-2-0/
>>
>> web.xml looks like this:
>>
>>        
>>                warpPersistFilter
>>                
>> com.wideplay.warp.persist.PersistenceFilter
>>        
>>
>>        
>>                warpPersistFilter
>>                /*
>>        
>>
>>        
>>                wicket.WicketWarp
>>                /*
>>        
>>
>> And my warpmodule like this:
>>
>>                Module warpModule = PersistenceService.usingJpa().across(
>>                                UnitOfWork.REQUEST).forAll(
>>                                Matchers.annotatedWith(Transactional.class), 
>> Matchers.any())
>>                                .buildModule();
>>
>> WicketApplication:
>>       �...@override
>>        protected void init() {
>>                super.init();
>>                addComponentInstantiationListener(new 
>> GuiceComponentInjector(this,
>>                                getGuiceInjector()));
>>        }
>>        protected Injector getGuiceInjector() {
>>                return Guice.createInjector(new Module());
>>        }
>>
>>
>> In advance thanks, and please ask if I forgot something. Otherwise I
>> have to roll back and ask a singleton for the dao each time and that
>> would be really undesirable.
>>
>> -Nino
>>
>

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



Re: Guice 2 / WarpPersist & Wicket

2010-05-30 Thread nino martinez wael
Okay tried moving the @Inject from the setter to the field
declaration, still not working. Tried to add the keyword transient to
the field, still not working :/ Im a little lost here for once..
Remember it's only when my loadable detachable models are called the
2nd time, on first load it works.. The injector part of the ldms look
like this, and im on wicket 1.4.9:

import org.apache.wicket.injection.web.InjectorHolder;

import com.google.inject.Inject;
import com.netdesign.codan.dao.PhoneDao;

public class ClassWithDao {

public ClassWithDao() {

InjectorHolder.getInjector().inject(this);
}

@Inject
private transient PhoneDao phoneDao;

public PhoneDao getPhoneDao() {
return phoneDao;
}

public void setPhoneDao(PhoneDao phoneDao) {
this.phoneDao = phoneDao;
}

}


2010/5/28 nino martinez wael :
> Hi Guys
>
> I wanted to try out the now working wicket injector holder for my
> webapp. But I keep getting:
> "java.lang.IllegalStateException: EntityManager is closed
>     at 
> org.hibernate.ejb.EntityManagerImpl.getSession(EntityManagerImpl.java:66)
>     at 
> org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:93)"
>
> I've traced it so far that it's not an issue with page creation or
> page reloads. But seems to be when my detachablemodels or
> datasources(inmethod) are being loaded. It's like the entity manager
> gets closed after a request and never opened again.
>
> I followed this guide:
> http://www.atomicgamer.com/dev/2009/10/wicket-guice-2-0-warp-persist-2-0/
>
> web.xml looks like this:
>
>        
>                warpPersistFilter
>                
> com.wideplay.warp.persist.PersistenceFilter
>        
>
>        
>                warpPersistFilter
>                /*
>        
>
>        
>                wicket.WicketWarp
>                /*
>        
>
> And my warpmodule like this:
>
>                Module warpModule = PersistenceService.usingJpa().across(
>                                UnitOfWork.REQUEST).forAll(
>                                Matchers.annotatedWith(Transactional.class), 
> Matchers.any())
>                                .buildModule();
>
> WicketApplication:
>       �...@override
>        protected void init() {
>                super.init();
>                addComponentInstantiationListener(new 
> GuiceComponentInjector(this,
>                                getGuiceInjector()));
>        }
>        protected Injector getGuiceInjector() {
>                return Guice.createInjector(new Module());
>        }
>
>
> In advance thanks, and please ask if I forgot something. Otherwise I
> have to roll back and ask a singleton for the dao each time and that
> would be really undesirable.
>
> -Nino
>

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



Guice 2 / WarpPersist & Wicket

2010-05-28 Thread nino martinez wael
Hi Guys

I wanted to try out the now working wicket injector holder for my
webapp. But I keep getting:
"java.lang.IllegalStateException: EntityManager is closed
 at 
org.hibernate.ejb.EntityManagerImpl.getSession(EntityManagerImpl.java:66)
 at 
org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:93)"

I've traced it so far that it's not an issue with page creation or
page reloads. But seems to be when my detachablemodels or
datasources(inmethod) are being loaded. It's like the entity manager
gets closed after a request and never opened again.

I followed this guide:
http://www.atomicgamer.com/dev/2009/10/wicket-guice-2-0-warp-persist-2-0/

web.xml looks like this:


warpPersistFilter

com.wideplay.warp.persist.PersistenceFilter



warpPersistFilter
/*



wicket.WicketWarp
/*


And my warpmodule like this:

Module warpModule = PersistenceService.usingJpa().across(
UnitOfWork.REQUEST).forAll(
Matchers.annotatedWith(Transactional.class), 
Matchers.any())
.buildModule();

WicketApplication:
@Override
protected void init() {
super.init();
addComponentInstantiationListener(new 
GuiceComponentInjector(this,
getGuiceInjector()));
}
protected Injector getGuiceInjector() {
return Guice.createInjector(new Module());
}


In advance thanks, and please ask if I forgot something. Otherwise I
have to roll back and ask a singleton for the dao each time and that
would be really undesirable.

-Nino

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