1 Reply Latest reply on Jun 19, 2012 7:12 AM by nilshan

    Hibernate class loading issue

    nilshan

      Hello..

       

      In my application I am using Hibernate 3 + Spring 3.1 + Jboss AS 7.1.0

       

      The EAR deployment is something like

       

      ECOM.ear

        |

        |-- Message.jar ( EJB Jar )

        |-- Queue.jar ( EJB Jar )

        |-- Console.war ( war )

        |-- lib ( Hibernate 3 jars + other jars )

       

      in my jboss-deployment-structure.xml I have added

       

      <deployment>

          <exclusions>

              <module name="org.hibernate" />

          </exclusions>

      </deployment>

       

      I have been facing issue ( stanalone deployment mode ) for above ear deployment:

       

      : java.lang.classcastexception org.hibernate.dialect.mysqldialect cannot be cast to org.hibernate.dialect.dialect

       

      I guess this is class loading issue. How would I stop my ear loading the classes that jboss AS 7 provides.

       

      Please provide suggestion..Thanks.

        • 1. Re: Hibernate class loading issue
          nilshan

          The above problem is solved by adding custom module for hibernate 3.

           

               <module name="org.hibernate" slot="3" export="true"/>

           

          I have other question regarding same structure.... 

           

          ECOM.ear

            |

            |-- Message.jar ( EJB Jar )

            |-- Queue.jar ( EJB Jar )

            |-- Console.war ( war )

               |----WEB-INF/LIB...   ( Here, at deployment time the referenced jar are being copied from EAR/LIB .. e.g spring jar)

            |-- lib ( Hibernate 3 jars + other jars )

           

          Here, the Console.war refers to ECOM.war/Lib jar files at compile time for compilation errors.  When I do deploy the EAR, the referenced jar files from EAR Lib is also copiled to Console.war / WEB-INF/lib.  

           

          This creates the class loading issue.

           

          How would I exclude the WAR / LIB at jboss deployment process using jboss-deployment-structure.xml so, that classloading issue can be resolved ?

           

          E.G.

           

          <sub-deployment name="Console.war" >

                   <resources>

                       <resource-root path="WEB-INF/lib/*" >

                             <filter>

                               <exclude path="/**"/>

                             </filter>

                       </resource-root>

                  </resources>                  

                     <dependencies>           

                      <module name="deployment.ECOM.ear.Message.jar" export="true" services="export"/>

                      .........

                  </dependencies>       

          </sub-deployment>

           

          Something like this.....?

           

          Please provide your suggestion or better deployment approach... Thanks in advance.