AnsweredAssumed Answered

IllegalArgumentException when invoking a service task requiring a date

Question asked by cdeneux on Apr 24, 2015
Latest reply on May 7, 2015 by jbarrez
Hi all,

I have a process definition whose an extract is:

    <startEvent id="start" activiti:initiator="employeeName">
       <extensionElements>
            <activiti:formProperty id="startDate" name="First day of holiday (dd-MM-yyy)" type="date" datePattern="dd-MM-yyyy hh:mm" required="true" />
       </extensionElements>
    </startEvent>

     <serviceTask>
            …
         <dataInputAssociation>
            …
            <assignment>
               <from>${startDate}</from>
               <to>${dataInputOfNotifyNewVacationRequest.startDate}</to>
            </assignment>
         </dataInputAssociation>
      </serviceTask>


I start a process instance using
RuntimeService.startProcessInstanceById(id, variables)
where
variables
contains the property
startDate
initialized with a java.util.Date.

The field
startDate
of the web-service request is defined as
xsd:date
.

I get the following error when creating the web-service request:

java.lang.IllegalArgumentException: argument type mismatch
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:606)
   at org.apache.cxf.databinding.AbstractWrapperHelper.createWrapperObject(AbstractWrapperHelper.java:99)
   at org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor.handleMessage(WrapperClassOutInterceptor.java:101)
   at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
   at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:570)
   at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:479)
   at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:382)
   at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:335)
   at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:355)
   at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:341)
   at org.activiti.engine.impl.webservice.CxfWebServiceClient.send(CxfWebServiceClient.java:38)
   at org.activiti.engine.impl.webservice.WSOperation.safeSend(WSOperation.java:74)
   at org.activiti.engine.impl.webservice.WSOperation.sendFor(WSOperation.java:62)
   at org.activiti.engine.impl.bpmn.webservice.Operation.sendMessage(Operation.java:50)
   at org.activiti.engine.impl.bpmn.behavior.WebServiceActivityBehavior.execute(WebServiceActivityBehavior.java:75)
        …


The error is due to incompatible Java types: to build the web-service request, CXF expect a type </code>XMLGregorianCalendar (the default Jaxb mapping of xsd:date) but the process var type is <code>java.util.Date.

Should I do a data conversion in the
dataInputAssociation
of the service task ? How to do this conversion ?
Should
activiti-cxf
manage conversion of java.util.Date to XMLGregorianCalender ?
Should
activiti-cxf
be configured to generate java.util.Date instead of XMLGregorianCalendar ?

In my mind, I should do conversion in my
dataInputAssociation
, but I don't know how to this. Have you an example ?
Perhaps it could be interesting to update
activiti-cxf
to generate java.util.Date instead of XMLGregorianCalendar to avoid data conversion, simplifying the process definition, reducing performance overhead.

Regards,
Christophe

Outcomes