Announcement Announcement Module
No announcement yet.
JTA @transaction not commited Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • JTA @transaction not commited

    In My service layer i am using @transaction.From service i am calling DAO

    Service layer code:
    public class LocationImpl implements ILocation{
    	private ILocationDao locationDaoImpl;
    	public boolean addLocation(Location location) {
    		System.out.println("Ganesha in service");
    		boolean saveFlag=locationDaoImpl.addLocation(location);
    		return saveFlag;
    DAO COde:

    public class LocationDaoImpl implements ILocationDao{
    	public EntityManager entitymanager;
    	EntityManager em;*/
    	/*@Transactional*/ // commented
    	public boolean addLocation(Location location) {
    			return true;

    Business Object:
    public class Location implements Serializable{
    	private String locationName;
    	private long locationId;
    	public String getLocationName() {
    		return locationName;
    	public void setLocationName(String locationName) {
    		this.locationName = locationName;
    	public long getLocationId() {
    		return locationId;
    	public void setLocationId(long locationId) {
    		this.locationId = locationId;

    Spring Configuration:

    <tx:annotation-driven />
    <bean id="entitymanager"
    class="org.springframework.orm.jpa.LocalContainerE ntityManagerFactoryBean">
    <property name="persistenceUnitName" value="X" />
    <property name="jpaVendorAdapter">
    <bean class="org.springframework.orm.jpa.vendor.OpenJpaV endorAdapter" >
    <property name="database" value="DB2" />
    <property name="showSql" value="true" />
    <bean class=" enceAnnotationBeanPostProcessor" />
    <tx:jta-transaction-manager />

    Persistence xml:

    <persistence-unit name="X" transaction-type="JTA">
    <property name="RuntimeUnenhancedClasses" value="supported"/>



    When i run on Websphere application server,my location object is not saved.I am not getting any error.

    If i put @Transaction on DAO addLocation is getting saved.But i need to put on service layer so that i can call other DAo methods in the same transaction.

    Console stackTrace is:

    INFO [WebContainer : 2] openjpa.Runtime - Starting OpenJPA 2.1.1-SNAPSHOT
    [2/14/13 22:53:50:868 IST] 00000032
    SystemErr R 19494 TRACE [WebContainer : 2] openjpa.jdbc.SQL - <t 31882503, conn 29839727> executing stmnt 29839913 SELECT CURRENT SCHEMA FROM SYSIBM.SYSDUMMY1
    [2/14/13 22:53:50:868 IST] 00000032
    SystemErr R 19494 TRACE [WebContainer : 2] openjpa.jdbc.SQL - <t 31882503, conn 29839727> [0 ms] spent

    Please help me.

    Last edited by vaijesh; Feb 14th, 2013, 01:11 PM.

  • #2
    Problem got solved.

    I have java project and web project bundled as Ear.In java project context i have defined <tx:annotation-driven /> and in web project i have defined <context:annotation-config />.
    Actually Transaction was not active because i have defined <context:annotation-config /> and <tx:annotation-driven /> in different root context .
    After moving both in single context it got worked.The transaction have become active.