i have a great problem with Camunda.
I have tried to write inside this forum but without answer.
I want explain my problem:
I use camunda widfly 10 and i use Eclipse eon with Maven. The bpmn are on the same project and used the same ProcessEngine. My dream is comunicate among two process.
I have used this tutorial:
I have in the same maven project this two web service:
package org.camunda.webservice.ame;
import java.util.ArrayList;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import org.camunda.bpm.engine.TaskService;
import org.camunda.bpm.engine.task.Task;
import org.camunda.bpm.engine.ProcessEngine;
/*
* This is a very simple JAX-WS SOAP web service that create a new
* process instance in the Camunda engine. The WS accepts a string
* parameter that is used to initialize a "name" process variable.
*/
@WebService
public class RicevutaRichiestaAcquirente {
@Resource(mappedName = "java:global/camunda-bpm-platform/process-
engine/default")
private ProcessEngine processEngine;
@Inject
private TaskService taskService;
public static final String CALLBACK_URL = "callbackURL";
public static final String CALLBACK_CORRELATION_ID = "callbackCorrelationId";
public static final String PAYLOAD = "payload";
private final static Logger LOGGER = Logger.getLogger(RicevutaRichiestaAcquirente.class.getName());
// IO METTO A DISPOSIZIONE QUESTO WEB SERVICE ALL'ACQUIRENTE PER FARMI CHIAMARE
// prende i seguenti parametri:
// - il processo da avviare
// - un URL da richiamare indietro quando il processo è completato
// - Un ID di correlazione per identificare l'istanza del processo da richiamare
// - payload
public void invokeProcess(String processDefinitionKey, String callbackUrl, String correlationId, @WebParam(name="richiesta") String payload) {
LOGGER.info("l'ID del processo chiamante - lato web service - (acquirente) e: " + correlationId);
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("callbackURL", callbackUrl);
variables.put("callbackCorrelationId", correlationId);
variables.put("richiesta", payload); // in questo caso sarà il nostro valore del form "richiesta"
processEngine.getRuntimeService().startProcessInstanceByKey(processDefinitionKey, variables);
}
// TaskDto
public List<String> getTaskList(List<String> correlationIds) {
ArrayList<String> tasks = new ArrayList<String>();
// Better than the loop would be to introduce an own query doing this in one SQL, see
// https://app.camunda.com/confluence/display/foxUserGuide/Performance+Tuning+with+custom+Queries
for (String id : correlationIds) {
List<Task> tasksForCorrelationId = taskService.createTaskQuery().processVariableValueEquals(CALLBACK_CORRELATION_ID, id).list();
for (Task task : tasksForCorrelationId) {
tasks.add(task.getName());
//new TaskDto(task.getName(), task.getDescription(), task.getAssignee(), task.getId(), task.getProcessInstanceId(), task.getExecutionId(), task.getProcessDefinitionId()));
}
}
return tasks;
}
}
package org.camunda.webservice.acquirente;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
import javax.xml.ws.handler.soap.SOAPMessageContext
import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.runtime.EventSubscription;
import org.camunda.bpm.engine.runtime.Execution;
import org.camunda.bpm.engine.runtime.ProcessInstance;
@WebService
public class RispondiAdAcquirente {
@Resource(mappedName = "java:global/camunda-bpm-platform/process-
engine/default")
//private ProcessEngine processEngine;*/
@Inject
private RuntimeService runtimeService;
public static final String PAYLOAD_RECEIVED_FROM_CALLBACK =
"payloadReceivedFromCallback";
private final static Logger LOGGER =
Logger.getLogger(RispondiAdAcquirente.class.getName());
// questa cosa parte quando viene ricevuta la richiesta da parte
dell'acquirente. Corrisponde ad un throw message start event
// QUESTO E' IL WEB SERVICE DI ACQUIRENTE. LO ESPONGO AD ACQUIRENTE
// prende tre parametri:
// il processo che è stato chiamato e quindi che è stato terminato,
// il CorrelationID che è stato assegnato al suddetto processo
// il payload che nel nostro caso sarà il valore di review.
@WebMethod
public void invokeProcessCallback(String calledProcess, String
correlationId, String payload) throws SOAPException {
LOGGER.info("processoChiamato " + calledProcess);
LOGGER.info("correlationID " + correlationId);
LOGGER.info("payload " + payload);
LOGGER.info("non mi piace quell execution " + payload);
Execution execution = runtimeService
.createExecutionQuery()
.variableValueEquals(calledProcess, correlationId) //
seleziona il processo che è stato completato con il relativo ID
.singleResult();
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("risposta-richiesta", payload); // payload che sarà
rispedito al mittente
runtimeService.signal(execution.getId(), variables);
}
@WebMethod
public void prova2(@WebParam(name="processoDaIniziare") String
processoDaIniziare,
@WebParam(name="id") String IDdelProcesso,
@WebParam(name="messageName") String messageName
){
ProcessInstance pi = runtimeService.startProcessInstanceByKey(processoDaIniziare);
EventSubscription subscription =
runtimeService.createEventSubscriptionQuery()
.processInstanceId(pi.getId()).eventType("message").singleResult();
runtimeService.messageEventReceived(messageName, IDdelProcesso);
}
@WebMethod
public void prova3(@WebParam(name="processo") String processo,
@WebParam(name="id") String id){
ProcessInstance pi = runtimeService.startProcessInstanceByKey(processo);
// in realtà è acquirente
Execution execution = runtimeService.createExecutionQuery()
.processInstanceId(pi.getId()).activityId("risp-acme-
id").singleResult();
//runtimeService.signal(execution.getId());
runtimeService.signal(id);
}
}
When i deploy this webservice i obtain this wsdl:
1-
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://acquirente.webservice.camunda.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="RispondiAdAcquirenteService" targetNamespace="http://acquirente.webservice.camunda.org/">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://acquirente.webservice.camunda.org/" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://acquirente.webservice.camunda.org/">
<xs:element name="invokeProcessCallback" type="tns:invokeProcessCallback"/>
<xs:element name="invokeProcessCallbackResponse" type="tns:invokeProcessCallbackResponse"/>
<xs:element name="rispondiAdAcquirente" type="tns:rispondiAdAcquirente"/>
<xs:element name="rispondiAdAcquirenteResponse" type="tns:rispondiAdAcquirenteResponse"/>
<xs:complexType name="invokeProcessCallback">
<xs:sequence>
<xs:element minOccurs="0" name="arg0" type="xs:string"/>
<xs:element minOccurs="0" name="arg1" type="xs:string"/>
<xs:element minOccurs="0" name="arg2" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="invokeProcessCallbackResponse">
<xs:sequence/>
</xs:complexType>
<xs:complexType name="rispondiAdAcquirente">
<xs:sequence>
<xs:element minOccurs="0" name="richiesta" type="xs:string"/>
<xs:element minOccurs="0" name="EXECUTION_ID" type="xs:string"/>
<xs:element minOccurs="0" name="CHIAVE" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="rispondiAdAcquirenteResponse">
<xs:sequence/>
</xs:complexType>
<xs:element name="SOAPException" type="tns:SOAPException"/>
<xs:complexType name="SOAPException">
<xs:sequence>
<xs:element minOccurs="0" name="message" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="rispondiAdAcquirente">
<wsdl:part element="tns:rispondiAdAcquirente" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="SOAPException">
<wsdl:part element="tns:SOAPException" name="SOAPException"></wsdl:part>
</wsdl:message>
<wsdl:message name="invokeProcessCallbackResponse">
<wsdl:part element="tns:invokeProcessCallbackResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="rispondiAdAcquirenteResponse">
<wsdl:part element="tns:rispondiAdAcquirenteResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="invokeProcessCallback">
<wsdl:part element="tns:invokeProcessCallback" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:portType name="RispondiAdAcquirente">
<wsdl:operation name="invokeProcessCallback">
<wsdl:input message="tns:invokeProcessCallback" name="invokeProcessCallback"></wsdl:input>
<wsdl:output message="tns:invokeProcessCallbackResponse" name="invokeProcessCallbackResponse"></wsdl:output>
<wsdl:fault message="tns:SOAPException" name="SOAPException"></wsdl:fault>
</wsdl:operation>
<wsdl:operation name="rispondiAdAcquirente">
<wsdl:input message="tns:rispondiAdAcquirente" name="rispondiAdAcquirente"></wsdl:input>
<wsdl:output message="tns:rispondiAdAcquirenteResponse" name="rispondiAdAcquirenteResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="RispondiAdAcquirenteServiceSoapBinding" type="tns:RispondiAdAcquirente">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="invokeProcessCallback">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="invokeProcessCallback">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="invokeProcessCallbackResponse">
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="SOAPException">
<soap:fault name="SOAPException" use="literal"/>
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="rispondiAdAcquirente">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="rispondiAdAcquirente">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="rispondiAdAcquirenteResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="RispondiAdAcquirenteService">
<wsdl:port binding="tns:RispondiAdAcquirenteServiceSoapBinding" name="RispondiAdAcquirentePort">
<soap:address location="http://localhost:8080/soseng/RispondiAdAcquirente"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
the second wsdl is:
2-
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://ame.webservice.camunda.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="RicevutaRichiestaAcquirenteService" targetNamespace="http://ame.webservice.camunda.org/">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://ame.webservice.camunda.org/" elementFormDefault="unqualified" targetNamespace="http://ame.webservice.camunda.org/" version="1.0">
<xs:element name="getTaskList" type="tns:getTaskList"/>
<xs:element name="getTaskListResponse" type="tns:getTaskListResponse"/>
<xs:element name="invokeProcess" type="tns:invokeProcess"/>
<xs:element name="invokeProcessResponse" type="tns:invokeProcessResponse"/>
<xs:element name="start" type="tns:start"/>
<xs:element name="startResponse" type="tns:startResponse"/>
<xs:complexType name="invokeProcess">
<xs:sequence>
<xs:element minOccurs="0" name="arg0" type="xs:string"/>
<xs:element minOccurs="0" name="arg1" type="xs:string"/>
<xs:element minOccurs="0" name="arg2" type="xs:string"/>
<xs:element minOccurs="0" name="richiesta" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="invokeProcessResponse">
<xs:sequence/>
</xs:complexType>
<xs:complexType name="getTaskList">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="arg0" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="getTaskListResponse">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="return" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="start">
<xs:sequence>
<xs:element minOccurs="0" name="richiesta" type="xs:string"/>
<xs:element minOccurs="0" name="arg1" type="xs:string"/>
<xs:element minOccurs="0" name="arg2" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="startResponse">
<xs:sequence/>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="invokeProcessResponse">
<wsdl:part element="tns:invokeProcessResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="invokeProcess">
<wsdl:part element="tns:invokeProcess" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="getTaskList">
<wsdl:part element="tns:getTaskList" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="getTaskListResponse">
<wsdl:part element="tns:getTaskListResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="start">
<wsdl:part element="tns:start" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="startResponse">
<wsdl:part element="tns:startResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:portType name="RicevutaRichiestaAcquirente">
<wsdl:operation name="invokeProcess">
<wsdl:input message="tns:invokeProcess" name="invokeProcess"></wsdl:input>
<wsdl:output message="tns:invokeProcessResponse" name="invokeProcessResponse"></wsdl:output>
</wsdl:operation>
<wsdl:operation name="getTaskList">
<wsdl:input message="tns:getTaskList" name="getTaskList"></wsdl:input>
<wsdl:output message="tns:getTaskListResponse" name="getTaskListResponse"></wsdl:output>
</wsdl:operation>
<wsdl:operation name="start">
<wsdl:input message="tns:start" name="start"></wsdl:input>
<wsdl:output message="tns:startResponse" name="startResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="RicevutaRichiestaAcquirenteServiceSoapBinding" type="tns:RicevutaRichiestaAcquirente">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="invokeProcess">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="invokeProcess">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="invokeProcessResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getTaskList">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="getTaskList">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getTaskListResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="start">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="start">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="startResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="RicevutaRichiestaAcquirenteService">
<wsdl:port binding="tns:RicevutaRichiestaAcquirenteServiceSoapBinding" name="RicevutaRichiestaAcquirentePort">
<soap:address location="http://localhost:8080/soseng/RicevutaRichiestaAcquirente"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
For testing i use SoapUI.
For the webservice RicevutaRichiestaAcquirente the result is
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:getTaskListResponse xmlns:ns2="http://ame.webservice.camunda.org/"/>
</soap:Body>
</soap:Envelope>
for the second WebService instead:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>WFLYEE0042: Failed to construct component instance</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
In particular the stack trace is:
21:11:03,802 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (default task-1) Application {http://acquirente.webservice.camunda.org/}RispondiAdAcquirenteService#{http://acquirente.webservice.camunda.org/}invokeProcessCallback has thrown exception, unwinding now: org.apache.cxf.interceptor.Fault: WFLYEE0042: Failed to construct component instance at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:162) at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.createFault(AbstractJAXWSMethodInvoker.java:267) at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:128) at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.invoke(AbstractJAXWSMethodInvoker.java:232) at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:85) at org.jboss.wsf.stack.cxf.JBossWSInvoker.invoke(JBossWSInvoker.java:145) at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source)
....
Caused by: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:163) at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:134) at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:88) at org.jboss.as.webservices.injection.WSComponent.getComponentInstance(WSComponent.java:55) at org.jboss.as.webservices.deployers.WSComponentInstanceAssociationInterceptor.processInvocation(WSComponentInstanceAssociationInterceptor.java:53) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356) at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:636) at org.jboss.invocation.AccessCheckingInterceptor.processInvocation(AccessCheckingInterceptor.java:61) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356) at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:198) at org.jboss.as.webservices.invocation.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:137) at org.jboss.wsf.stack.cxf.JBossWSInvoker.performInvocation(JBossWSInvoker.java:169) at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
Caused by: java.lang.IllegalArgumentException: Can not set org.camunda.bpm.engine.RuntimeService field org.camunda.webservice.acquirente.RispondiAdAcquirente.runtimeService to org.camunda.bpm.engine.impl.ProcessEngineImpl at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source) at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source) at sun.reflect.UnsafeObjectFieldAccessorImpl.set(Unknown Source) at java.lang.reflect.Field.set(Unknown Source) at org.jboss.as.ee.component.ManagedReferenceFieldInjectionInterceptorFactory$ManagedReferenceFieldInjectionInterceptor.processInvocation(ManagedReferenceFieldInjectionInterceptorFactory.java:106) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.as.ee.component.AroundConstructInterceptorFactory$1.processInvocation(AroundConstructInterceptorFactory.java:28) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.as.weld.injection.WeldInterceptorInjectionInterceptor.processInvocation(WeldInterceptorInjectionInterceptor.java:56) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.as.weld.injection.WeldInjectionContextInterceptor.processInvocation(WeldInjectionContextInterceptor.java:43) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356) at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:161) ... 76 more
The error is triggered when i want awake the received task “Ricevo Mex risposta” from the service task “Rispondi al cliente” with the web method invokeProcesscallback. Infact the process “acquirente-processo” starts and the service task Invio richiesta throw the other process “acme-processo” thanks to
processEngine.getRuntimeService().startProcessInstanceByKey(processDefinitionKey, variables);
}
I'm in your hands :(