Results 1 to 6 of 6

Thread: SLSB Participate in Spring Transaction

  1. #1
    Join Date
    Sep 2005
    Location
    Hong Kong, China
    Posts
    33

    Default SLSB Participate in Spring Transaction

    Hi,

    I have a Spring bean "A" which insert some data into the database and then it calls a SLSB. The SLSB is implemented using Spring supported EJB class "AbstractStatelessSessionBean" with the business interface being another Spring bean "B". While bean "A" calls the SLSB through the Spring supported EJB class "SimpleRemoteStatelessSessionProxyFactoryBean" .

    The problem is bean "B" cannot find the data inserted by "A". The SLSB is a CMT with transaction type "Supports" and transaction propagation is set to transaction manger used by both bean "A" and "B".

    According to Spring documentation, Spring transaction could be propagated to EJB. I have read from other threads that it could be done through EJB remoting. However, I didn't know what EJB remoting is? Anyone know what configuration is missing? Thanks.

    Regards,
    Koala

  2. #2
    Join Date
    Nov 2005
    Location
    Austria
    Posts
    38

    Default

    Can you post some code (interfaces) and context definitions?
    When using declarative transactions, starting the transaction from bean "A" and handling it over to "B", it should work correctly.
    Which EJB Container do you use?

  3. #3
    Join Date
    Sep 2005
    Location
    Hong Kong, China
    Posts
    33

    Default

    I am using WebLogic Server 8.1 as J2EE server. Shown below is the Spring context definitions:

    Transaction Proxy used by Bean "A":

    <bean id="txProxyTemplate" abstract="true"
    class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager">
    <ref bean="transactionManager" />
    </property>
    <property name="transactionAttributes">
    <props>
    <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
    </props>
    </property>
    </bean>

    Spring Bean "A":

    <bean id="locationSlipManager" parent="txProxyTemplate">
    <property name="target">
    <bean
    class="LocationSlipManagerImpl">
    <property name="primeMoverJobOperationManager">
    <ref bean="primeMoverJobOperationSLSB" />
    </property>
    </bean>
    </property>
    </bean>

    SLSB for Bean "B":

    <bean id="primeMoverJobOperationSLSB" class="org.springframework.ejb.access.SimpleRemote StatelessSessionProxyFactoryBean">
    <property name="jndiName">
    <value>ejb/PrimeMoverJobOperation</value>
    </property>
    <property name="businessInterface">
    <value>PrimeMoverJobOperationManager</value>
    </property>
    </bean>

    Transaction Manager used by Bean "B":

    <bean id="transactionManager"
    class="org.springframework.transaction.jta.JtaTran sactionManager">
    </bean>

    Transaction Proxy used by Bean "B":

    <bean id="txProxyTemplate" abstract="true"
    class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager">
    <ref bean="transactionManager" />
    </property>
    <property name="transactionAttributes">
    <props>
    <prop key="*">PROPAGATION_REQUIRED</prop>
    </props>
    </property>
    </bean>

    Spring Bean "B":

    <bean id="primeMoverJobOperationManager" parent="txProxyTemplate">
    <property name="target">
    <bean id="primeMoverJobOperationManagerImpl" class="PrimeMoverJobOperationManagerImpl">
    </bean>
    </property>
    </bean>


    What's going wrong with the configuration above? Thanks.

  4. #4
    Join Date
    Nov 2005
    Location
    Austria
    Posts
    38

    Default

    I think you're Transaction Mgr setup is not complete. It should look like:

    <!-- Transaction manager that delegates to JTA (for a transactional JNDI DataSource) -->
    <bean id="containerTX" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiName">
    <value>java:/TransactionManager</value>
    </property>
    </bean>
    <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTran sactionManager">
    <property name="transactionManager">
    <ref local="containerTX"/>
    </property>
    <property name="userTransactionName">
    <value>UserTransaction</value>
    </property>
    </bean>

    The configuration from above works with JBoss. Maybe WebLogic has different JNDI locations.

    Juergen
    _________________________________
    Juergen Mayrbaeurl - Solution architect

  5. #5
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    Use WebLogicJtaTransactionManager on WebLogic. It uses proprietary BEA APIs for closer integration.
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

  6. #6
    Join Date
    Aug 2004
    Location
    The Netherlands
    Posts
    160

    Default

    Interesting is the part that you are using CMT, since with CMT it is possible that you cannot access the transaction via spring. I know that with oracle application server you cannot access the UserTransaction if you are using CMT.
    Jettro Coenradie
    http://www.gridshore.nl

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •