5 Replies Latest reply on Feb 23, 2006 1:05 AM by aguizar

    Task node exception!

    mdonato

      Hi all,

      Someone knows what does it means?

      [28/11/05 12:34:51:041 GMT-03:00] 2b164be2 StatefulPersi W org.hibernate.engine.StatefulPersistenceContext Narrowing proxy to class org.jbpm.graph.node.TaskNode - this operation breaks ==
      


      Here is my configuration:
      <property name="hibernate.dialect">br.com.glr.jbpm.compatibility.SQLServer7Dialect</property><!-- MS SQLServer 7 -->
      
       <property name="hibernate.connection.datasource">jdbc/dsPOPULIS</property>
       <property name="hibernate.TransactionManagerLookup">org.hibernate.transaction.WebSphereTransactionManagerLookup</property>
       <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WebSphereTransactionManagerLookup</property>
       <property name="hibernate.TransactionManagerLookupStrategy">org.hibernate.transaction.WebSphereTransactionManagerLookup</property>
      
       <property name="hibernate.TransactionStrategy">org.hibernate.transaction.CMTTransactionFactory</property>
       <property name="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</property>
      
       <property name="hibernate.connection.release_mode">after_statement</property>
       <property name="hibernate.transaction.auto_close_session">true</property>
       <property name="hibernate.transaction.flush_before_completion">true</property>
       <property name="hibernate.default_schema">POPULIS</property>
      


      My env:
      jbpm 3.0.1
      hibernate 3.1
      MSSQLServer7
      (Jboss4 & websphere5.1)

      Here is the code:
      TaskMgmtSession tms = getJbpmSession().getTaskMgmtSession();
       TaskInstance ti = tms.loadTaskInstance( taskInstanceId.longValue() );
       if( variables!=null ){
       Map variablesMap = new HashMap();
       Iterator it = variables.iterator();
       while(it.hasNext()){
       Variable variable = (Variable) it.next();
       variablesMap.put( variable.getName(), variable.getValue() );
       }
       ti.submitParameters(variablesMap);
       }
       ti.end( transitionName );
      



      thanks

        • 1. Re: Task node exception!
          mdonato

          More info:

          Task Controller:

          public void submitParameters(Map parameters, TaskInstance taskInstance) {
          
           Token token = taskInstance.getToken();
           ProcessInstance processInstance = token.getProcessInstance();
           ContextInstance contextInstance = (ContextInstance) processInstance.getInstance(ContextInstance.class);
          
           Iterator it = variableList.iterator();
           while(it.hasNext()){
           Element element = (Element) it.next();
           Variable variable = Variable.createVariable(element, contextInstance, processInstance.getRootToken() );
          
           // then do the update
           if ((variable.getWriteable().equals("S")) && (parameters.get(variable.getName()) != null)) {
           contextInstance.setVariable(variable.getName(), parameters.get(variable.getName()), token);
           }
           }
          
           }
          



          processDefinition:

          <task-node name="task1">
           <task name="resp1" swimlane="resp1" description="Autorizacao nivel 1">
           <controller config-type="bean" class="br.com.glr.jbpm.handlers.BaseControllerHandler" >
           <variableList element-type="org.dom4j.Element">
           <variable name="pes.atrnomepessoa"></variable>
           <variable name="fun.atrregistro"></variable>
           <variable name="tur.atrnometurno"></variable>
           <variable name="bat.atrcodigobatida"></variable>
           <variable name="apo.atrdataexcecao"></variable>
           <variable name="apo.atrdatamarcacaoentrada"></variable>
           <variable name="apo.atrdatamarcacaosaida"></variable>
           <variable name="apo.atracumuladohoras">
           <showWhen variable="bat.atrdiashorasquantidade" operator="eq" value="H"/>
           </variable>
           <variable name="apo.atrquantidadedesconto">
           <showWhen variable="bat.atrdiashorasquantidade" operator="neq" value="H"/>
           </variable>
           <variable name="apo.atridmotivoautorizacao" writeable="S" required="S"></variable>
           <variable name="apo.atracumuladohorasautorizado" writeable="S" required="S">
           <showWhen variable="bat.atrdiashorasquantidade" operator="eq" value="H"/>
           </variable>
           <variable name="apo.atrquantidadedescontoautorizado" writeable="S" required="S">
           <showWhen variable="bat.atrdiashorasquantidade" operator="neq" value="H"/>
           </variable>
           </variableList>
           </controller>
           <event type="task-create">
           <action class="br.com.glr.jbpm.handlers.MotivoAutorizacaoActionHandler" config-type="bean" >
           <atrIdBatida>$apo.atridbatida</atrIdBatida>
           </action>
           </event>
           </task>
           <transition name="autorizado" to="task2"></transition>
           <transition name="nao.autorizado" to="node.nao.autorizado"></transition>
           </task-node>
          


          • 2. Re: Task node exception!
            koen.aers

            This is a Hibernate message. This is because all node types are stored in the same table. They get loaded by Hibernate lazily (in fact they are not loaded, but there is a stub in the collection representing all the different nodes of the collection). When you are actually using the nodes (in this case a tasknode) the object in the collection gets replaced by an actual TaskNode instance. This operation effectively breaks the == operator.
            Nothing really to worry about ;-)

            Regards,
            Koen

            • 3. Re: Task node exception!
              mdonato

              All right!

              Thanks for answer!

              • 4. Re: Task node exception!
                christianbacher

                ok (jbpm3.1,postgresql8,java1.5,jboss4.0.3SP1),
                i have the same warning in the log file.
                but i have the problem, that
                the method

                token.getNode()

                gives me a
                org.jbpm.graph.def.Node$$EnhancerByCGLIB$$a104bdc6

                object.
                I can't cast this object to a task node (at the time i do this the node is
                for sure a task node, because it is equal to a tasknode)

                is this a bug or a feature?

                thanks and best regards,
                christian

                • 5. Re: Task node exception!
                  aguizar

                  It is a well-documented feature. See section 19.1.3, single-ended association proxies of the Hibernate reference manual for details.
                  In particular, you can make the node castable to a TaskNode this way:

                  TaskNode taskNode = hbSession.load(TaskNode.class, token.getNode().getId());

                  Note this does not result in a round trip to the database if Node proxy was already initialized and you have a second-level cache in place.