3 Replies Latest reply on Mar 31, 2014 9:39 AM by Jussi Kukkonen

    How to resolve Loader Constraint violation

    swapnil narvekar Newbie

      Hi All,

           I am deploying my web application - test.war on JBoss 6.

      After successful deployment when I try to log in I get following exception

       

       

      complete request: org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.LinkageError: loader constraint violation: when resolving interface method "org.hibernate.event.EventSource.getTransaction()Lorg/hibernate/Transaction;" the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) of the current class, org/hibernate/envers/synchronization/AuditProcessManager, and the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) for resolved class, org/hibernate/event/EventSource, have different Class objects for the type org/hibernate/Transaction used in the signature

       

      I am putting jboss-classloading.xml here.

      -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

      <?xml version="1.0" encoding="UTF-8"?>

      <!--See http://phytodata.wordpress.com/2010/10/21/demystifying-the-jboss5-jboss-classloading-xml-file-->

      <classloading xmlns="urn:jboss:classloading:1.0"

                    name="emhada.war"   

                    domain="emhada"

                    parent-first="false"

                    export-all="NON_EMPTY"

                    import-all="true">

          <parent-policy>

            <before-filter>

             <javabean xmlns="urn:jboss:javabean:2.0" class="org.jboss.classloader.plugins.filter.NegatingClassFilter">

              <constructor>

               <parameter>

                <javabean xmlns="urn:jboss:javabean:2.0" class="org.jboss.classloader.spi.filter.PackageClassFilter">

                 <constructor>

                  <parameter>org.hibernate,org.apache.commons.collections,com.sun.mail.smtp</parameter>

                 </constructor>

                </javabean>

               </parameter>

              </constructor>

             </javabean>

            </before-filter>

          </parent-policy>             

      </classloading>

      --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

       

      Also putting a snippet of persistence.xml which may be responsible for the exception:

      --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

      <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" />

                             

                  <property name="org.hibernate.envers.audit_table_prefix" value="A" />

                 

                  <property name="org.hibernate.envers.audit_table_suffix" value="" />

                 

                  <property name="org.hibernate.envers.do_not_audit_optimistic_locking_field" value="false" />

                 

                  <property name="org.hibernate.envers.store_data_at_delete" value="true" />

                 

      -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

       

      I read following link : http://wiki.metawerx.net/wiki/Java.lang.LinkageError

      It says :

      This error occurs when two classloaders have loaded the same class with different signatures.

       

      ie: you have the same class twice in your CLASSPATH, but the classes are different (usually different versions).

       

      But I did not find org.hibernate.event.EventSource loaded twice.

       

      Please throw light on it.So that I can manage to solve this error.

      Thanks