3 Replies Latest reply on Nov 10, 2015 1:15 AM by valentintsm

    Conflict Hibernate and JBoss

    valentintsm

      Hi,

      I'm having issue to solve some dependencies conflict.

      I have developed an application that is working on my local JBoss Dev Studio with JBoss EAP 6.1+  using Hibernate 4.2.18.Final.

      However this same application fails when I deploy it on our server - JBoss EAP 6.4.0.GA.

      I'm getting these error:

      java.lang.NoClassDefFoundError: Could not initialize class com.lionco.hibernate.HibernateUtil

      and

      org.hibernate.annotations.common.reflection.java.JavaReflectionManager cannot be cast to org.hibernate.annotations.common.reflection.MetadataProviderInjector

      It seems to be related to dependencies conflict with maybe hibernate.logging but I cannot find any information about it.

      My current Pom.xml:

      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        
      <modelVersion>4.0.0</modelVersion>
        
      <groupId>com.lionco</groupId>
        
      <artifactId>Bus</artifactId>
        
      <version>0.0.1-SNAPSHOT</version>
        
      <packaging>war</packaging>
        
      <name>Bus</name>
        
      <description>Bus</description>
        
      <build>
        
      <sourceDirectory>src</sourceDirectory>
        
      <plugins>
        
      <plugin>
        
      <artifactId>maven-compiler-plugin</artifactId>
        
      <version>3.1</version>
        
      <configuration>
        
      <source>1.8</source>
        
      <target>1.8</target>
        
      </configuration>
        
      </plugin>
        
      <plugin>
        
      <artifactId>maven-war-plugin</artifactId>
        
      <version>2.4</version>
        
      <configuration>
        
      <warSourceDirectory>WebContent</warSourceDirectory>
        
      <failOnMissingWebXml>false</failOnMissingWebXml>
        
      </configuration>
        
      </plugin>
        
      </plugins>
        
      </build>
        
      <dependencies>
        
      <dependency>
        
      <groupId>asm</groupId>
        
      <artifactId>asm-all</artifactId>
        
      <version>3.3.1</version>
        
      </dependency>
        
      <dependency>
        
      <groupId>com.sun.jersey</groupId>
        
      <artifactId>jersey-bundle</artifactId>
        
      <version>1.14</version>
        
      <exclusions>
        
      <exclusion>
        
      <artifactId>jersey-bean-validation</artifactId>
        
      <groupId>org.glassfish.jersey.ext</groupId>
        
      </exclusion>
        
      <exclusion>
        
      <artifactId>bean-validator</artifactId>
        
      <groupId>org.glassfish.hk2.external</groupId>
        
      </exclusion>
        
      </exclusions>
        
      </dependency>
        
      <dependency>
        
      <groupId>org.json</groupId>
        
      <artifactId>json</artifactId>
        
      <version>20090211</version>
        
      </dependency>
        
      <dependency>
        
      <groupId>javax.xml</groupId>
        
      <artifactId>jaxrpc-api</artifactId>
        
      <version>1.1</version>
        
      </dependency>
        
      <dependency>
        
      <groupId>org.apache.axis</groupId>
        
      <artifactId>axis</artifactId>
        
      <version>1.4</version>
        
      </dependency>
        
      <dependency>
        
      <groupId>javax.mail</groupId>
        
      <artifactId>mail</artifactId>
        
      <version>1.4</version>
        
      </dependency>
        
      <dependency>
        
      <groupId>com.github.dvdme</groupId>
        
      <artifactId>ForecastIOLib</artifactId>
        
      <version>LATEST</version>
        
      </dependency>
        
      <dependency>
        
      <groupId>org.reficio</groupId>
        
      <artifactId>soap-builder</artifactId>
        
      <version>1.0.0-SNAPSHOT</version>
        
      </dependency>
        
      <dependency>
        
      <groupId>org.reficio</groupId>
        
      <artifactId>soap-client</artifactId>
        
      <version>1.0.0-SNAPSHOT</version>
        
      </dependency>
        
      <dependency>
        
      <groupId>org.reficio</groupId>
        
      <artifactId>soap-server</artifactId>
        
      <version>1.0.0-SNAPSHOT</version>
        
      </dependency>
        
      <dependency>
        
      <groupId>commons-httpclient</groupId>
        
      <artifactId>commons-httpclient</artifactId>
        
      <version>3.1</version>
        
      </dependency>
        
      <dependency>
        
      <groupId>mysql</groupId>
        
      <artifactId>mysql-connector-java</artifactId>
        
      <version>5.1.36</version>
        
      </dependency>
        
      <dependency>
        
      <groupId>com.google.maps</groupId>
        
      <artifactId>google-maps-services</artifactId>
        
      <version>0.1.7</version>
        
      </dependency>
        
      <dependency>
        
      <groupId>org.hibernate</groupId>
        
      <artifactId>hibernate-core</artifactId>
        
      <version>4.2.18.Final</version>
        
      </dependency>
        
      <dependency>
        
      <groupId>org.hibernate</groupId>
        
      <artifactId>hibernate-c3p0</artifactId>
        
      <version>4.2.18.Final</version>
        
      </dependency>
        
      <dependency>
        
      <groupId>javax.mail</groupId>
        
      <artifactId>mail</artifactId>
        
      <version>1.4.7</version>
        
      </dependency>
        
      <dependency>
        
      <groupId>org.quartz-scheduler</groupId>
        
      <artifactId>quartz</artifactId>
        
      <version>2.1.5</version>
        
      </dependency>
        
      <dependency>
        
      <groupId>org.jboss.logging</groupId>
        
      <artifactId>jboss-logging</artifactId>
        
      <version>3.3.0.Final</version>
        
      </dependency>
        
      </dependencies>
        
      <repositories>
        
      <repository>
        
      <id>reficio</id>
        
      <url>http://repo.reficio.org/maven/</url>
        
      </repository>
        
      </repositories>
      </project>

       

      I tried to change the scope of Hibernate-core to compile, remove it...but nothing has fixed my issue.

      Any idea would be greatly appreciated

      Thanks

        • 1. Re: Conflict Hibernate and JBoss
          jaysensharma

          Hello,

           

          java.lang.NoClassDefFoundError: Could not initialize class com.lionco.hibernate.HibernateUtil

          The above class is not offered by JBoss EAP hence you will need to check your application or custom module to see if it is included properly or not.

          Can you please share the location of this class "com.lionco.hibernate.HibernateUtil" or the JAR which contains this class?  Like have you placed it inside your WEB-INF/lib or WEB-INF/classes or EAR/lib ...etc.

           

           

          org.hibernate.annotations.common.reflection.java.JavaReflectionManager cannot be cast to org.hibernate.annotations.common.reflection.MetadataProviderInjector

           

            Above error indicates that you might be packaging some other version of hibernate JARs inside your application which might be causing some conflicts with the JBoss EAP 6.4 provided Hibernate JARs. NOTE the below mentioned JARs contains the class  "org.hibernate.annotations.common.reflection.java.JavaReflectionManager" which is provided by EAP 6.4.

           

             $JBOSS_HOME/modules/system/layers/base/org/hibernate/commons-annotations/main/hibernate-commons-annotations-4.0.2.Final-redhat-1.jar

           

           

              Hence can you please share the following details:

          1). The list of JARs present inside your application.

          2). The complete stack Trace of the error/exception which you are getting?

          3). Are you purely using hibernate only or Using JPA as well?

          4). The exact location of the class "com.lionco.hibernate.HibernateUtil" inside your EAR/WAR?

          5). Are you creating any custom module for placing your JARs?

           

          Regards

          Jay SenSharma

          • 2. Re: Conflict Hibernate and JBoss
            valentintsm

            Hi Jay,

             

            Thank you for your reply.

             

            Please find below the different information:

            1)

            jar-1.jpg

            jar-2.jpg

            2)

            jboss-error.jpg

            3) I am using purely Hibernate to connect to a database

            4) My class HibernateUtil is located in the package com.lionco.hibernate inside Java Resources\src

            5) I am only using Maven to manage my dependencies: Jersey to create a Rest Webservice and Hibernate as ORM

             

            This application is working fine on Tomcat and on JBoss Developer Studio with JBoss EAP 6.1+ as a server but I know that Jboss EAP goes with a couple of pre-installed libraries such as Hibernate.

            That is also why I have downgraded my hibernate version from 5.0 to 4.2.18.Final following the JBoss documentation to get the same version as per the server.

             

            Thanks for your help

            • 3. Re: Conflict Hibernate and JBoss
              valentintsm

              I have been able to access to the Production Server and I think I found what the issue is but not how to fix it.

               

              On my local environment, the dependencies deployed on my JBoss Server (exact same version as the production one, Jboss EAP 6.4) look like this:

              JBOSS_Issue_local-version.jpg

               

              However on the Production Server, the dependencies look like this:

              JBOSS_Issue.jpg

               

              I don't know why but it seems that when I deploy my application on the Production Server it deploys several instances of the same library with different version (e.g. Hibernate-commons-annotations) and end up with a conflict.

               

               

              What I basically did was:

              - Checking my pom.xml, but it only contains one version of each library

              - Checking the dependencies of each library but couldn't find the redundant libraries (e.g. Maven Repository: org.hibernate » hibernate-core » 4.2.18.Final)

              - Removing libraries from my code to keep only hibernate and jersey but it didn't fix it.

               

              I don't understand how it can be running well on my environment with the same version of the JBoss Server (EAP 6.4) and not on the production server?

               

              Any help would be greatly appreciated.

              Thanks