tags:

views:

534

answers:

3

To my application I need to use hibernate with apache cxf. Problem is after I configure hibernate to apache cxf, application didn't start. It gives an error saying it cannot find the LocalSessionFactoryBean class from the springframework (which I used to create the factorySession). I'm new to apache cxf, so it could be an error in my part. Can any of you guys tell me what is the best way to configure hibernate with apache cxf.

Thanks in advance

A: 

use CXF for you service layer, and keep hibernate in the back end. It should not really interfere with what spring or hibernate are doing.

Martlark
A: 

This really looks like a classpath problem, that you somehow lost the hiberate jars from the classpath when adding CXF. That missing bean is a hibernate class.

bmargulies
+2  A: 

Mickael Istria wrote: Your problem may be related to a conflict on the "asm" dependency. Indeed, CXF uses a newer "cglib" version than hibernate, that itself uses a newer "asm", so that it sometimes cause issues when integrating them together (Exception such as NoSuchMethodError) The workaround I use is to replace the old cglib (and its dependency) by the cglib-nodep.jar in your classpath, that is OK for Hibernate and does not require an old "asm".

If you use Maven, this sample should help you to understand how to resolve such conflict:

     <dependency>
           <!-- This artifacts adds hibernate as a dependency -->
           <groupId>org.ow2.bonita</groupId>
           <artifactId>bonita-server</artifactId>
           <version>4.0.1</version>
           <scope>test</scope>
          <exclusions>
               <exclusion> <!-- Then remove the dependency to cglib to avoid
 conflicts with CXF's asm -->
                  <groupId>cglib</groupId>
                   <artifactId>cglib</artifactId>
               </exclusion>
           </exclusions>
       </dependency>
            <!-- Replaced old cglib by cglib-nodep -->
       <dependency>
           <groupId>cglib</groupId>
           <artifactId>cglib-nodep</artifactId>
          <version>2.1_3</version>
       </dependency>

I Found the solution here: http://mail-archives.apache.org/mod%5Fmbox/cxf-users/200901.mbox/%[email protected]%3E

atomsfat