Re: Issue 597 in google-guice: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times
Comment #22 on issue 597 by fjackst...@gmail.com: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times http://code.google.com/p/google-guice/issues/detail?id=597 Pull request is here: https://github.com/google/guice/pull/820 -- You received this message because this project is configured to send all issue notifications to this address. You may adjust your notification preferences at: https://code.google.com/hosting/settings -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To unsubscribe from this group and stop receiving emails from it, send an email to google-guice-dev+unsubscr...@googlegroups.com. To post to this group, send email to google-guice-dev@googlegroups.com. Visit this group at http://groups.google.com/group/google-guice-dev. For more options, visit https://groups.google.com/d/optout.
Re: Issue 597 in google-guice: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times
Comment #21 on issue 597 by rfili...@gmail.com: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times http://code.google.com/p/google-guice/issues/detail?id=597 A unit test that exposes the bug and confirms the fix of remi.bantos is attached. Attachments: JpaPersistServiceTest.java 2.2 KB -- You received this message because this project is configured to send all issue notifications to this address. You may adjust your notification preferences at: https://code.google.com/hosting/settings -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To unsubscribe from this group and stop receiving emails from it, send an email to google-guice-dev+unsubscr...@googlegroups.com. To post to this group, send email to google-guice-dev@googlegroups.com. Visit this group at http://groups.google.com/group/google-guice-dev. For more options, visit https://groups.google.com/d/optout.
Re: Issue 597 in google-guice: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times
Comment #16 on issue 597 by tae...@gmail.com: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times http://code.google.com/p/google-guice/issues/detail?id=597 I am seeing the same behavior as indicated by the above link regarding the PersistFilter. In my case, I am using Shiro which has some filters that will cause all filters to process a request a second time. This will include the Persist filter, which will then blow up when it starts the unit of work again. To fix this locally, I implemented a wrapper around the PersistFilter that basically implements a pattern in the Shiro class OncePerRequestFilter. That is, I check an attribute on the request called PERSIST.FILTERED and only call to the wrapped filter if this has not been set to true. So, a couple of questions: - Is this a bad idea or a sign that I have done something else awry? - Any reason not to have this logic in the main PersistFilter directly? (I can put together a pull request easily enough.) -- You received this message because this project is configured to send all issue notifications to this address. You may adjust your notification preferences at: https://code.google.com/hosting/settings -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To unsubscribe from this group and stop receiving emails from it, send an email to google-guice-dev+unsubscr...@googlegroups.com. To post to this group, send email to google-guice-dev@googlegroups.com. Visit this group at http://groups.google.com/group/google-guice-dev. For more options, visit https://groups.google.com/groups/opt_out.
Re: Issue 597 in google-guice: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times
Comment #17 on issue 597 by remi.ban...@gmail.com: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times http://code.google.com/p/google-guice/issues/detail?id=597 Hi, I have implemented a fix for this issue as already mentioned above. http://code.google.com/r/remibantos-guice-persist/source/detail?r=3a9d1012fedd403c2aaddc47701f8ace9eaa3eb8 There is also a thread about this behavior here: https://groups.google.com/forum/#!topic/google-guice/n6D0T_yCVyc Some people would like this fix to be reviewed and pulled to master. Until it is pulled/released, you can eventually add your own JpaPersistService class with this fix to your application in order that it takes precedence other JpaPersistService class from guice-persist library during classloader execution. -- You received this message because this project is configured to send all issue notifications to this address. You may adjust your notification preferences at: https://code.google.com/hosting/settings -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To unsubscribe from this group and stop receiving emails from it, send an email to google-guice-dev+unsubscr...@googlegroups.com. To post to this group, send email to google-guice-dev@googlegroups.com. Visit this group at http://groups.google.com/group/google-guice-dev. For more options, visit https://groups.google.com/groups/opt_out.
Re: Issue 597 in google-guice: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times
Comment #18 on issue 597 by tae...@gmail.com: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times http://code.google.com/p/google-guice/issues/detail?id=597 So, that does not seem to be quite what I am seeing. My specific case is as follows: - Request comes in - FilterChain starts - PersistFilter starts a unit of work - continues FilterChain - ShiroFilter sees I need to login, redirects to login url - Filter Chains runs again - Persist filter throws exception starting a new unit of work. - Finally of the first call to PersistFilter runs, calling UnitOfWork.end() In my case, the problem is essentially that the PersistFilter is not reentrant. Simple fix is to make so that it is. At least, I believe that is my problem. Again, if I am doing something else wrong, I'm ears. (And, if I need to open another ticket for this, let me know.) -- You received this message because this project is configured to send all issue notifications to this address. You may adjust your notification preferences at: https://code.google.com/hosting/settings -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To unsubscribe from this group and stop receiving emails from it, send an email to google-guice-dev+unsubscr...@googlegroups.com. To post to this group, send email to google-guice-dev@googlegroups.com. Visit this group at http://groups.google.com/group/google-guice-dev. For more options, visit https://groups.google.com/groups/opt_out.
Re: Issue 597 in google-guice: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times
Comment #15 on issue 597 by remi.ban...@gmail.com: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times http://code.google.com/p/google-guice/issues/detail?id=597 I'm a little bit pessimistic for this fix to be released by someone soon... It seems like there is no more activity nor maintenance on guice-persist. Just take a look at open / not analysed issues. After having pushed on google code this fix (to a fork), i had to bring myself to fix it...by myself. So i did it by customysing the JpaPersistService on my webapp ... :( By the way, there are a lot of duplicates or similar issues on guice-persist, so there would probably be another solutions to deal with this problem. -- You received this message because this project is configured to send all issue notifications to this address. You may adjust your notification preferences at: https://code.google.com/hosting/settings -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To unsubscribe from this group and stop receiving emails from it, send an email to google-guice-dev+unsubscr...@googlegroups.com. To post to this group, send email to google-guice-dev@googlegroups.com. Visit this group at http://groups.google.com/group/google-guice-dev. For more options, visit https://groups.google.com/groups/opt_out.
Re: Issue 597 in google-guice: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times
Comment #13 on issue 597 by twr@gmail.com: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times http://code.google.com/p/google-guice/issues/detail?id=597 I encountered the same issue with JpaPersistService.end() and would like it to be addressed. How likely is it that the fix suggested in the previous post would end up in a new release? Problem: If an exception is thrown in com.google.inject.persist.jpa.JpaPersistService.end() on em.close(), entityManager.remove() is not called. When used from com.google.inject.persist.PersistFilter, this results in java.lang.IllegalStateException for every consequent invocation of the filter. 1) exception on em.close() org.hibernate.exception.GenericJDBCException: Could not close connection at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110) at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.releaseConnection(LogicalConnectionImpl.java:327) at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.close(LogicalConnectionImpl.java:199) at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.close(JdbcCoordinatorImpl.java:141) at org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl.close(TransactionCoordinatorImpl.java:276) at org.hibernate.internal.SessionImpl.close(SessionImpl.java:352) at org.hibernate.ejb.EntityManagerImpl.close(EntityManagerImpl.java:137) at com.google.inject.persist.jpa.JpaPersistService.end(JpaPersistService.java:81) at com.google.inject.persist.PersistFilter.doFilter(PersistFilter.java:91) 2) exception on filter invocation java.lang.IllegalStateException: Work already begun on this thread. Looks like you have called UnitOfWork.begin() twice without a balancing call to end() in between. at com.google.inject.internal.util.$Preconditions.checkState(Preconditions.java:142) at com.google.inject.persist.jpa.JpaPersistService.begin(JpaPersistService.java:66) at com.google.inject.persist.PersistFilter.doFilter(PersistFilter.java:87) -- You received this message because this project is configured to send all issue notifications to this address. You may adjust your notification preferences at: https://code.google.com/hosting/settings -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To unsubscribe from this group and stop receiving emails from it, send an email to google-guice-dev+unsubscr...@googlegroups.com. To post to this group, send email to google-guice-dev@googlegroups.com. Visit this group at http://groups.google.com/group/google-guice-dev. For more options, visit https://groups.google.com/groups/opt_out.
Re: Issue 597 in google-guice: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times
Comment #14 on issue 597 by remi.ban...@gmail.com: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times http://code.google.com/p/google-guice/issues/detail?id=597 I'm a little bit pessimistic for this fix to be released by someone soon... It seems like there is no more activity nor maintenance on guice-persist (and even guice?). Just take a look at open / not analysed issues. After having pushed on google code this fix (to a fork), i had to bring myself to fix it...by myself. So i did it by customysing the JpaPersistService on my webapp ... :( By the way, there are a lot of duplicates or similar issues on guice-persist, so there would probably be another solutions to deal with this problem. Injection of several data-sources with guice-persist is quite painfull. So I plan to migrate my app to a CDI implementation soon and use EJB persistence unit injection (which is very easy to do for dealing with many datasources), perhaps guice owners plan the same :) (Seriously, it would be great for users to have a clear view on guice roadmap if there is one.) -- You received this message because this project is configured to send all issue notifications to this address. You may adjust your notification preferences at: https://code.google.com/hosting/settings -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To unsubscribe from this group and stop receiving emails from it, send an email to google-guice-dev+unsubscr...@googlegroups.com. To post to this group, send email to google-guice-dev@googlegroups.com. Visit this group at http://groups.google.com/group/google-guice-dev. For more options, visit https://groups.google.com/groups/opt_out.
Re: Issue 597 in google-guice: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times
Comment #12 on issue 597 by remi.ban...@gmail.com: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times http://code.google.com/p/google-guice/issues/detail?id=597 Hi, I have cloned git repository and added the following thing: EntityManager#close() method call in JpaPersistService#end() method is now surrounded by a try{}. entityManager.remove() is now always performed in a finally. With this modification, unitOfWork is now properly ended, even if there is RuntimeException exception during close() -- You received this message because this project is configured to send all issue notifications to this address. You may adjust your notification preferences at: https://code.google.com/hosting/settings -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To unsubscribe from this group and stop receiving emails from it, send an email to google-guice-dev+unsubscr...@googlegroups.com. To post to this group, send email to google-guice-dev@googlegroups.com. Visit this group at http://groups.google.com/group/google-guice-dev. For more options, visit https://groups.google.com/groups/opt_out.
Re: Issue 597 in google-guice: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times
Comment #11 on issue 597 by remi.ban...@gmail.com: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times http://code.google.com/p/google-guice/issues/detail?id=597 I agree also that JPAPersistService should not perform an explicit begin of the unit of work. However, regarding my personal case, i think there is a real issue in guice-persist that should be fixed and which is linked to this issue. Indeed, the end() method of JpaPersistService might not work when the jdbc connection is already closed by an external application. So the test i was talking about in my previous post would be to check that the connection is not already closed before calling the close() method on the EntityManager in JpaPersistService end() method. (Perhaps i should report another issue linked to this one?) -- You received this message because this project is configured to send all issue notifications to this address. You may adjust your notification preferences at: https://code.google.com/hosting/settings -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To unsubscribe from this group and stop receiving emails from it, send an email to google-guice-dev+unsubscr...@googlegroups.com. To post to this group, send email to google-guice-dev@googlegroups.com. Visit this group at http://groups.google.com/group/google-guice-dev?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Issue 597 in google-guice: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times
Comment #8 on issue 597 by martins@gmail.com: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times http://code.google.com/p/google-guice/issues/detail?id=597 I really think that introducing in Guice Persist any kind of checking whether unit of work has already begun is a bad idea: 1) That's the whole point of Unit Of Work pattern: the user is responsible for explicitly starting it and ending it as well. If it fails to do so, that's not a bug in Guice Persist, that's a bug in the user's code or other libraries; 2) If we reuse an existing unit of work, we kind of hijack an existing (most probably not flushed) ORM session which could be a cause for much more obscure bugs than those people are describing here. -- You received this message because this project is configured to send all issue notifications to this address. You may adjust your notification preferences at: https://code.google.com/hosting/settings -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To unsubscribe from this group and stop receiving emails from it, send an email to google-guice-dev+unsubscr...@googlegroups.com. To post to this group, send email to google-guice-dev@googlegroups.com. Visit this group at http://groups.google.com/group/google-guice-dev?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Issue 597 in google-guice: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times
Comment #7 on issue 597 by remi.ban...@gmail.com: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times http://code.google.com/p/google-guice/issues/detail?id=597 I had the same issue in an application on Tomcat. I've read this article which helped me to figure out what the problem was: http://barinskis.me/blog/2013/04/30/persistence-unit-of-work-pattern-in-sitebricks/ In my personal case, i had a request thread in Tomcat which was using a connexion for a very long time (a timeout setting was not configured properly in a client stub ...). During this period, Tomcat DBCP had closed and removed the connexion from pool considering it as abandoned (this is a dbcp common setting). So the associated unit of work was not properly ended. Therefore, a next request which was reusing the same thread from tomcat pool were doing unitofwork.begin() although an entitymanager were already attached to thread (see JpaPersistService class, its entityManager instance is a thread-local variable) Hope this help. I think we could handle that by adding a test in PersistFilter or JpaPersistService to manage this situation. -- You received this message because this project is configured to send all issue notifications to this address. You may adjust your notification preferences at: https://code.google.com/hosting/settings -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To unsubscribe from this group and stop receiving emails from it, send an email to google-guice-dev+unsubscr...@googlegroups.com. To post to this group, send email to google-guice-dev@googlegroups.com. Visit this group at http://groups.google.com/group/google-guice-dev?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Issue 597 in google-guice: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times
Comment #6 on issue 597 by g.zoritc...@gmail.com: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times http://code.google.com/p/google-guice/issues/detail?id=597 I had to move back quickly to warp-persist because of this precondition (even if I do not use directly UnitOfWork but only the PersistFilter). Nobody to answer the questions of the previous comments? -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To post to this group, send email to google-guice-dev@googlegroups.com. To unsubscribe from this group, send email to google-guice-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-guice-dev?hl=en.
Re: Issue 597 in google-guice: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times
Comment #1 on issue 597 by dha...@google.com: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times http://code.google.com/p/google-guice/issues/detail?id=597 We should probably correct the javadoc. -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To post to this group, send email to google-guice-dev@googlegroups.com. To unsubscribe from this group, send email to google-guice-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-guice-dev?hl=en.
Re: Issue 597 in google-guice: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times
Comment #2 on issue 597 by michal.g...@gmail.com: Persist Extension: UnitOfWork.begin() throws IllegalStateException when called multiple times http://code.google.com/p/google-guice/issues/detail?id=597 Yes, that would be fine. The limitation that we can not nest unit of works will have impact on users migrating from warp-persist. Would it be possible to add boolean isWorking() method to the UnitOfWork interface? Could you please describe what was the reasoning behind this? -- You received this message because you are subscribed to the Google Groups google-guice-dev group. To post to this group, send email to google-guice-dev@googlegroups.com. To unsubscribe from this group, send email to google-guice-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-guice-dev?hl=en.