Nuwan
Nuwan

Reputation: 177

how to configure hibernate to work with apache cxf

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

Upvotes: 1

Views: 2701

Answers (3)

atomsfat
atomsfat

Reputation: 2913

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_mbox/cxf-users/200901.mbox/%[email protected]%3E

Upvotes: 2

bmargulies
bmargulies

Reputation: 100013

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.

Upvotes: 0

Martlark
Martlark

Reputation: 14581

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.

Upvotes: 0

Related Questions