Results 1 to 2 of 2

Thread: Calling DAOs from a session bean, transaction problem

  1. #1
    Join Date
    Aug 2004
    Location
    Warsaw, Poland
    Posts
    3

    Default Calling DAOs from a session bean, transaction problem

    Hi,

    I have a service class (POJO) that uses DAOs to access database.
    Here is the Spring config:

    Code:
    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName"><value>java&#58;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>
    And it perfectly works when accessed from a web client.
    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.
    Code:
    <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>
    2.
    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>
    3.
    Code:
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource"><ref local="dataSource"/></property>
    </bean>
    And the service definition is then:

    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 option 1 or 2 then it complaints that java:comp/UserTransaction cannot be found in JNDI.

    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

  2. #2
    Join Date
    Aug 2004
    Location
    Warsaw, Poland
    Posts
    3

    Default The problem is solved

    My mistake.
    One of the rewritten methods called itself recursively ...
    The problem is solved.

    But it still does not answer why I am unable to get the transaction manager.
    It simply says that java:/comp/UserService is not bound in JNDI, no matter if I configure it the 1st or 2nd way.

    Now it simply works without transaction manager configured on the spring side.

Similar Threads

  1. Unit testing with JOTM and JtaTransactionManager
    By lalle in forum Architecture
    Replies: 1
    Last Post: Oct 15th, 2005, 09:05 AM
  2. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. could not satisfy dependencies
    By springuser in forum Container
    Replies: 4
    Last Post: Apr 26th, 2005, 01:15 PM
  5. Replies: 1
    Last Post: Apr 25th, 2005, 07:37 PM

Posting Permissions

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