8 Replies Latest reply on May 21, 2007 7:37 AM by Ricardo Marques

    Why doesn't work?

    Ricardo Marques Novice

      Hi guys

      I have the following process:

      <process-definition
       xmlns="urn:jbpm.org:jpdl-3.1" name="sendmail">
       <start-state name="Inicio">
       <transition name="" to="Send Mail"></transition>
       </start-state>
       <end-state name="Fim"></end-state>
       <node name="Send Mail">
       <action class="test.MailMeActionHandler"></action>
       <transition name="" to="Fim"></transition>
       </node>
      </process-definition>
      


      And the following action handler:

      package pep.test;
      
      import org.jbpm.graph.def.ActionHandler;
      import org.jbpm.graph.exe.ExecutionContext;
      //import java.util.Properties;
      //import javax.mail.*;
      //import javax.mail.internet.*;
      import java.io.*;
      
      public class MailMeActionHandler implements ActionHandler {
      
       private static final long serialVersionUID = 1L;
      
       public void execute(ExecutionContext context) throws Exception {
      
      
       /* Tenta enviar o e-mail*/
      
       String host = "smtp.myserver.com";
       String from = "ricardo.marques@myserver.com";
       String to = "ricardo.marques@myserver.com";
      
       try {
       // Get system properties
       Properties props = System.getProperties();
      
       // Setup mail server
       Authenticator auth = new PopupAuthenticator();
       props.put("mail.smtp.host", host);
       props.put("mail.smtp.auth", "true");
      
       // Get session
       Session session = Session.getInstance(props, auth);
       session.setDebug(true);
       //session.setDebug(true);
      
      
      
       // Define message
       MimeMessage message = new MimeMessage(session);
      
      
       // Set the from address
       message.setFrom(new InternetAddress(from,"Ricardo Marques"));
      
       // Set the to address
       message.addRecipient(Message.RecipientType.TO,new InternetAddress(to,"Ricardo Marques"));
      
       // Set the subject
       message.setSubject("Hello JavaMail");
      
       // Set the content
       message.setText("Welcome to JavaMail");
      
       // Send message
       Transport.send(message);
       System.out.println("OK Man");
       }
       catch (Exception e) {
       e.printStackTrace();
       }
      
       context.leaveNode();
      
       }
      
       static class PopupAuthenticator extends Authenticator {
       public PasswordAuthentication getPasswordAuthentication() {
       return new PasswordAuthentication("rmarques@myserver.com", "******");
       }
       }
      
      }
      


      But just can't see the result of the execution, or any kind of error. On the process instances table, it appears a record about the execution, but nothing else.

      The mail code, detach from the jbpm enviromnent, it works, so I suppose that should work on the enviroment.

      I want to start the process and receive a e-mail.

      Please need some help..!

        • 1. Re: Why doesn't work?
          Ronald van Kuijk Master

          the action is in a place where it does not do anything. It is neither related to the node as a node implementation, nor to an event, nor to a transition, nor to a timer. Look at the testcases and examples how to do this.

          • 2. Re: Why doesn't work?
            Arjan van Bentem Novice

            And the package name in the Java code does not match the name as used in the class attribute of .

            • 3. Re: Why doesn't work?
              Arjan van Bentem Novice

              Ok, stupid not to use the preview; some < .. > I used are hidden in my previous reply.

              So:

              And the package name in the Java code does not match the name as used in the class attribute of the action element.

              • 4. Re: Why doesn't work?
                Ricardo Marques Novice

                The package name isn't a problem, my mistake and I paste the code here.

                Regarding how the process is design, i had look at the websale example, particulary to this part:

                <node name="update books">
                 <action class="org.jbpm.websale.UpdateBooks">
                 <msg>accountancy application is now informed of the payment</msg>
                 </action>
                 <transition to="salejoin" />
                 </node>
                


                • 5. Re: Why doesn't work?
                  Ricardo Marques Novice

                  I suspect that the problem has something doing with i'm using the class NewProcessInstanceCommand to start an execution, but something more must miss.

                  Do I need to signal a instance to start even i had a start node?

                  help needed!

                  • 6. Re: Why doesn't work?
                    Ronald van Kuijk Master

                    ok... sorry I was wrong... that might indeed work (I still had the old format in mind, shame on me)

                    Can you analyse the debug output and see what really happens?

                    • 7. Re: Why doesn't work?
                      Ricardo Marques Novice

                      Ok here's the log:

                      10:31:20,953 DEBUG [CommandServiceBean] getting jbpm configuration resource from the environment properties
                      10:31:21,390 DEBUG [UIComponentTag] Exited encodeEnd for client-Id: _idJsp0
                      10:31:21,390 DEBUG [CommandServiceBean] couldn't find configuration property JbpmCfgResource through JNDI
                      10:31:21,390 DEBUG [CommandServiceBean] getting default jbpm configuration resource (jbpm.cfg.xml)
                      10:31:21,390 DEBUG [CommandServiceBean] handing over the command execution to the command service
                      10:31:21,390 DEBUG [JbpmContextInfo] creating jbpm context with service factories '[tx, message, scheduler, logging, persistence, authentication]'
                      10:31:21,390 DEBUG [FacesServlet] service end
                      10:31:21,890 DEBUG [JbpmContext] creating org.jbpm.JbpmContext@37c7ee
                      10:31:21,890 DEBUG [CommandServiceBean] executing org.jbpm.command.GetTaskListCommand@26fb32
                      10:31:21,890 DEBUG [DbPersistenceServiceFactory] creating persistence service
                      10:31:21,890 DEBUG [DbPersistenceService] creating hibernate session
                      10:31:21,890 DEBUG [SessionImpl] opened session at timestamp: 4832214556221440
                      10:31:21,890 DEBUG [DbPersistenceService] beginning hibernate transaction
                      10:31:21,890 DEBUG [JDBCTransaction] begin
                      10:31:21,890 DEBUG [ConnectionManager] opening JDBC connection
                      10:31:21,890 DEBUG [DriverManagerConnectionProvider] total checked-out connections: 1
                      10:31:21,890 DEBUG [DriverManagerConnectionProvider] opening new JDBC connection
                      10:31:21,906 DEBUG [DriverManagerConnectionProvider] created connection to: jdbc:mysql://localhost:3306/workflow-server, Isolation Level: 4
                      10:31:21,906 DEBUG [JDBCTransaction] current autocommit status: false
                      10:31:21,906 DEBUG [JDBCContext] after transaction begin
                      10:31:21,937 DEBUG [QueryPlanCache] located HQL query plan in cache (
                      
                       select ti
                       from org.jbpm.taskmgmt.exe.TaskInstance as ti
                       where ti.actorId = :actorId
                       and ti.isSuspended != true
                       and ti.isOpen = true
                      
                       )
                      10:31:22,390 DEBUG [QueryPlanCache] located HQL query plan in cache (
                      
                       select ti
                       from org.jbpm.taskmgmt.exe.TaskInstance as ti
                       where ti.actorId = :actorId
                       and ti.isSuspended != true
                       and ti.isOpen = true
                      
                       )
                      10:31:22,390 DEBUG [HQLQueryPlan] find:
                      
                       select ti
                       from org.jbpm.taskmgmt.exe.TaskInstance as ti
                       where ti.actorId = :actorId
                       and ti.isSuspended != true
                       and ti.isOpen = true
                      
                      
                      10:31:22,390 DEBUG [QueryParameters] named parameters: {actorId=grover}
                      10:31:22,890 DEBUG [AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
                      10:31:22,890 DEBUG [SQL] select taskinstan0_.ID_ as ID1_27_, taskinstan0_.VERSION_ as VERSION3_27_, taskinstan0_.NAME_ as NAME4_27_, taskinstan0_.DESCRIPTION_ as DESCRIPT5_27_, taskinstan0_.ACTORID_ as ACTORID6_27_, taskinstan0_.CREATE_ as CREATE7_27_, taskinstan0_.START_ as START8_27_, taskinstan0_.END_ as END9_27_, taskinstan0_.DUEDATE_ as DUEDATE10_27_, taskinstan0_.PRIORITY_ as PRIORITY11_27_, taskinstan0_.ISCANCELLED_ as ISCANCE12_27_, taskinstan0_.ISSUSPENDED_ as ISSUSPE13_27_, taskinstan0_.ISOPEN_ as ISOPEN14_27_, taskinstan0_.ISSIGNALLING_ as ISSIGNA15_27_, taskinstan0_.ISBLOCKING_ as ISBLOCKING16_27_, taskinstan0_.TASK_ as TASK17_27_, taskinstan0_.TOKEN_ as TOKEN18_27_, taskinstan0_.PROCINST_ as PROCINST19_27_, taskinstan0_.SWIMLANINSTANCE_ as SWIMLAN20_27_, taskinstan0_.TASKMGMTINSTANCE_ as TASKMGM21_27_ from JBPM_TASKINSTANCE taskinstan0_ where taskinstan0_.ACTORID_=? and taskinstan0_.ISSUSPENDED_<>1 and taskinstan0_.ISOPEN_=1
                      10:31:23,390 DEBUG [AbstractBatcher] preparing statement
                      10:31:23,390 DEBUG [StringType] binding 'grover' to parameter: 1
                      10:31:23,390 DEBUG [AbstractBatcher] about to open ResultSet (open ResultSets: 0, globally: 0)
                      10:31:23,390 DEBUG [Loader] processing result set
                      10:31:23,390 DEBUG [Loader] done processing result set (0 rows)
                      10:31:23,390 DEBUG [AbstractBatcher] about to close ResultSet (open ResultSets: 1, globally: 1)
                      10:31:23,390 DEBUG [AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
                      10:31:23,390 DEBUG [AbstractBatcher] closing statement
                      10:31:23,890 DEBUG [Loader] total objects hydrated: 0
                      10:31:23,890 DEBUG [StatefulPersistenceContext] initializing non-lazy collections
                      10:31:23,890 DEBUG [QueryPlanCache] located HQL query plan in cache (
                      
                       select distinct ti
                       from org.jbpm.taskmgmt.exe.PooledActor pooledActor
                       join pooledActor.taskInstances ti
                       where pooledActor.actorId in ( :actorIds )
                       and ti.actorId is null
                       and ti.isSuspended != true
                       and ti.isOpen = true
                      
                       )
                      10:31:23,890 DEBUG [QueryPlanCache] located HQL query plan in cache (
                      
                       select distinct ti
                       from org.jbpm.taskmgmt.exe.PooledActor pooledActor
                       join pooledActor.taskInstances ti
                       where pooledActor.actorId in ( :actorIds )
                       and ti.actorId is null
                       and ti.isSuspended != true
                       and ti.isOpen = true
                      
                       )
                      10:31:24,390 DEBUG [HQLQueryPlan] find:
                      
                       select distinct ti
                       from org.jbpm.taskmgmt.exe.PooledActor pooledActor
                       join pooledActor.taskInstances ti
                       where pooledActor.actorId in ( :actorIds )
                       and ti.actorId is null
                       and ti.isSuspended != true
                       and ti.isOpen = true
                      
                      
                      10:31:24,390 DEBUG [QueryParameters] named parameters: {actorIds=grover}
                      10:31:24,390 DEBUG [AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
                      10:31:24,390 DEBUG [SQL] select distinct taskinstan2_.ID_ as ID1_27_, taskinstan2_.VERSION_ as VERSION3_27_, taskinstan2_.NAME_ as NAME4_27_, taskinstan2_.DESCRIPTION_ as DESCRIPT5_27_, taskinstan2_.ACTORID_ as ACTORID6_27_, taskinstan2_.CREATE_ as CREATE7_27_, taskinstan2_.START_ as START8_27_, taskinstan2_.END_ as END9_27_, taskinstan2_.DUEDATE_ as DUEDATE10_27_, taskinstan2_.PRIORITY_ as PRIORITY11_27_, taskinstan2_.ISCANCELLED_ as ISCANCE12_27_, taskinstan2_.ISSUSPENDED_ as ISSUSPE13_27_, taskinstan2_.ISOPEN_ as ISOPEN14_27_, taskinstan2_.ISSIGNALLING_ as ISSIGNA15_27_, taskinstan2_.ISBLOCKING_ as ISBLOCKING16_27_, taskinstan2_.TASK_ as TASK17_27_, taskinstan2_.TOKEN_ as TOKEN18_27_, taskinstan2_.PROCINST_ as PROCINST19_27_, taskinstan2_.SWIMLANINSTANCE_ as SWIMLAN20_27_, taskinstan2_.TASKMGMTINSTANCE_ as TASKMGM21_27_ from JBPM_POOLEDACTOR pooledacto0_ inner join JBPM_TASKACTORPOOL taskinstan1_ on pooledacto0_.ID_=taskinstan1_.POOLEDACTOR_ inner join JBPM_TASKINSTANCE taskinstan2_ on taskinstan1_.TASKINSTANCE_=taskinstan2_.ID_ where (pooledacto0_.ACTORID_ in (?)) and (taskinstan2_.ACTORID_ is null) and taskinstan2_.ISSUSPENDED_<>1 and taskinstan2_.ISOPEN_=1
                      10:31:24,890 DEBUG [AbstractBatcher] preparing statement
                      10:31:24,890 DEBUG [StringType] binding 'grover' to parameter: 1
                      10:31:24,906 DEBUG [AbstractBatcher] about to open ResultSet (open ResultSets: 0, globally: 0)
                      10:31:24,906 DEBUG [Loader] processing result set
                      10:31:24,906 DEBUG [Loader] done processing result set (0 rows)
                      10:31:24,906 DEBUG [AbstractBatcher] about to close ResultSet (open ResultSets: 1, globally: 1)
                      10:31:24,906 DEBUG [AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
                      10:31:25,390 DEBUG [AbstractBatcher] closing statement
                      10:31:25,390 DEBUG [Loader] total objects hydrated: 0
                      10:31:25,390 DEBUG [StatefulPersistenceContext] initializing non-lazy collections
                      10:31:25,390 DEBUG [JbpmContext] closing JbpmContext
                      10:31:25,390 DEBUG [Services] closing service 'persistence': org.jbpm.persistence.db.DbPersistenceService@1e775bc
                      10:31:25,390 DEBUG [DbPersistenceService] committing hibernate transaction
                      10:31:25,390 DEBUG [JDBCTransaction] commit
                      10:31:25,390 DEBUG [SessionImpl] automatically flushing session
                      10:31:25,390 DEBUG [JDBCContext] before transaction completion
                      10:31:25,890 DEBUG [SessionImpl] before transaction completion
                      10:31:25,890 DEBUG [JDBCTransaction] committed JDBC Connection
                      10:31:25,890 DEBUG [JDBCContext] after transaction completion
                      10:31:25,890 DEBUG [ConnectionManager] aggressively releasing JDBC connection
                      10:31:25,890 DEBUG [ConnectionManager] releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
                      10:31:25,890 DEBUG [DriverManagerConnectionProvider] returning connection to pool, pool size: 1
                      10:31:25,890 DEBUG [SessionImpl] after transaction completion
                      10:31:25,890 DEBUG [DbPersistenceService] closing hibernate session
                      10:31:25,890 DEBUG [SessionImpl] closing session
                      10:31:25,890 DEBUG [ConnectionManager] connection already null in cleanup : no action
                      10:31:25,890 DEBUG [Services] closing service 'tx': org.jbpm.tx.TxService@15080e5
                      10:31:25,890 DEBUG [UIComponentTag] Exited encodeChildren for client-Id: taskList
                      10:31:26,390 DEBUG [UIComponentTag] Entered encodeEnd for client-Id: taskList
                      10:31:26,390 DEBUG [UIComponentTag] Exited encodeEnd for client-Id: taskList
                      10:31:26,390 DEBUG [FacesServlet] service end
                      
                      


                      • 8. Re: Why doesn't work?
                        Ricardo Marques Novice

                        BTW, i'm trying to isolate the problem, now i've tried to execute the process from another way, this time using StartProcessInstanceCommand.

                        Using this code:

                        Properties props = System.getProperties();
                         try {
                        
                         props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
                         props.put(Context.PROVIDER_URL, "jnp://localhost:1099");
                         props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
                        
                         Context ctx = new InitialContext(props);
                        
                         Object obj = ctx.lookup("CommandService");
                        
                         CommandServiceRemoteHome remoteCommandService = (CommandServiceRemoteHome) javax.rmi.PortableRemoteObject.narrow(obj,CommandServiceRemoteHome.class);
                         CommandServiceRemote commandService = remoteCommandService.create();
                        
                         StartProcessInstanceCommand cmd = new StartProcessInstanceCommand();
                        
                         cmd.setProcessName("send mail 4");
                         cmd.setCreateStartTask(false);
                         cmd.setActorId("grover");
                        
                        
                         System.out.println("RETURNING OBJECT: " + commandService.execute(cmd).toString());
                        
                         commandService.remove();
                         ctx.close();
                        


                        I get this exception:

                        Caused by: org.jbpm.JbpmException: couldn't execute org.jbpm.command.StartProcessInstanceCommand@1d3510d
                         at pep.workflow.server.beans.command.CommandServiceBean.execute(CommandServiceBean.java:71)
                         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                         at java.lang.reflect.Method.invoke(Method.java:585)
                         at org.jboss.invocation.Invocation.performCall(Invocation.java:359)
                         at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:237)
                         at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:158)
                         at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:169)
                         at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:63)
                         at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:121)
                         at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)
                         at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
                         at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:168)
                         at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
                         ... 24 more
                        Caused by: org.jbpm.JbpmException: token 'Token(/)' can't be signalled cause it is currently not positioned in a node
                         at org.jbpm.graph.exe.Token.signal(Token.java:134)
                         at org.jbpm.graph.exe.ProcessInstance.signal(ProcessInstance.java:251)
                         at org.jbpm.command.StartProcessInstanceCommand.execute(StartProcessInstanceCommand.java:32)
                         at pep.workflow.server.beans.command.CommandServiceBean.execute(CommandServiceBean.java:67)
                         ... 38 more
                        
                        


                        The process XML is this:

                        <?xml version="1.0" encoding="UTF-8"?>
                        
                        <process-definition
                         xmlns="urn:jbpm.org:jpdl-3.1" name="sendmail">
                         <start-state name="Inicio">
                         <transition name="" to="Send Mail"></transition>
                         </start-state>
                         <end-state name="Fim"></end-state>
                         <node name="Send Mail">
                         <action class="pep.test.MailMeActionHandler"></action>
                         <transition name="" to="Fim"></transition>
                         </node>
                        </process-definition>