6 Replies Latest reply on Mar 12, 2009 10:31 AM by frinux

    Persistance and setActorId

    frinux

      Hi,

      I'm trying to assign one people to one task in my Workflow. I added a custom AssignmentHandler :

      public class CustomAssignmentHandler implements AssignmentHandler {
      
       private static final long serialVersionUID = 1L;
      
       public void assign(Assignable assignable, ExecutionContext executionContext) throws Exception {
      
       Demande demande = (Demande) executionContext.getVariable("demande");
      
      
       assignable.setActorId(demande.getValideur().getUsername());
       }
      
      }


      Here is the interesting part of my process definition :

      <task-node name="validation">
       <task name="validate">
       <assignment class='logica.ws.CustomAssignmentHandler' />
       </task>
       <transition to="notifier_acceptation" name="validee"></transition>
       <transition to="notifier_refus" name="refusee"></transition>
       </task-node>


      When it comes to this task, I get an exception :
      Unknown entity: org.jbpm.taskmgmt.exe.TaskInstance

      Details about the exception here :
      http://pastebin.com/m457e5848

      I found nothing when googling...

      What do you think about this ?

        • 1. Re: Persistance and setActorId
          kukeltje

          your hibernate config is wrong I guess

          • 2. Re: Persistance and setActorId
            frinux

            Here is my hibernate config file :

            <?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="connection.url">jdbc:mysql://localhost:3306/econges</property>
             <property name="connection.username">root</property>
             <property name="connection.password">unilog</property>
             <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
             <property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
            
            </session-factory>
            </hibernate-configuration>


            It's a quite simple one...

            • 3. Re: Persistance and setActorId
              frinux

              In a forum I saw that 3 elements are required for hibernate:
              - a javabean
              - a mapping file
              - a configuration file

              I wrote the last one only, because in jBPM documentation there is no trace of the others. I also saw that jBPM handle everything for the persistance, so that we just have to execute the contextInstance.setVariable().

              Am I right? What did I forget?

              • 4. Re: Persistance and setActorId
                kukeltje

                The full hibernate configuration indeed consists of multiple files (or at least multiple sections) the mapping file is in the jbpm jar. If the config file you posted is in the wrong place it cannot find the mapping files.

                • 5. Re: Persistance and setActorId
                  frinux

                  Hum the file is in the right place, I mean it is taken because it connects to the database.

                  I added the mapping files of my classes.

                  But I think the problem is somewhere else. When I'm debugging my action, I see that everything is going wrong since I step into the signal() function :

                  boolean response = false;
                  
                   //required fields, otherwise an exception is thrown...
                   if(demande == null || demande.getDemandeur().getUsername().equals("")) {
                   return false;
                   }
                  
                   // Lookup the pojo persistence context-builder that is configured above
                   JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
                   try {
                  
                  
                   ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("demande/processdefinition.xml");
                  
                  
                   //process definition deployment
                   //jbpmContext.getGraphSession().deployProcessDefinition(processDefinition);
                  
                  
                   ProcessInstance processInstance = new ProcessInstance(processDefinition);
                  
                   //creates the instance variables
                   processInstance.getContextInstance().setVariable("demande", demande);
                   processInstance.getContextInstance().setVariable("dateEmissionDemande", new Date());
                  
                   // let's go !
                   processInstance.setStart(new Date());
                   processInstance.signal();
                  
                   //we check if the current active node is the right one : validation
                   Token currentToken = processInstance.getRootToken();
                  
                   if(currentToken.getName().equals("validation"))
                   {
                   response=true;
                   }
                   else
                   {
                   response=false;
                   }
                  
                   jbpmContext.save(processInstance);
                  
                   } finally {
                   jbpmContext.close();
                   }
                  
                   return response;



                  It doesn't go further than processInstance.signal();
                  It comes directly to the finally.

                  • 6. Re: Persistance and setActorId
                    frinux

                    Sorry my last message doesn't help. I catched the exception and I came back to the first one :
                    couldn't assign id to TaskInstance(validate)

                    The problem is still there...