Announcement Announcement Module
Collapse
No announcement yet.
TransactionRequiredException-WebApp using JPA and Spring's Transaction Management Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • TransactionRequiredException-WebApp using JPA and Spring's Transaction Management

    I have deployed my web app in Tomcat container.Below is my app context,

    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerE ntityManagerFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="jpaVendorAdapter">
    <bean class="org.springframework.orm.jpa.vendor.OpenJpaV endorAdapter">
    <property name="showSql" value="false"/>
    <property name="generateDdl" value="true"/>
    <property name="databasePlatform" value="org.apache.openjpa.jdbc.sql.OracleDictionar y"/>
    </bean>
    </property>
    <property name="jpaPropertyMap">
    <map>
    <entry key="openjpa.jdbc.DBDictionary" value="org.apache.openjpa.jdbc.sql.OracleDictionar y"/>
    <entry key="openjpa.Log" value="DefaultLevel=WARN, Runtime=TRACE, SQL=TRACE"/>
    </map>
    </property>
    <property name="loadTimeWeaver">
    <bean class="org.springframework.instrument.classloading .SimpleLoadTimeWeaver"/>
    </property>
    </bean>

    <bean id="jpaTemplate" class="org.springframework.orm.jpa.JpaTemplate">
    <property name="entityManagerFactory" ref="entityManagerFactory"/>
    </bean>

    <bean name="transactionManager" class="org.springframework.orm.jpa.JpaTransactionM anager">
    <property name="entityManagerFactory" ref="entityManagerFactory" />
    <property name="dataSource" ref="dataSource"/>
    </bean>

    <tx:annotation-driven />

    I am using the OpenEntityManagerinView filter as below in my web.xml,
    <filter>
    <filter-name>JpaFilter</filter-name>
    <filter-class>org.springframework.orm.jpa.support.OpenEnti tyManagerInViewFilter</filter-class>
    </filter>

    <filter-mapping>
    <filter-name>JpaFilter</filter-name>
    <url-pattern>*.do</url-pattern>
    </filter-mapping>
    All my service implementation methods are marked @Transactional.

    I get a TransactionRequiredException when calling entityManager.lock(entity); method
    I am able to successfully merge() entities and my persistence context type is the default "Transaction..."
    When i debug, entitymanager.getTransaction() throws a IllegalStateException and entityManager.getTransactionalObjects() returns an empty collection.
    Is the Transaction never started ?
    How do check this?

    Any help will be greatly appreciated.
Working...
X