Hi,
I have a service class (POJO) that uses DAOs to access database.
Here is the Spring config:
And it perfectly works when accessed from a web client.Code:<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName"><value>java:comp/env/jdbc/ApplicationDS</value></property> </bean> <bean id="projectConfigDAO" class="my.company.ProjectConfigDAOImpl" lazy-init="true"> <property name="dataSource"><ref local="dataSource"/></property> </bean> <bean id="projectConfigService" class="my.company.ProjectConfigServiceImpl" lazy-init="true"> <property name="projectConfigDAO"><ref local="projectConfigDAO"/></property> </bean>
But I have a requirement that my services must be exposed as stateless session beans. In fact the 'projectConfigService' is called from a session bean. Methods are just invoked 1:1.
Transaction attributes on config methods (session bean) are SUPPORTS.
And it also works from the webclient when I try to invoke it through the session bean.
The problem starts when the projectConfigEJB is called from another session bean, a method that has REQUIRED as the transaction attribute.
I simply have deadlock. The other method does sth in database, then calls my config bean - and hangs in this place.
My guessing would be that I should specify a transaction manager behavior in spring for it.
1.
2.Code:<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>
3.Code:<bean id="WSTransactionFactory" class="org.springframework.transaction.jta.WebSphereTransactionManagerFactoryBean"/> <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"> <property name="transactionManager"><ref local="WSTransactionFactory"/></property> </bean>
And the service definition is then:Code:<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource"><ref local="dataSource"/></property> </bean>
When I tried option 1 or 2 then it complaints that java:comp/UserTransaction cannot be found in JNDI.Code:<bean id="projectConfigService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager"><ref local="transactionManager"/></property> <property name="target"><ref bean="projectConfigServiceTarget"/></property> <!-- renamed service defined above --> <property name="transactionAttributes"> <props> <prop key="*">PROPAGATION_REQUIRED</prop> </props> </property> </bean>
When I tried 3 then it complaints about the manager trying to work with dataSource commit options directly, which is not allowed.
It worked before switching to Spring, then I just rewrote 1 DAO, I added the POJO service bean that works on it, and simply redirected calls from the session bean to the POJO service.
Any hints how I should configure it?
Is it transaction related problem? probably ...
Can I invoke such services from inside a session bean?
I run it in WSAD 5.1, DB2
Darek


Reply With Quote