Spring and Hibernate inside Axis2 inside Tomcat6
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:
whe开发者_高级运维re my mistake?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
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
).
精彩评论