我嘗試在axis2上創建web服務基礎(沒有ServletContext)。我的代碼工作正常(Spring + Hebirnate)並嘗試將其放入AAR,如this article和this one中所述。所有的工作都很好,除了休眠。Tomcat6內的Axis2內部的Spring和Hibernate
我:
<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>
此文件在AAR的根。
我複製此AAR文件爲c:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\axis2\WEB-INF\services
,但如果我嘗試運行Tomcat服務器,我得到錯誤:
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
在我的錯誤呢?
哦,是的! 太容易了! Befoure我只在AAR \ lib中添加* jar文件! 現在所有的工作! – Testus 2010-08-05 05:03:30