0 Replies Latest reply on Aug 8, 2009 3:43 PM by Shanthi Shanmugam

    JBPM in SEAMGen CRUD application

    Shanthi Shanmugam Newbie
      Hi ,


        I am using Seam 2.1.1 GA and Jbossepp 4.3.I have created the Seam application.
        I have used the Seam-gen reverse engineering to create the crud application
        I have configured the JBPM.I am able to create the process successfully and
        business process variables are able to reteive form the taskInstance.But when
        I try to start the task using @StartTask annotation i am not able to start the task.
        I am geting the following exception
       
        Exception during request processing:
        Caused by javax.el.ELException with message: "java.lang.IllegalStateException: begin
        method invoked from a long-running conversation, try using @Begin(join=true) on method: approve"
        org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:333)
        org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:342)
        org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
        org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
        org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
        org.jboss.seam.core.Expressions$2.invoke(Expressions.java:175)
        org.jboss.seam.navigation.Pages.callAction(Pages.java:708)
        org.jboss.seam.navigation.Pages.preRender(Pages.java:346)
        org.jboss.seam.jsf.SeamPhaseListener.preRenderPage(SeamPhaseListener.java:562)
        org.jboss.seam.jsf.SeamPhaseListener.beforeRenderResponse(SeamPhaseListener.java:473)
        org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:146)
        org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:116)

        Even if i give use @Begin(join=true) also i am getting the exception when i use @starttask or
        @BeginTask.Once i restart the server all my business context variables are also lost.
       
        Please help me to solve this problem.
       
        My Configuration files
       
        process jpdl file
       
        <process-definition
             name="Partner Approval">
          
           <start-state name="register"  end-tasks="true">
              <transition to="confirmregistration"/>
           </start-state>
          
           <task-node name="confirmregistration" >
              <task name="confirmregistration" description="svc registration confirmation">
                  <assignment pooled-actors="admin"/>
              </task>
              <transition name="approve" to="approved">
              
              </transition>
               <transition name="reject" to="rejected"/>
           </task-node>
         
           <end-state name="approved"/>
           <end-state name="rejected"/>
          
      </process-definition>
       
       
        pageflow.jpdl.cml
       
        <?xml version="1.0"?>
       
        <pageflow-definition
             xmlns="http://jboss.com/products/seam/pageflow"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation=
                 "http://jboss.com/products/seam/pageflow http://jboss.com/products/seam/pageflow-1.2.xsd"
              name="partnerapproval">
            <start-state name="start">
                <transition to="pendingtask"/>
            </start-state>
       
            <page name="pendingtask" view-id="/PartnerEdit1.xhtml"
                  >
                <redirect/>
                <transition name="cancel"   to="cancel"/>
                <transition name="register" to="register">
                    <action expression="#{partnerHome.registerPartner}" />
                </transition>
            </page>
           
            <page name="cancel" view-id="/PartnerEdit.xhtml">
                <redirect/>
                <end-conversation/>
            </page>   
       
            <page name="register" view-id="/registrationSuccess.xhtml">
                <redirect/>
                <end-conversation before-redirect="true"/>
            </page>
       
        </pageflow-definition>

       
       
        hibernet.cfg.xml
       
        <?xml version='1.0' encoding='utf-8'?>
       
        <!DOCTYPE hibernate-configuration PUBLIC
                  "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
                  "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
       
        <hibernate-configuration>
          <session-factory>
       
            <property name="show_sql">false</property>
            <property name="connection.datasource">java:/prmportalDatasource</property>
            <property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
            <property name="transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
            <property name="cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
            <property name="hbm2ddl.auto">create-drop</property>
            <!--property name="transaction.flush_before_completion">true</property-->
       
        .......
        ,,,,,
        ......
           
          </session-factory>
        </hibernate-configuration>

      persistence.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <persistence xmlns="http://java.sun.com/xml/ns/persistence"
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
                    version="1.0">
          <persistence-unit name="prmportalDatabase">
             <provider>org.hibernate.ejb.HibernatePersistence</provider>
             <jta-data-source>java:/prmportalDatasource</jta-data-source>
             <properties>
                <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
                <property name="hibernate.cache.use_query_cache" value="true"/>
                <property name="hibernate.show_sql" value="true"/>
                 <property name="hibernate.cache.provider_class"
                          value="org.hibernate.cache.HashtableCacheProvider"/>
                 <property name="jboss.entity.manager.factory.jndi.name"
                          value="java:/prmportalEntityManagerFactory" />
             </properties>
          </persistence-unit>
      </persistence>

      jboss-beans.xml

      <?xml version="1.0" encoding="UTF-8"?>

      <deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
                   xmlns="urn:jboss:bean-deployer:2.0">
            <bean name="prmportalDatasourceBootstrap" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
               <property name="driverClass">org.hsqldb.jdbcDriver</property>
               <property name="connectionURL">jdbc:hsqldb:.</property>
               <property name="userName">sa</property>
               <property name="jndiName">java:/prmportalDatasource</property>
               <property name="minSize">0</property>
               <property name="maxSize">10</property>
               <property name="blockingTimeout">1000</property>
               <property name="idleTimeout">100000</property>
               <property name="transactionManager"><inject bean="TransactionManager"/></property>
               <property name="cachedConnectionManager"><inject bean="CachedConnectionManager"/></property>
               <property name="initialContextProperties"><inject bean="InitialContextProperties"/></property>
           </bean>
            <bean name="prmportalDatasource" class="java.lang.Object">
               <constructor factoryMethod="getDatasource">
                   <factory bean="prmportalDatasourceBootstrap"/>
               </constructor>
           </bean>
      </deployment>


      jbpm.cfg.xml

      <jbpm-configuration>
        <jbpm-context>
          <service name="persistence">
             <factory>
                <bean class="org.jbpm.persistence.db.DbPersistenceServiceFactory">
                   <field name="isTransactionEnabled"><false/></field>
                </bean>
             </factory>
          </service>
          <service name="message" factory="org.jbpm.msg.db.DbMessageServiceFactory" />
          <service name="scheduler" factory="org.jbpm.scheduler.db.DbSchedulerServiceFactory" />
          <service name="tx" factory="org.jbpm.tx.TxServiceFactory" />
          <service name="logging" factory="org.jbpm.logging.db.DbLoggingServiceFactory" />
          <service name="authentication" factory="org.jbpm.security.authentication.DefaultAuthenticationServiceFactory" />
        </jbpm-context>

      </jbpm-configuration>


      package org.domain.prmportal.session;

      import java.io.Serializable;

      import javax.ejb.Remove;
      import javax.ejb.Stateful;


      import org.domain.prmportal.entity.Partner;
      import org.jboss.seam.Component;
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.Begin;
      import org.jboss.seam.annotations.Destroy;
      import org.jboss.seam.annotations.End;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Out;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.annotations.bpm.BeginTask;
      import org.jboss.seam.annotations.bpm.CreateProcess;
      import org.jboss.seam.annotations.bpm.EndTask;
      import org.jboss.seam.annotations.bpm.StartTask;
      import org.jboss.seam.bpm.BusinessProcess;


      Java files


      Entity bean

      package org.domain.prmportal.entity;

      // Generated Jul 27, 2009 4:52:34 PM by Hibernate Tools 3.2.4.GA

      import java.util.Date;
      import java.util.HashSet;
      import java.util.Set;
      import javax.persistence.Column;
      import javax.persistence.Entity;
      import javax.persistence.FetchType;
      import javax.persistence.Id;
      import javax.persistence.JoinColumn;
      import javax.persistence.ManyToOne;
      import javax.persistence.OneToMany;
      import javax.persistence.Table;
      import javax.persistence.Temporal;
      import javax.persistence.TemporalType;
      import org.hibernate.validator.Length;
      import org.hibernate.validator.NotNull;
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.Out;

      /**
      * Partner generated by hbm2java
      */
      @Entity
      @Table(name = "PARTNER", schema = "PRMDB")
      public class Partner implements java.io.Serializable {
           
           @Out(scope=ScopeType.BUSINESS_PROCESS,required=false)
           private String username;
                
           @Out(scope=ScopeType.BUSINESS_PROCESS,required=false)
           private String firstname;
           
           
           
           @Out(scope=ScopeType.BUSINESS_PROCESS,required=false)
           private String bankaddress;
           
           @Out(scope=ScopeType.BUSINESS_PROCESS,required=false)
           private String bankaddress2;
           
           @Out(scope=ScopeType.BUSINESS_PROCESS,required=false)
           private String companyiban;
           
           
           public Partner() {
           }

           public Partner(String username) {
                this.username = username;
           }
           
           @Id
           @Column(name = "USERNAME", unique = true, nullable = false, length = 40)
           @NotNull
           @Length(max = 40)
           public String getUsername() {
                return this.username;
           }

           public void setUsername(String username) {
                this.username = username;
           }

           @Column(name = "FIRSTNAME", length = 40)
           @Length(max = 40)
           public String getFirstname() {
                return this.firstname;
           }

           public void setFirstname(String firstname) {
                this.firstname = firstname;
           }
           
           
      }


      @Name("partneresb")
      public class PartnerESBAction implements Serializable{

           @Out(scope=ScopeType.BUSINESS_PROCESS,required=false)
           String username;
           @Out(scope=ScopeType.BUSINESS_PROCESS,required=false)
           String firstname;
           
           
                
            @BeginTask
            public void approve(){
                     System.out.println("Inside Approve");
                //  persist();     
                  System.out.println("persist done");
           }
           
           
           
           @EndTask
           public void reject(){
                
                System.out.println("Inside reject");
                
           }
           
      }


      @Name("partnerHome")
      public class PartnerHome extends EntityHome<Partner> {

           /**
            *
            */
           private static final long serialVersionUID = 1L;
           
           

           public void setPartnerUsername(String id) {
                setId(id);
           }

           public String getPartnerUsername() {
                return (String) getId();
           }
         
           
           @Override
           protected Partner createInstance() {
                Partner partner = new Partner();
                return partner;
           }

           public void wire() {
                getInstance();
                
           }

           public boolean isWired() {
                return true;
           }

           public Partner getDefinedInstance() {
                return isIdDefined() ? getInstance() : null;
           }

           
           
           @Out(scope=ScopeType.BUSINESS_PROCESS,required=false)
           String username;
           @Out(scope=ScopeType.BUSINESS_PROCESS,required=false)
           String firstname;
           
           @Begin(nested=true, pageflow="partnerapproval")
           public void begin(){
                System.out.println("inside begin");
           }
           @End
           @CreateProcess(definition="Partner Approval")
           public void registerPartner(){
                Partner partner=getInstance();
                //assignValues(partner);
                System.out.println(" UserName "+partner.getUsername());
                username=partner.getUsername();
                firstname=partner.getFirstname();
           }
                     
                  
      }


      Is it possibl;e to use JBPM in seam gen application? if i try to make the seam componenet
      as stateful by using the annotation @stateful annotation,i am getting teh exception as
      not able to start the seam component error.Please help me..