Re: GuiceFilter PersistFilter in web application

240 views
Skip to first unread message

Moandji Ezana

unread,
May 31, 2013, 1:41:58 PM5/31/13
to google...@googlegroups.com

Are you also using @Transactional? That can cause a UnitOfWork to begin twice.

Mwanji

On May 31, 2013 6:04 PM, "Hui Ouyang" <houy...@gmail.com> wrote:
Hi,
I am using Guice + JPA+ Hibernate for web application running within Jboss.
1. per http://google-guice.googlecode.com/git/javadoc/com/google/inject/persist/PersistFilter.html
I did the following to register
PersistFilter in my service module, which extends from ServletModule
install(new JpaPersistModule(PERSITENCE_UNIT_NAME));
filter("/*").through(PersistFilter.class);
2. per http://google-guice.googlecode.com/git/javadoc/com/google/inject/servlet/GuiceFilter.html, I added the guiceFilter to my web.xml

Buy I got the following error when starting Jboss
[[/]] Exception starting filter guiceFilter: java.lang.IllegalStateException: Persistence service was already initialized.]
If I remove "
filter("/*").through(PersistFilter.class);" then it works fine. The reason I added this is to make sure it is work per request.

What is the right way to achieve the goal for work per request? I notice that there is one
JpaPersistModule but do not use it. Should it be used together with PersistFilter?

Thx.

Hui

--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-guice...@googlegroups.com.
To post to this group, send email to google...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-guice?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Stephan Classen

unread,
May 31, 2013, 3:18:50 PM5/31/13
to google...@googlegroups.com
You are calling PersistService.start() somewhere in your code.
If you are using the PersistFilter you must not call PersistService.start() yourselves because it is called by the PersistFilter.
Reply all
Reply to author
Forward
0 new messages