Adding multiple last resources is disallowed

Posted on

When i am doing multiple transaction annotation in the single delegated method and all delgated method are annotated with the @transaction of spring on single datasource its causing the issue.

<?xml version="1.0" encoding="UTF-8"?>

<tx:jta-transaction-manager/>
<context:annotation-config/>

<jee:jndi-lookup id="taproReadDataSource" jndi-name="java:jboss/datasources/jdbc/taproRODS" lookup-on-startup="true"
                 proxy-interface="javax.sql.DataSource"/>
<jee:jndi-lookup id="taproWriteDataSource" jndi-name="java:jboss/datasources/jdbc/taproRWDS" lookup-on-startup="true"
                 proxy-interface="javax.sql.DataSource"/>



<bean id="dataSource"  primary="true" class="com.tapro.taqframework.persistence.datasources.DatasourceRouter" lazy-init="true">
    <property name="targetDataSources">
        <map>
            <entry key="RODS" value-ref="taproReadDataSource"/>
            <entry key="RWDS" value-ref="taproWriteDataSource"/>
        </map>
    </property>
    <property name="defaultTargetDataSource" ref="taproReadDataSource"/>
</bean>
<alias name="dataSource" alias="defaultJDBCDataSource"/>





<bean id="defaultEntityManagerFactory" primary="true"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
      parent="abstractEntityManagerFactory" lazy-init="true">
    <property name="dataSource" ref="dataSource"/>
    <property name="persistenceUnitName" value="oracle_pu"/>
</bean>

<bean id="entityManagerFactory"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
      parent="abstractEntityManagerFactory" lazy-init="true">
    <property name="dataSource" ref="dataSource"/>
    <property name="persistenceUnitName" value="oracle_pu"/>
</bean>

true
true
org.hibernate.transaction.JBossTransactionManagerLookup
false
true
jta
auto
jta
JBossAS

</util:properties>

<!-- Add JPA support -->
<!-- <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="persistenceXmlLocation" value="classpath*:META-INF/spring/persistence-spring.xml"/>
    <property name="dataSource" ref="dataSource"/> <property name="jpaVendorAdapter">
    <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
    <property name="showSql" value="true"/> <property name="generateDdl" value="false"/>
    <property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect"/>
    </bean> </property> </bean> -->

<!-- Transaction manager for a single JPA EntityManagerFactory (alternative
    to JTA) -->
<!-- <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
    p:entityManagerFactory-ref="entityManagerFactory"/> -->


<!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= -->

<!--
    Activates various annotations to be detected in bean classes: Spring's
    @Required and @Autowired, as well as JSR 250's @PostConstruct,
    @PreDestroy and @Resource (if available) and JPA's @PersistenceContext
    and @PersistenceUnit (if available).
-->
<context:annotation-config/>

<!-- Instruct Spring to perform declarative transaction management automatically
    on annotated classes. for mode="aspectj"/ see SPR-6392 -->
<!-- <tx:annotation-driven transaction-manager="transactionManager" /> <tx:jta-transaction-manager/> -->

<!--
    Simply defining this bean will cause requests to owner names to be saved.
    This aspect is defined in petclinic.jar's META-INF/aop.xml file.
    Note that we can dependency inject this bean like any other bean.

<bean class="org.springframework.samples.petclinic.aspects.UsageLogAspect" p:historySize="300"/>
-->
<!--
    Post-processor to perform exception translation on @Repository classes (from native
    exceptions such as JPA PersistenceExceptions to Spring's DataAccessException hierarchy).

<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
-->