我們試圖配置Spring應用程序以使用JTA事務。它並不像它失敗,但是我們所做的一切只是做了選擇而忽略了我們的持久性操作。無法使JTA在Spring 3.1上運行jboss AS7.1
正如你可以在下面的日誌中看到,即使保存語句運行沒有插入語句,既沒有例外,既不是一個錯誤/警告日誌
的server.log
DEBUG [xxxx.xxxx.persistence] (http--0.0.0.0-8080-1) execute $Proxy363.save([email protected])
DEBUG [org.springframework.data.repository.core.support.TransactionalRepositoryProxyPostProcessor$CustomAnnotationTransactionAttributeSource] (http--0.0.0.0-8080-1) Adding transactional method 'save' with attribute: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''
DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] (http--0.0.0.0-8080-1) Returning cached instance of singleton bean 'transactionManager'
DEBUG [org.springframework.transaction.jta.JtaTransactionManager] (http--0.0.0.0-8080-1) Participating in existing transaction
INFO [xxxx.xxxx.impl.BpmnUserBusinessImpl] (http--0.0.0.0-8080-1) Last Assigned Time Updated to *******, Thu Sep 06 15:48:48 ICT 2012
這是就像應用服務器認爲一切順利。而如果您檢查表格,則不進行插入或更新。
我們打算與Spring應用程序一起使用的數據源與運行在同一應用程序服務器中的Java EE war應用程序成功地用於JTA事務。
由於我們不知道問題出在哪裏,所以我想把它放在完整的背景下。
- 彈簧3.1.2-RELEASE
- 冬眠4.1.5.Final
- 彈簧數據JPA 1.1.1.Final
- apache的軸1.4
- 的JBoss AS7.1
- DB:oracle 10g
我們一直在嘗試各種各樣瘋狂的配置,爲了嘗試使它工作,所以我只是將h最簡單的一個。
standalone.xml
<datasource jta="true" jndi-name="java:jboss/datasources/EngineDS" pool-name="EngineDS" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:oracle:thin:@server:port:****</connection-url>
<driver>oracle</driver>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>100</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>****</user-name>
<password>****</password>
</security>
<statement>
<prepared-statement-cache-size>32</prepared-statement-cache-size>
<share-prepared-statements>true</share-prepared-statements>
</statement>
</datasource>
<drivers>
<driver name="oracle" module="com.oracle.ojdbc6">
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
</driver>
</drivers>
的web.xml
[...]
<resource-ref id="DS">
<res-ref-name>EngineDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
<mapped-name>java:jboss/datasources/EngineDS</mapped-name>
</resource-ref>
[...]
<jpa:repositories base-package="whatever.core.repositories" />
<jee:jndi-lookup id="dataSource" jndi-name="EngineDS" cache="true" resource-ref="true" expected-type="javax.sql.DataSource"/>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="whatever.core.entities" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="${hibernate.show_sql}" />
<property name="generateDdl" value="${jpa.generateDdl}" />
<property name="databasePlatform" value="${jpa.dialect}" />
</bean>
</property>
</bean>
<tx:annotation-driven />
<tx:jta-transaction-manager />
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
<bean class="org.springframework.orm.hibernate4.HibernateExceptionTranslator"/>
我們在過去的JBoss AS5由彈簧JPA-config.xml中/彈簧3.0應用程序與JTA交易一起工作,所以這不是我第一次做這件事,而且我們一直在尋找所有可能的BL gs和我能找到的開源項目。然而,任何似乎對每個人都順利運作的東西似乎在我的應用程序中被忽略。我確信它應該是我們在某處丟失了一些非常愚蠢的東西,但是我們迄今爲止已經嘗試了70多種不同的配置,並且沒有一個看起來沒有做一個簡單的插入,否則在不嘗試JTA時會工作。 (我們使用軸1.4的事實可能是相關的或不是,但我想告訴,因爲我們的應用程序只在web服務調用後觸發動作)。在這一點上,我們開始相信配置超自然的活動...
任何線索的人?