休止状態を使用して DB に接続し、データを取得する方法を取得しました。このメソッドは、スタンドアロンの Java アプリとして実行すると正常に機能します。ただし、Tomcat にデプロイして Web サービスとして呼び出そうとすると、次のようなエラーが発生します。私の方法は、DB 接続が確立される最初で唯一の場所です。つまり、Tomcat 内でデータソースを定義していません。
No Hibernate Session bound to thread, and configuration does not allow creation
of non-transactional one here
at
org.springframework.orm.hibernate3.LocalSessionFactoryBean$TransactionAwareInvocationHandler.invoke(LocalSessionFactoryBean.
私の休止状態の設定ファイル:
<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="myDataSource" />
<property name="exposeTransactionAwareSessionFactory" value="true" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">none</prop>
<prop key="hibernate.statement_cache.size">10</prop>
<prop key="hibernate.c3p0.min_size">1</prop>
<prop key="hibernate.c3p0.max_size">10</prop>
<prop key="hibernate.connection.autocommit">false</prop>
<prop key="hibernate.default_schema">${mydbSchema}</prop>
<prop key="hibernate.current_session_context_class">thread</prop>
<prop key="hibernate.transaction.manager_lookup_class">com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup</prop>
</props>
</property>
</bean>
次の休止状態モジュールを使用しています。
hibernate-annotations 3.4.0.GA、hibernate-core 3.3.1.GA、hibernate 3.2.6.ga、hibernate-commons-annotations 3.1.0.GA