3 Replies Latest reply on Feb 22, 2008 12:54 AM by youngm

    Tranaction issue using SEAM SPRING Integration

    gururajpai

      Currently we are doing POC using SEAM, SPRING, JPA webapplication on Tomcat server(Without JBOSS)




      While integrating SPRING with SEAM, event is not getting raised using raiseTransactionSuccessEvent(), but we could acheive it by using raiseEvent().  Any idea what could be the issue.




      Following code snippets


      1) applicationContext.xml


      ------------------------------


      
      <beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop"
      
       xmlns:util="http://www.springframework.org/schema/util" xmlns:seam="http://jboss.com/products/seam/spring-seam"
      
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
      
       xmlns:jee="http://www.springframework.org/schema/jee"
      
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
      
                                 http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
      
                                 http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd
      
                                 http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
      
                                 http://jboss.com/products/seam/spring-seam http://jboss.com/products/seam/spring-seam-2.0.xsd
      
                                 http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"
      
       default-lazy-init="false">
      
       <!-- This  uses resource local JpaTransactionManager.  You could just as easily use a JtaTransactionManager -->
      
       <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
      
        <!-- Be sure to specify the SeamManagedEntityManagerFactory since that will manage the EM that will be
      
        beginning and ending transactions.-->
      
           <property name="entityManagerFactory" ref="seamEntityManagerFactory"/>
      
       </bean>
      
       <tx:annotation-driven proxy-target-class="true" />
      
       <!--  using PersistenceAnnotationBeanPostProcessor for persistence -->
      
       <bean id="orderService" class="com.service.impl.OrderServiceImpl" scope="prototype">
      
          <seam:component/>
      
          </bean>
      
          <bean id="userService" class="com.service.impl.UserServiceImpl" scope="prototype">
      
          <seam:component/>
      
          </bean>
      
       <seam:configure-scopes />
      
       <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor">
      
        <!-- Because we have multiple EntityManagerFactories in this applicaitonContext identify the
      
        SeamManagedEntityManagerFactory as the default -->
      
        <property name="defaultPersistenceUnitName" value="conversationScoped"/>
      
       </bean>
      
       <!-- EMF that wraps a Seam Managed EM instance for use in Spring -->
      
       <bean id="seamEntityManagerFactory" class="org.jboss.seam.ioc.spring.SeamManagedEntityManagerFactoryBean">
      
        <!-- The Seam managed-persistence-context component name. -->
      
        <property name="persistenceContextName" value="em" />
      
        <!-- Optionally provide a unit name.  If not specified the default would be the persistenceContextName -->
      
        <property name="persistenceUnitName" value="conversationScoped"/>
      
       </bean>
      
      </beans>
      
      


      2)Components.xml


      
      <components xmlns="http://jboss.com/products/seam/components" 
      
                  xmlns:core="http://jboss.com/products/seam/core"
      
                  xmlns:persistence="http://jboss.com/products/seam/persistence"
      
                  xmlns:spring="http://jboss.com/products/seam/spring"
      
                  xmlns:transaction="http://jboss.com/products/seam/transaction"
      
                  xmlns:security="http://jboss.com/products/seam/security"
      
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      
                  xsi:schemaLocation="http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd 
      
                                      http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd
      
                                      http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd
      
                                      http://jboss.com/products/seam/spring http://jboss.com/products/seam/spring-2.0.xsd
      
                             http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.0.xsd 
      
                                      http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd">
      
      
            <core:init debug="true"/>   
      
          <core:manager conversation-timeout="120000" 
      
                        concurrent-request-timeout="500"
      
                        conversation-id-parameter="cid"/>
      
          <persistence:entity-manager-factory name="bookingDatabase"/>
      
          <persistence:managed-persistence-context name="em"
      
                                     auto-create="true" 
      
                          entity-manager-factory="#{bookingDatabase}"/>
      
           <spring:context-loader />
      
           <!-- Sample Hibernate Session -->
      
          <persistence:managed-hibernate-session name="hibernateSession" auto-create="true" session-factory="#{sessionFactory}"/>
      
          <spring:spring-transaction platform-transaction-manager="#{transactionManager}"/>
      
          <security:identity authenticate-method="#{authenticator.authenticate}"/>  
      
        </components>
      
      


      booking database is oracle .


      3) the method raises event


      
      @End
      
       public void confirm() {
      
        orderService.createOrder(order);
      
        facesMessages
      
        .add("Thank you, #{user.cusLblLastName} #{user.cusLblFirstName} , your confimation number for #{stock.stkLblName} is #{order.ordPidOrderDetail}");
      
        log.info("New order: #{order.ordPidOrderDetail} for #{user.username}");
      
        events.raiseTransactionSuccessEvent("orderConfirmed");
      
       }
      
      


      ----------------------------------------------------------------------------------------------------------


      4) The method uses Observer annotation



      
       @Factory
      
         @Observer("orderConfirmed")
      
         @Transactional
      
         public void getOrders()
      
         {
      
            orders = orderService.getOrdersByUsername(user.getUsername());
      
         }
      
      
      



      Is there any setting is missed out .


      Thanks in advance
      Guru