PDA

View Full Version : SLSB Participate in Spring Transaction



koalalam
Nov 11th, 2005, 11:56 PM
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

Juergen Mayrbaeurl
Nov 23rd, 2005, 01:28 AM
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?

koalalam
Dec 18th, 2005, 10:56 PM
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.Transa ctionProxyFactoryBean">
<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.SimpleRemoteStatele ssSessionProxyFactoryBean">
<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.JtaTransaction Manager">
</bean>

Transaction Proxy used by Bean "B":

<bean id="txProxyTemplate" abstract="true"
class="org.springframework.transaction.interceptor.Transa ctionProxyFactoryBean">
<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.

Juergen Mayrbaeurl
Jan 12th, 2006, 09:56 AM
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.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:/TransactionManager</value>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransaction Manager">
<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

Rod Johnson
Jan 12th, 2006, 05:41 PM
Use WebLogicJtaTransactionManager on WebLogic. It uses proprietary BEA APIs for closer integration.

jettro
Jan 13th, 2006, 12:30 AM
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.