0

私たちは現在、プロジェクトでSpring 3とhibernate 4.4を使用しています。私のデータベース設定xmlのスニペットは次のようになります

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
        destroy-method="close">
        <property name="driverClass">
            <value>${jdbc.driver.className}</value>
        </property>
        <property name="jdbcUrl">
            <value>${jdbc.url}</value>
        </property>
        <property name="user">
            <value>${jdbc.username}</value>
        </property>
        <property name="password">
            <value>${jdbc.password}</value>
        </property>
    </bean>

    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource">
            <ref bean="dataSource" />
        </property>

        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">${jdbc.hibernate.dialect}</prop>
                <prop key="hibernate.show_sql">false</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
                <prop key="hibernate.jdbc.batch_size">20</prop>
                <prop key="hibernate.current_session_context_class">managed</prop>
            </props>
        </property>
        <property name="packagesToScan" value="com.sample.entity" />
    </bean>
    <bean id="transactionManager"
        class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory">
            <ref bean="sessionFactory" />
        </property>
    </bean>
    <tx:annotation-driven />

戦争をテストしているときに、この例外に遭遇しました。

13:27:19,511 ERROR TransactionInterceptor:419 - Application exception overridden by rollback exception
    org.springframework.beans.factory.BeanCreationNotAllowedException: 
    Error creating bean with name 'transactionManager': Singleton bean creation not allowed 
    while the singletons of this factory are in destruction (Do not request a bean from a 
    BeanFactory in a destroy method implementation!)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:212)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.determineTransactionManager(TransactionAspectSupport.java:248)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:100)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)

これが構成ファイルに記載されている destroy-method =close によるものかどうかはわかりません。また、サービス層とデータベース層の両方で @Transactional アノテーションを使用しています。これにより問題が発生しますか? 複数の人 (約 150 人) がすべて同時にアプリケーションにアクセスしようとするシナリオをテストしようとしていました。

親切に私を助けてください..詳細が必要な場合はお知らせください。

ありがとう

4

1 に答える 1

0

春のドキュメントがセクション3.6.1.5で述べているように

起動とシャットダウンの呼び出しの順序が重要になる場合があります。2 つのオブジェクト間に「依存関係」が存在する場合、依存側は依存関係の後に開始され、依存関係の前に停止します。ただし、直接の依存関係が不明な場合もあります。特定のタイプのオブジェクトが別のタイプのオブジェクトの前に開始する必要があることしか知らない場合があります。そのような場合、SmartLifecycle インターフェースは別のオプションを定義します。つまり、そのスーパーインターフェースである Phased で定義されている getPhase() メソッドです。

したがって、 SmartLifeCycle、SmartLifeCycle インターフェース 1の Javadoc を実装するには、Bean が必要です。ライフサイクル プロセッサ.

お役に立てれば !!

于 2013-02-02T08:14:08.490 に答える