2012-09-06 2 views
1

우리는 Spring 어플리케이션을 JTA 트랜잭션을 사용하도록 구성하려고합니다. 그것은 실패하는 것만 큼은 아니지만, 우리가 시도한 모든 것은 선택을 수행하고 지속성 작업을 무시합니다.Spring 3.1을 사용하는 jboss AS7.1에서 JTA를 작동시킬 수 없습니다.

당신이

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 

그것은 아니 INSERT 문,도 예외, 어느 오류/경고 로그

server.log에 없다 심지어 문을 저장 실행하지만, 다음과 같은 로그에서 볼 수 있듯이 애플리케이션 서버가 모든 것이 옳았다 고 생각하는 생각. 표를 확인하면 삽입이나 업데이트가 수행되지 않습니다.

스프링 응용 프로그램과 함께 사용하려는 데이터 소스는 동일한 응용 프로그램 서버에서 실행되는 Java EE war 응용 프로그램에서 JTA 트랜잭션과 함께 성공적으로 사용됩니다.

문제가 어디에서 발생했는지 모르기 때문에 전체 내용을 모두 넣고 싶습니다.

  • 스프링 3.1.2-RELEASE
  • 1.1.1.Final
  • 아파치
  • 1.4 축 보스의 AS7.1
  • 스프링 데이터 JPA 4.1.5.Final 동면 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> 
[...] 

우리는 과거 제이 보스 AS5에 만들었다

<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"/> 

스프링 JPA-config.xml에/봄 3.0 응용 프로그램 JTA 트랜잭션으로 작업하기 때문에, 처음이 작업을하는 것과 같지 않습니다. 우리는 가능한 모든 블럭을 살펴 보았습니다. gs 및 오픈 소스 프로젝트를 찾을 수 있습니다. 그러나 모든 사람들에게 원활하게 작동하는 것으로 보이는 것은 내 응용 프로그램에서 무시당하는 것처럼 보입니다. 나는 우리가 어딘가에 정말 어리석은 뭔가를 놓쳤다 고 확신하지만, 우리는 지금까지 70 가지가 넘는 다른 설정을 시도해 보았습니다. 그리고 JTA를 시도하지 않을 때 다른 방법으로 작동하는 간단한 삽입을 보이지 않았습니다.

(우리가 축 1.4를 사용한다는 사실은 관련이있을 수도 있지만 그렇지 않을 수도 있지만, 우리의 응용 프로그램은 웹 서비스 호출 후에 동작을 트리거하기 때문에 알려주고 싶습니다.) 이 시점에서 우리는 구성 초자연적 인 활동을 믿기 시작하고 있습니다 ...

단서 누구?

답변

1

org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean이라는 사실 때문에 위의 구성이 작동하지 않는 것으로 나타났습니다.

내가는 JBoss 컨테이너 관리 엔티티 관리자 spring-jpa.config.xml에 대한 조회해야 JTA를하려면

<!-- lookup the container-managed JPA-EMF --> 
<!-- the JNDI name is specified in META-INF/persistence.xml --> 
<!-- SEE: https://docs.jboss.org/author/display/AS71/JPA+Reference+Guide#JPAReferenceGuide-BindingEntityManagerFactorytoJNDI --> 
<jee:jndi-lookup id="defaultPu" jndi-name="java:jboss/defaultPu" /> 

그리고 META-INF/persistence.xml에 당신은 JNDI로 엔티티 관리자 팩토리 바인딩 :

<!-- bind the EMF in JNDI --> 
<property name="jboss.entity.manager.factory.jndi.name" value="java:jboss/defaultPu" /> 

그래서, Jboss가 JPA를 부트 스트랩하게하고 그런 식으로 JTA 트랜잭션이 작동합니다!

관련 문제