6 Replies Latest reply on Dec 17, 2008 7:19 PM by dunks80

    org.hibernate.AssertionFailure: collection

    Petr Juza Newbie

      Hello,
      I have the following domain model:

      public class AssetGroup {
       @ManyToOne(fetch = FetchType.LAZY)
       @JoinColumn(name = "iteration_id", nullable = false)
       private Iteration iteration;
      ...
      }


      public class Iteration {
       @OneToMany(fetch = FetchType.LAZY,
       cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
       @JoinTable(name = "iteration_to_links",
       joinColumns = { @JoinColumn(name = "iteration_id") },
       inverseJoinColumns = { @JoinColumn(name = "link_id") })
       @ForeignKey(name = "to_iteration_fk", inverseName = "to_link_fk")
       @BatchSize(size = 10)
       @Unversioned
       private Set<ExternalLink> externalLinks;
      ...
      }


      When I activate Envers (=I add hibernate.ejb.event.* properties to persistence.xml) then this error occurs: "org.hibernate.AssertionFailure: collection [com.anect.rmt.domain.Iteration.externalLinks] was not processed by flush()."

      I have tested it with Hibernate 3.2.6 and also with Hibernate 3.3.1. Of course with last version of Envers (1.1.0_beta and 1.1.0_beta_Hibernate3.3).

      I have tried to remove cascade parameters for example, but nothing helps.
      What helped was when I changed "post-*" to "post-commit-*" in configuration but then versioning didn't work at all.

      I don't need to have versioning for externalLinks now (I know that this type of association doesn't work yet) but I need to application runs without errors at this moment.

      Thank you in advance for any help.
      PETER


        • 1. Re: org.hibernate.AssertionFailure: collection
          Adam Warski Master

          Hello,

          could you post the full stack trace? And describe the environment in which you're using Envers?

          Also, the SVN version supports the "externalLinks" collection.

          --
          Adam

          • 2. Re: org.hibernate.AssertionFailure: collection
            Petr Juza Newbie

            Hello,
            of course, I would strive to send as much as possible.

            I use Spring 2.5, Hibernate is configured over JPA (exactly I use JPA with Hibernate EntityManager - org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean with HibernateJpaVendorAdapter). Application runs on Tomcat 6.x.

            When I add new Asset or AssetGroup, then it works fine, problem is during updating. During update isn't Iteration changed, Iteration expresses binding to certain period of time only.

            And here is full stack trace (our code starts with com.anect.rmt):

            2008-09-25 07:18:51,444 ERROR: an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
            org.hibernate.AssertionFailure: collection [com.anect.rmt.domain.Iteration.externalLinks] was not processed by flush()
             at org.hibernate.engine.CollectionEntry.postFlush(CollectionEntry.java:228)
             at org.hibernate.event.def.AbstractFlushingEventListener.postFlush(AbstractFlushingEventListener.java:356)
             at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
             at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
             at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:304)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:194)
             at $Proxy35.flush(Unknown Source)
             at com.anect.common.dao.impl.jpa.GenericJpaDaoImpl.update(GenericJpaDaoImpl.java:41)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
             at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
             at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
             at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:138)
             at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
             at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
             at $Proxy36.update(Unknown Source)
             at com.anect.rmt.services.impl.AssetServiceImpl.updateAsset(AssetServiceImpl.java:71)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
             at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
             at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
             at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
             at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
             at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:54)
             at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
             at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
             at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
             at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
             at $Proxy45.updateAsset(Unknown Source)
             at com.anect.rmt.web.controllers.assets.AssetController.saveAsset(AssetController.java:201)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.apache.el.parser.AstValue.invoke(AstValue.java:172)
             at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
             at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
             at javax.faces.component._MethodExpressionToMethodBinding.invoke(_MethodExpressionToMethodBinding.java:78)
             at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:57)
             at javax.faces.component.UICommand.broadcast(UICommand.java:143)
             at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:366)
             at javax.faces.component.UIViewRoot.process(UIViewRoot.java:261)
             at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:151)
             at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
             at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:103)
             at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:76)
             at javax.faces.webapp.FacesServlet.service(FacesServlet.java:151)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
             at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
             at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
             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:233)
             at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
             at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
             at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
             at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
             at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
             at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
             at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
             at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
             at java.lang.Thread.run(Thread.java:595)


            What did you mean with SVN?

            PETER

            • 3. Re: org.hibernate.AssertionFailure: collection
              Adam Warski Master

              Hello,

              of course when I copied your mapping and tried running it I got no errors ;)

              Which Hibernate version are you using?

              SVN - I meant the "trunk" version of code, see: http://anonsvn.jboss.org/repos/envers/trunk for the code and http://www.jboss.org/envers/source.html for build instructions.

              Adam

              • 4. Re: org.hibernate.AssertionFailure: collection
                Petr Juza Newbie

                As I wrote - I have tested it with Hibernate 3.2.6 and now I'm using Hibernate 3.3.1.

                Please where is problem? :)

                PETER

                • 5. Re: org.hibernate.AssertionFailure: collection
                  Adam Warski Master

                  Ah yes, sorry, didn't spot this.

                  Well, it looks like other people using Spring also have this problem, for example when using Hibernate Search (or when any event listeners are installed):
                  http://forum.springframework.org/showthread.php?t=49058

                  There's also a bug in JIRA, I don't know how it relates to 3.2.6 and 3.3:
                  http://opensource.atlassian.com/projects/hibernate/browse/HHH-2763

                  It's hard for me to say anything more, as I don't have a failing test case :) (if you have time and can do it, please create a minimal one, you can then attach it to a bug in JIRA :) )

                  Adam

                  • 6. Re: org.hibernate.AssertionFailure: collection
                    dunks80 Newbie

                    I hate to do a "Me too" post but i've also experienced the problem described above. Using JBoss 4.2.2.GA with the latest hibernate and envers libs from the 3.4.0 snapshot build I kept getting the "org.hibernate.AssertionFailure: collection [] was not processed by flush()" error. I looked at all of Adam's tests and tried to modify them to reproduce the error in his test suite to no avail. Finally at the edge of sanity I removed all the class level @Audited annotations from my entities and started marking individual fields as @Audited (including the collection that the error was occurring on) and suddenly everything started work. I guess the point of this post is has anyone gained any more insight into why this error might occur and how to avoid it when using envers?