cancel
Showing results for 
Search instead for 
Did you mean: 

IllegalArgumentException when invoking a service task requiring a date

cdeneux
Champ in-the-making
Champ in-the-making
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
5 REPLIES 5

trademak
Star Contributor
Star Contributor
Hi Christophe,

I think the transformation should be implemented in activiti-cxf if possible. Or indeed make sure activiti-cxf is able to handle java.util.Date

Best regards,

cdeneux
Champ in-the-making
Champ in-the-making
Hi Tijs,

I will try to improve activiti-cxf to generate java.util.Date for xsd:date/dateTime/Time instead of XMLGregorianCalendar and the submit you a pull-request.

If in my previous example, the date is defined as string in my process definition, how can I convert it into java.util.Date through the data input association ? Have you an example ? I don't find any documentation on this subject, perhaps I have not search with the right keywords.

Thanks for your help,
Regards,
Christophe

trademak
Star Contributor
Star Contributor
Hi Christophe,

Ok great, thanks in advance.
Doing a conversion directly via the data input association is not possible I think. So you would have to convert the variable in a script or service task first.

Best regards,

cdeneux
Champ in-the-making
Champ in-the-making
Hi all,

activiti-cxf was improved about date support with pull request 585.

Regards,
Christophe

jbarrez
Star Contributor
Star Contributor
Thanks. We will look at it soon and discuss it there (or merge if it's perfect)
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.