12 Replies Latest reply on Sep 2, 2009 11:01 AM by gdfgd eqwe

    Seam and Envers

    Robert Morse Apprentice

      Hello,
      I have a working Seam application (JBoss 5.1.0.GA, Seam 2.2.0.CR1, Envers 1.2.1.GA-hibernate-3.3, hibernate-core-3.3.2.GA), and I'm trying to incorporate Hibernate's Envers (Entity Versioning).  For the most part, it appears to be working well, but I have a very simple ManyToMany relationship that saves and versions correctly on the first persist, but fails with subsequent updates.  The exception trace is below.  If I remove the event listeners from my persistence.xml, everything works again.  I'm not really sure what to make of the exception and was hoping to get some pointers from this group.  Thanks.


      Here's what's in my persistence.xml




      <property name="hibernate.ejb.event.post-insert" value="org.hibernate.ejb.event.EJB3PostInsertEventListener, org.hibernate.envers.event.AuditEventListener" />
      <property name="hibernate.ejb.event.post-update" value="org.hibernate.ejb.event.EJB3PostUpdateEventListener, org.hibernate.envers.event.AuditEventListener" />
      <property name="hibernate.ejb.event.post-delete" value="org.hibernate.ejb.event.EJB3PostDeleteEventListener, org.hibernate.envers.event.AuditEventListener" />
      <property name="hibernate.ejb.event.pre-collection-update" value="org.hibernate.envers.event.AuditEventListener" />
      <property name="hibernate.ejb.event.pre-collection-remove" value="org.hibernate.envers.event.AuditEventListener" />
      <property name="hibernate.ejb.event.post-collection-recreate" value="org.hibernate.envers.event.AuditEventListener" /> 
      
      






      The exception:




      19:51:12,751 WARN  [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_2] TwoPhaseCoordinator.beforeCompletion - failed for com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple@1d7d1778
      org.hibernate.TransactionException: Transaction not successfully started
           at org.hibernate.transaction.CMTTransaction.rollback(CMTTransaction.java:110)
           at org.hibernate.envers.synchronization.AuditSync.beforeCompletion(AuditSync.java:171)
           at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:101)
           at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:269)
           at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:89)
           at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)
           at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1423)
           at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:137)
           at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)
           at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:162)
           at org.jboss.seam.transaction.UTTransaction.commit(UTTransaction.java:52)
           at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:613)
           at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:604)
           at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsAfterPhase(SeamPhaseListener.java:345)
           at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:245)
           at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:196)
           at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:175)
           at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:114)
           at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
           at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
           at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
           at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
           at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
           at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
           at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
           at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
           at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
           at java.lang.Thread.run(Thread.java:637)
      19:51:12,798 WARN  [SeamPhaseListener] uncaught exception, passing to exception handler
      java.lang.IllegalStateException: Could not commit transaction
           at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:625)
           at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:604)
           at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsAfterPhase(SeamPhaseListener.java:345)
           at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:245)
           at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:196)
           at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:175)
           at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:114)
           at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
           at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
           at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
           at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
           at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
           at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
           at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
           at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
           at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
           at java.lang.Thread.run(Thread.java:637)
      Caused by: javax.transaction.RollbackException: [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] Could not commit transaction.
           at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1435)
           at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:137)
           at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)
           at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:162)
           at org.jboss.seam.transaction.UTTransaction.commit(UTTransaction.java:52)
           at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:613)
           ... 51 more
      Caused by: org.hibernate.TransactionException: Transaction not successfully started
           at org.hibernate.transaction.CMTTransaction.rollback(CMTTransaction.java:110)
           at org.hibernate.envers.synchronization.AuditSync.beforeCompletion(AuditSync.java:171)
           at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:101)
           at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:269)
           at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:89)
           at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)
           at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1423)
           ... 56 more
      20:06:43,839 INFO  [SkinBean] Removed
      



        • 1. Re: Seam and Envers
          Robert Morse Apprentice

          Solved.
          This is related to My Link


          Because h:selectManyListbox doesn't work with Sets, and because Envers deals with Sets, I was creating a new HashSet from the ArrayList used in the UI.  Doing a HashSet.clear() and then repopulating from the ArrayList rather than creating a new HashSet avoids this issue.

          • 2. Re: Seam and Envers
            Chris Simons Expert

            Thanks for posting the resolution.


            I am using Seam and Envers but had never run across the issue you were experiencing; if I run across this ever, I will have at least an idea why.

            • 3. Re: Seam and Envers
              gdfgd eqwe Novice

              Hy!


              I would like to set up envers with JBoss 5.1 And Seam 2.2.
              I set persistence.xml properties,And I copied the envers.jar to ear lib dir and jboss default/lib directory, but I always get the following error:


              Do you have any idea?
              I user JBoss 5.1 seam 2.2 envers latest jar?.


              Should I added additional jars to the correct work?
              thx.




              22:20:49,271 ERROR [AbstractKernelController] Error installing to Start: name=persistence.unit:unitN
              ame=dvc-ear.ear/dvc-ejb.jar#dvc state=Create
              java.lang.LinkageError: loader constraint violation: when resolving method "org.hibernate.cfg.AnnotationConfiguration.getReflectionManager()Lorg/hibernate/annotations/common/re
              flection/ReflectionManager;" the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) of the current class,
               org/hibernate/envers/configuration/AuditConfiguration, and the class loader (instance of org/jboss/
              classloader/spi/base/BaseClassLoader) for resolved class, org/hibernate/cfg/AnnotationConfiguration,
               have different Class objects for the type org/hibernate/annotations/common/reflection/ReflectionMan
              ager used in the signature
                   at org.hibernate.envers.configuration.AuditConfiguration.<init>(AuditConfiguration.java:78)
                   at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:99)
                   at org.hibernate.envers.event.AuditEventListener.initialize(AuditEventListener.java:260)
                   at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198)
                   at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181)
                   at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194)
                   at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1338)
                   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
                   at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
                   at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
                   at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.
              java:132)
              




              • 4. Re: Seam and Envers
                Robert Morse Apprentice

                I didn't copy it anywhere in the JBoss deployment.  I only have it in my ear lib.

                • 5. Re: Seam and Envers
                  gdfgd eqwe Novice

                  thx.


                  I removed envers.jar from jboss dir,but the probelem was not solved.


                  Did You add envers.jar to apllication.xml or ejb project build path?

                  • 6. Re: Seam and Envers
                    Leo van den berg Master

                    Hi Frank,


                    It works in my environment after copying the Envers jar to the lib directory of the server. But the problem I had, (And i think you're suffering the same issue) is cnflicting support jars. Be careful in adding all kind of commons-lib, because it caused a lot of trpuble.


                    Check the dependenccies of envers and Hibernate and create a single set of libraries. I used Maven to do that and it saved me a lot of agony-

                    • 7. Re: Seam and Envers
                      gdfgd eqwe Novice

                      thx.


                      I have hibernate-commons-annotations both ear/lib and jboss/lib directory.
                      It works!


                      But always get the following exception, when the entity has a blolb atrribute:






                      Caused by: org.hibernate.MappingException: Type not supported for auditing: org.hibernate.type.SerializableToBlobType, on entity com.shop, property 'data'.
                           at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.throwUnsupportedTypeException(AuditMetadataGenerator.java:438)
                           at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.addValue(AuditMetadataGenerator.java:147)
                           at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.addProperties(AuditMetadataGenerator.java:161)
                           at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateFirstPass(AuditMetadataGenerator.java:381)
                           at org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:87)
                           at org.hibernate.envers.configuration.AuditConfiguration.<init>(AuditConfiguration.java:86)
                           at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:99)
                           at org.hibernate.envers.event.AuditEventListener.initialize(AuditEventListener.java:260)
                           at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198)
                           at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181)
                           at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194)



                      • 8. Re: Seam and Envers
                        Leo van den berg Master

                        Use the following annotation on the attribute:




                        @NotAudited
                        




                        It will not try to audit the value-

                        • 9. Re: Seam and Envers
                          gdfgd eqwe Novice

                          Thank you very much.


                          Possible to versioning blob attributes, because it is important part of my application to retrieve old values of blobs?

                          • 10. Re: Seam and Envers
                            Leo van den berg Master

                            I am not sure, but looking at your exception and the Envers it seems like a No, however i'vr seen a earlier release with auditing on Lob's . Try the envers forum maybe?

                            • 11. Re: Seam and Envers
                              Robert Morse Apprentice

                              I have classes annotated like this, and versioning works fine.  Strings also work:



                                 @Lob
                                 @Column(name="DOCUMENT_CONTENT")
                                 private byte[] content;
                                 
                              




                              • 12. Re: Seam and Envers
                                gdfgd eqwe Novice

                                thanks!


                                I use Blob type currently, and I got the above exception!