Hello,

Dans la doc de spring il cite notement ceci pour l'utilisation de JTA en mode managé par le container

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
If we use JTA in a J2EE container, as in the 'dataAccessContext-jta.xml'  file from the same sample application, we use a container DataSource, obtained via JNDI, in conjunction with Spring's JtaTransactionManager. The JtaTransactionManager doesn't need to know about the DataSource, or any other specific resources, as it will use the container's global transaction management infrastructure.
 
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="
       <a href="http://www.springframework.org/schema/beans" target="_blank">http://www.springframework.org/schema/beans</a> <a href="http://www.springframework.org/schema/beans/spring-beans-2.0.xsd" target="_blank">http://www.springframework.org/schem...-beans-2.0.xsd</a>
       <a href="http://www.springframework.org/schema/jee" target="_blank">http://www.springframework.org/schema/jee</a> http://www.springframework.org/schema/jee/spring-jee-2.0.xsd">
 
  <jee:jndi-lookup id="dataSource" jndi-name="jdbc/jpetstore"/> 
 
  <bean id="txManager" class="org.springframework.transaction.jta.JtaTransactionManager" />
 
  <!-- other <bean/> definitions here -->
 
</beans>
cette simple définition nous permet-elle donc de ne rien définir d'autres (sans tx-annotation-driven) et d'utiliser simplement l'annotation @Transactional ?

EDIT

Un peu plus loin dans la doc je lis ceci :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 
!-- from the file 'context.xml' -->
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
 
  <!-- this is the service object that we want to make transactional -->
  <bean id="fooService" class="x.y.service.DefaultFooService"/>
 
  <!-- enable the configuration of transactional behavior based on annotations -->
  <tx:annotation-driven transaction-manager="txManager"/>
 
  <!-- a PlatformTransactionManager is still required -->
  <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <!-- (this dependency is defined somewhere else) -->
    <property name="dataSource" ref="dataSource"/>
  </bean>
 
  <!-- other <bean/> definitions here -->
 
</beans>
Peut on combiner la datasource utilisé ici "dataSource" avec la datasource JNDI utilisé plus haut ?

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
<jee:jndi-lookup id="dataSource" jndi-name="jdbc/jpetstore"/>