views:

27

answers:

1

I'm try to create web service base on axis2 (without a ServletContext). I have code that work properly (Spring + Hebirnate) and try to put it into AAR as it describe in this article and this one . All work good except hibernate.

I have:

    <bean id="dataSourceCommon" class="org.apache.commons.dbcp.BasicDataSource"
  destroy-method="close">
  <property name="driverClassName" value="oracle.jdbc.OracleDriver" />
  <property name="url" value="jdbc:oracle:oci:@xxxx" />
  <property name="username" value="xxxx" />
  <property name="password" value="xxxx" />
  <property name="maxActive" value="10" />
  <property name="defaultAutoCommit" value="false" />
 </bean>

 <bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  <property name="dataSource" ref="dataSourceCommon" />

  <property name="mappingLocations">
   <value>classpath:xxxx.hbm.xml</value>
  </property>

  <property name="hibernateProperties">
   <props>
    <prop key="hibernate.dialect">
     org.hibernate.dialect.Oracle10gDialect
    </prop>
   </props>
  </property>
 </bean>

 <bean id="hibernateDaoSupport" abstract="true"
  class="org.springframework.orm.hibernate3.support.HibernateDaoSupport">
  <property name="sessionFactory" ref="hibernateSessionFactory" />
 </bean>

 <bean id="transactionManager"
  class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  <property name="sessionFactory" ref="hibernateSessionFactory" />
 </bean>

This file in root of AAR.

I copy this aar-file into c:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\axis2\WEB-INF\services, but if I try to run Tomcat server I get error:

org.springframework.beans.factory.BeanCreationException:

Error creating bean with name 'hibernateSessionFactory' defined in class path resource [xxxx.context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError ... Caused by: java.lang.ClassNotFoundException: org.hibernate.cfg.Configuration




where my mistake?

A: 

If the error is

java.lang.ClassNotFoundException: org.hibernate.cfg.Configuration

then the mistake is that you did not include the Hibernate classes (hibernate.jar, etc) on the claspath of your webapp (WEB-INF/lib).

matt b
Oh yes!So easy! Befoure I added *jar file only in AAR\lib!Now all work!
Testus