2 Replies Latest reply on Dec 17, 2010 8:58 AM by marcio.dantas

    Spring Integration

    marcio.dantas

      Hi,


      I'm integrating a spring application with Seam. The extended persistence context is working fine but I'm having issues with my spring annotated transactions (which worked before).


      Caused by: org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove readOnly marker from transaction definition.



      This kind of problem occurs with write transactional methods that calls other annotated methods with propagation REQUIRES_NEW and read-only true. The session's flush mode gets setted to NEVER and when the global transaction continues to execute and flushes the error happens.


      The question is: are the transactions really supposed to work as before or are there limitations?

        • 1. Re: Spring Integration
          luomo

          Hello,


          have you resolved this problem?
          I'm facing the same issue and don't have a clue how to fix it.


          Best regards


          llluomo@gmail.com

          • 2. Re: Spring Integration
            marcio.dantas

            Hi Joao,


            sorry about not seeing your question. It has been a long time since a solved this issue and I can't tell you the details. So I'll just post my components.xml and spring-config.xml:




            <?xml version="1.0" encoding="UTF-8"?>
            <components xmlns="http://jboss.com/products/seam/components"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xmlns:core="http://jboss.com/products/seam/core"
                 xmlns:mail="http://jboss.com/products/seam/mail"
                 xmlns:navigation="http://jboss.com/products/seam/navigation"
                 xmlns:persistence="http://jboss.com/products/seam/persistence"
                 xmlns:transaction="http://jboss.com/products/seam/transaction"
                 xmlns:web="http://jboss.com/products/seam/web"
                 xmlns:spring="http://jboss.com/products/seam/spring"
                 xmlns:security="http://jboss.com/products/seam/security"
                 xsi:schemaLocation="http://jboss.com/products/seam/components
                      http://jboss.com/products/seam/components-2.1.xsd
                      http://jboss.com/products/seam/core
                      http://jboss.com/products/seam/core-2.1.xsd
                      http://jboss.com/products/seam/mail
                      http://jboss.com/products/seam/mail-2.1.xsd
                      http://jboss.com/products/seam/navigation
                      http://jboss.com/products/seam/navigation-2.1.xsd
                      http://jboss.com/products/seam/persistence
                      http://jboss.com/products/seam/persistence-2.1.xsd
                      http://jboss.com/products/seam/transaction
                      http://jboss.com/products/seam/transaction-2.1.xsd
                      http://jboss.com/products/seam/web
                      http://jboss.com/products/seam/web-2.1.xsd
                      http://jboss.com/products/seam/spring
                      http://jboss.com/products/seam/spring-2.0.xsd
                      http://jboss.com/products/seam/security
                      http://jboss.com/products/seam/security-2.1.xsd">
                <!-- seam default transactions disabled. they impact the spring annotated transactions -->
                 <core:init transaction-management-enabled="false" debug="true" />
                <!-- conversation -->
                 <core:manager conversation-id-parameter="cid" 
                     conversation-timeout="1200000"
                     concurrent-request-timeout="5000"/>
                <!-- spring context initializer -->
                 <spring:context-loader config-locations="classpath:spring-config.xml"/>
                <!-- seam-spring integration for extended persistence context -->
                <persistence:managed-hibernate-session name="hibernateSession" 
                      session-factory="#{hibernateSessionFactorySpring}" auto-create="true" />
                <!-- seam-spring integration for transaction manager.
                     see seam in action, cap. 15. -->
                <spring:spring-transaction platform-transaction-manager="#{txManager}" 
                    join-transaction="false" />
            </components>
            




            ...
                 <!-- Seam-Spring Hibernate session factory integration -->
                <bean id="hibernateSessionFactory" class="org.jboss.seam.ioc.spring.SeamManagedSessionFactoryBean">
                      <property name="sessionName" value="hibernateSession"></property>
                 </bean>
            
                 <!-- Transaction Manager Configuration -->
                 <bean id="txManager" class="org.springframework.transaction.jta.JtaTransactionManager">
                     <property name="transactionManagerName" value="java:/TransactionManager"/>
                     <property name="allowCustomIsolationLevels" value="true"/>
                 </bean>
            
                 <!-- annotations to control transactions -->
                 <tx:annotation-driven transaction-manager="txManager" />
            ...