Results 1 to 4 of 4

Thread: @Service conflicts with @Transactional in Tomcat

Hybrid View

  1. #1
    Join Date
    Jul 2008
    Posts
    8

    Default @Service conflicts with @Transactional in Tomcat

    I have a service with methods marked as Transactional on a product that has worked for almost a year. I tried replacing the XML bean declaration with a Service annotation at the top of the class, and it seemed to work fine. Unit tests on the transactional methods work, however when I call the exact same methods within Tomcat 6.0, I get a LazyInitializationException (while iterating through a lazy collection), indicating that the session (and thus the transaction) is not being preserved. When I remove the component annotation and declare the bean in XML again, it works fine. Any ideas?

  2. #2
    Join Date
    Jul 2008
    Posts
    8

    Default

    One more thing. I tried setting the "order" attribute in my tx:annotation-driven tag to 1, 200, and 1000000, and that didn't change the behavior either.

  3. #3
    Join Date
    Jul 2008
    Posts
    1

    Default

    Do you have something like this in your spring xml config:

    Code:
     <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
            <property name="sessionFactory" ref="sessionFactory"/>
        </bean>
    
        <tx:annotation-driven transaction-manager="txManager"/>
    
        <context:annotation-config />
    
        <context:component-scan base-package="com.yourcompany.yourproject"/>

  4. #4
    Join Date
    Aug 2004
    Location
    Amsterdam, Netherlands
    Posts
    450

    Default

    Hi guys,

    I posted this as a comment to Solomon's blog post as well:

    Hi Solomon,

    I'm using @Service in combination with @Transactional all the time, but not on Tomcat, so I currently can't really figure out what's going wrong with your setup. Could you provide a bit more information in a JIRA issue (ideally a stripped-down WAR file that we can deploy showing the issue) so that we can start researching a little bit more?

    JIRA is the best place for issues like those...

    thanks,
    Alef
    Alef Arendsen
    SpringSource
    http://www.springsource.com

Tags for this Thread

Posting Permissions

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