1 2 3 Previous Next 31 Replies Latest reply on Aug 3, 2011 11:14 PM by jaikiran

    Trying to use Envers with AS-provided Hibernate

    adamw

      Hello,

       

      I'm trying to deploy an application that uses Envers into AS7 and use the Hibernate included. (If I bundle Hibernate with my app it works fine). The problem is dom4j: Envers uses that and passes some dom4j classes to Hibernate. So I can't bundle it in the .war. I tried adding a Depends: org.dom4j to the manifest, but then I get:

       

      Caused by: java.lang.ClassCastException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory

                at org.dom4j.DocumentFactory.getInstance(DocumentFactory.java:97)

                at org.dom4j.DocumentHelper.getDocumentFactory(DocumentHelper.java:36)

                at org.dom4j.DocumentHelper.createDocument(DocumentHelper.java:41)

                at org.hibernate.envers.configuration.RevisionInfoConfiguration.generateDefaultRevisionInfoXmlMapping(RevisionInfoConfiguration.java:86)

       

      Which would suggest again a classloading issue. There's only one copy of the dom4j jar, but I suspect the classloader used for Hibernate-core and its dependencies is different from the one used for Hibernate-envers and its dependencies, am I right? Any ideas?

       

      Thanks,

      Adam

        • 1. Re: Trying to use Envers with AS-provided Hibernate
          jaikiran

          What exception do you get if you don't bundle dom4j.jar within your application?

          • 2. Re: Trying to use Envers with AS-provided Hibernate
            adamw

            The above one. Bundling dom4j in the war obviously won't work .

             

            Adam

            • 3. Re: Trying to use Envers with AS-provided Hibernate
              jaikiran

              Oh I misread a part of your original description. I should actually have asked - what's the exception stacktrace that you see when you don't add a Dependencies: org.dom4j. A CNFE I'm guessing, but I want to see the stacktrace to know which exact module is missing that dep and how it uses that library.

              • 4. Re: Trying to use Envers with AS-provided Hibernate
                adamw

                Sure. Here's the stack without Dependenices: http://pastie.org/private/tevhsuq3zp83v3ofohiegg

                And with: http://pastie.org/private/ns9bsq6htoox6elixm6cq

                 

                lms.war is my application

                 

                Adam

                • 5. Re: Trying to use Envers with AS-provided Hibernate
                  alesj

                  Make Envers as a module and have it depend on "org.dom4j". :-)

                  • 6. Re: Trying to use Envers with AS-provided Hibernate
                    adamw

                    That's what I was going to try in the evening

                    Just wondering if it's possible to use using the traditional bundle-in-war approach (which I think should be possible)

                     

                    Adam

                    • 7. Re: Trying to use Envers with AS-provided Hibernate
                      nickarls

                      What happens if you just make it a part of the hibernate module? Dump it in the module dir with the rest of them and register it in module.xml

                      • 8. Re: Trying to use Envers with AS-provided Hibernate
                        jaikiran

                        Ales Justin wrote:

                         

                        Make Envers as a module and have it depend on "org.dom4j". :-)

                        I thought Strong had already worked on that https://issues.jboss.org/browse/AS7-928. Looks like it's not available in upstream.

                        • 9. Re: Trying to use Envers with AS-provided Hibernate
                          alesj

                          Just wondering if it's possible to use using the traditional bundle-in-war approach (which I think should be possible)

                          Imo it should.

                          My guess is that war' child-first rule probably somehow gets in the way ...

                          • 10. Re: Trying to use Envers with AS-provided Hibernate
                            alesj

                            What happens if you just make it a part of the hibernate module? Dump it in the module dir with the rest of them and register it in module.xml

                            That would definitely work :-), but I doubt you wanna have Envers everywhere you have HIbernate.

                            • 11. Re: Trying to use Envers with AS-provided Hibernate
                              adamw

                              I tried quickly creating a separate module (depending on Hibernate), but then Hibernate doesn't see Envers at all - the new auto-discovery looks for implementations of Integrator in the classpath and it seems the EnversIntegrator isn't found. I think Strong already worked on that, but not sure if it got commited.

                               

                              Do you think the bundle-envers-in-war approach has any chances to work?

                               

                              Adam

                              • 12. Re: Trying to use Envers with AS-provided Hibernate
                                jaikiran

                                Adam Warski wrote:

                                 

                                 

                                Do you think the bundle-envers-in-war approach has any chances to work?

                                 

                                 

                                It should work. If it doesn't then we have to figure out why it doesn't work and try and fix it. After all, envers is just another library that the user can wish to package within his application.

                                • 13. Re: Trying to use Envers with AS-provided Hibernate
                                  nickarls

                                  dom4j is really sticky, for some reason I can't even get it excluded from envers in maven when trying the maven build. It still gets included and results in a classcastexception against the version on the AS...

                                  • 14. Re: Trying to use Envers with AS-provided Hibernate
                                    adamw

                                    Really? It doesn't get included for me.
                                    My dependencies:

                                     

                                     

                                     

                                        <dependencies>
                                            <!-- JEE -->
                                            <dependency>
                                                <groupId>org.jboss.spec</groupId>
                                                <artifactId>jboss-javaee-6.0</artifactId>
                                                <type>pom</type>
                                                <scope>provided</scope>
                                                <version>1.0.0.Final</version>
                                            </dependency>
                                    
                                      <dependency>
                                                                  <groupId>org.hibernate</groupId>
                                      <artifactId>hibernate-envers</artifactId>
                                                                  <version>4.0.0.Beta1</version>
                                      <exclusions>
                                      <exclusion>
                                                                                      <groupId>org.hibernate</groupId>
                                      <artifactId>hibernate-core</artifactId>
                                      </exclusion>
                                      <exclusion>
                                                                                      <groupId>org.hibernate</groupId>
                                                                                      <artifactId>hibernate-entitymanager</artifactId>
                                      </exclusion>
                                      <exclusion>
                                                                                      <groupId>org.hibernate</groupId>
                                                                                      <artifactId>hibernate-tools</artifactId>
                                      </exclusion>
                                      <exclusion>
                                                                                      <groupId>org.hibernate</groupId>
                                                                                      <artifactId>hibernate-commons-annotations</artifactId>
                                      </exclusion>
                                      <exclusion>
                                                                                      <groupId>org.jboss.logging</groupId>
                                      <artifactId>jboss-logging</artifactId>
                                      </exclusion>
                                      <exclusion>
                                      <groupId>ant</groupId>
                                      <artifactId>ant</artifactId>
                                      </exclusion>
                                      <exclusion>
                                      <groupId>dom4j</groupId>
                                      <artifactId>dom4j</artifactId>
                                      </exclusion>
                                      </exclusions>
                                      </dependency>
                                        </dependencies>
                                    
                                    

                                     

                                    Adam

                                    1 2 3 Previous Next