AnsweredAssumed Answered

JavaDelegate injecting filed

Question asked by nuthan on Nov 11, 2016
Latest reply on Nov 26, 2016 by anilmann
Hi I have a Spring bean which acts as Service delegate class. I am having trouble in injecting a filed .. Getting following error
Field definition uses unexisting field 'className' on class com.sun.proxy.$Proxy229

My delegate Class
————–

@Component("agileIntegrationDelegate")
@Transactional
public class AgileIntegrationOutBoundService implements JavaDelegate {
      
      public Expression entity;
      public Expression itemNumber;
      public Expression className;
      public Expression recipient;
      
      
      @Autowired
      @Qualifier("dataSource")
      private DataSource dataSource;
      
      
       @Override
      public void execute(DelegateExecution execution) throws Exception {
          try {
             execution.getVariables();
             String _class = (String) className.getValue(execution);
             String item = (String) itemNumber.getValue(execution);
             String to = (String) recipient.getValue(execution);
             AbstractEntity _entity = (AbstractEntity)entity.getValue(execution);
             
             /*String _class = (String) execution.getVariable("className");
             String item = (String) execution.getVariable("itemNumber");
             String to =  (String) execution.getVariable("recipient");
             AbstractEntity _entity = (AbstractEntity)execution.getVariable("entity");
             */
             switch(_class)
             {
             case "TECHNOLOGY":
                Technology tech = (Technology) _entity;
                System.out.println(tech);
                break;
             default:
                break;
             }
             System.out.println(_class + item + to);
          } catch (Exception e) {
             e.printStackTrace();
            //throw new BpmnError("BusinessExceptionOccurred");
          }
         
      }
}




My BPM xml
————

<process id="agileIntegration" name="Agile Out Bound integration" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="servicetask1" />
    <serviceTask id="servicetask1" name="Java Service to send data" activiti:delegateExpression="${agileIntegrationDelegate}">
        <extensionElements>
               <activiti:field name="className">
                  <activiti:string>${className}</activiti:string>
               </activiti:field>
               <activiti:field name="itemNumber">
                  <activiti:string>${itemNumber}</activiti:string>
               </activiti:field>
               <activiti:field name="recipient">
                  <activiti:string>${recipient}</activiti:string>
               </activiti:field>
               <activiti:field name="entity">
                     <activiti:expression>${entity}</activiti:expression>
             </activiti:field>
        </extensionElements>
    </serviceTask>
    <sequenceFlow id="flow2" sourceRef="servicetask1" targetRef="endevent1"></sequenceFlow>
   
    <endEvent id="endevent1" name="End"></endEvent>
  </process>



and I am starting workflow with

String process = "agileIntegration";
         Map<String, Object> variables = new HashMap<String, Object>();
         variables.put("itemNumber", itemNumber);
         variables.put("className", className);
         variables.put("entity", entity);
         variables.put("recipient", "nuthankumar.mallavaram@globalfoundries.com");
         //variables.put("owner", SecurityUtils.getCurrentLogin());
         //variables.put("variables", new String[] {"1234"});
         runtimeService.startProcessInstanceByKey(process, variables);



If I use direct class instead of spring bean , its getting all variables with out any problem. But My requirement is to inject bean

Outcomes