0 Replies Latest reply on Mar 21, 2007 10:23 PM by Sergio Sanchez

    How to use jBPM built-in components?

    Sergio Sanchez Newbie

      I want to use Seam built-in components to deploy a xml file with a process definition. My code:

      @Name("workflowHome")
      @Transactional
      public class WorkflowHome extends EntityHome<Workflow>
      {
      
       @RequestParameter
       Long workflowId;
      
       private Workflow workflow;
       @In(required=false)
       Discipline discipline;
       @In(value="org.jboss.seam.core.jbpm")
       private Jbpm jbpm;
      
       @In(value="org.jboss.seam.core.jbpmContext",create=true)
       private JbpmContext context;
      
      
       @Override
       public Object getId()
       {
       if (workflowId==null)
       {
       return super.getId();
       }
       else
       {
       return workflowId;
       }
       }
      
       @Override
       public void create() {
       super.create();
      
       }
      
       @Factory("workflow")
       public Workflow initWorkflow(){
       return getInstance();
       }
      
       protected Workflow createInstance() {
       workflow = new Workflow();
       discipline.getWorkflows().add(workflow);
       return workflow;
       }
      
       public void deployProcess(){
       String file = new String(workflow.getWorkflowFile());
      
       try{
       context.deployProcessDefinition(jbpm.getProcessDefinitionFromXml(file));
       }finally{
       context.close();
       }
       }
      
      }
      


      What am I missing? Because I'm getting the following exceptions:
      03:08:44,372 ERROR [PhaseListenerManager] Exception in PhaseListener RENDER_RESPONSE(6) beforePhase.
      java.lang.IllegalStateException: Could not commit transaction
       at org.jboss.seam.jsf.AbstractSeamPhaseListener.commitOrRollback(AbstractSeamPhaseListener.java:306)
       at org.jboss.seam.jsf.TransactionalSeamPhaseListener.handleTransactionsAfterPageActions(TransactionalSeamPhaseListener.java:47)
       at org.jboss.seam.jsf.AbstractSeamPhaseListener.enterPage(AbstractSeamPhaseListener.java:258)
       at org.jboss.seam.jsf.AbstractSeamPhaseListener.beforeRender(AbstractSeamPhaseListener.java:192)
       at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:53)
       at org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListenersBefore(PhaseListenerManager.java:70)
       at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:373)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamMultipartFilter.doFilter(SeamMultipartFilter.java:35)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:32)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:46)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=desktop/102, BranchQual=, localId=102] status=STATUS_NO_TRANSACTION; - nested throwable: (org.hibernate.SessionException: Session is closed!)
       at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:372)
       at org.jboss.tm.TxManager.commit(TxManager.java:240)
       at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:140)
       at org.jboss.seam.jsf.AbstractSeamPhaseListener.commitOrRollback(AbstractSeamPhaseListener.java:295)
       ... 36 more
      Caused by: org.hibernate.SessionException: Session is closed!
       at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:49)
       at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:993)
       at org.jboss.seam.core.ManagedJbpmContext.beforeCompletion(ManagedJbpmContext.java:95)
       at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1491)
       at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1110)
       at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:324)
       ... 39 more
      


      Everything works fine if I deploy the process definition if I use this code instead:
       String name=null;
       JbpmContext jbpmContext=null;
       String file = new String(workflow.getWorkflowFile());
       ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(file);
      
       JbpmConfiguration jbpmConf = JbpmConfiguration.getInstance();
       jbpmContext = jbpmConf.createJbpmContext();
      
       try {
       jbpmContext.deployProcessDefinition(processDefinition);
       } finally {
       jbpmContext.close();
       }
      


      I'd rather use the Seam components. I've been loonking for some similar problems in the forum and I don't know if it is the same problem as in http://jira.jboss.org/jira/browse/JBSEAM-798. If only anyone could help me!