Hi,
I want to execute a rest-call in a JavaDelegate and parse the Json-Response with Spin and set some ProcessVaraibles.
The current solution to do that with a built-in connector and parsing/setting with JAvaScript is working fine, but no option any longer.
The Rest-Call is no problem and working perfectly, but since i added the dependencies for Spin the hole thing crushes at the execution with a “java.lang.ClassNotFoundException”.
I stumble around an found several solutions (adding “scope provided”), but none of them worked for me.
The process starting correct and waiting at “Wait”, but crushes at “Call Action”.
Thanks for help!
pom.xml:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-bom</artifactId>
<version>7.7.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-engine</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-engine-plugin-spin</artifactId>
<version>7.7.0</version>
<scope>provided</scope>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.camunda.spin</groupId> -->
<!-- <artifactId>camunda-spin-core</artifactId> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>org.camunda.spin</groupId> -->
<!-- <artifactId>camunda-spin-dataformat-all</artifactId> -->
<!-- <scope>provided</scope> -->
<!-- </dependency> -->
</dependencies>
JavaDelegate:
public void execute(DelegateExecution execution) throws Exception {
String root = "https://jsonplaceholder.typicode.com";
String url = root + "/posts/1";
String payload = (String) execution.getVariable("actioncall");
Client client = Client.create();
WebResource webResource = client
.resource(url);
ClientResponse response = webResource.accept("application/json")
.get(ClientResponse.class);
String resp = response.getEntity(String.class);
execution.setVariable("response", resp);
SpinJsonNode json = JSON(resp);
for(String fieldname : json.fieldNames())
{
Object value = json.prop(fieldname).value();
execution.setVariable(fieldname, value);
}
}
TestJavascriptRestCall.bpmn (4.8 KB)