I've created a REST server method [1] and a REST client method. My goal is to communicate java class objects between two camunda systems.
So far the server is able to receive a customer class object, I created, as a JSON String from the server. Which looks like the following:
{
"name": "Jon",
"address": "Samplestr.",
"registered": true
}
But my problem is that I can't get the client to parse this string back into a customer class object.
My client code looks like the following:
---------------------------
public class JerseyClientGet implements JavaDelegate {
public void execute(DelegateExecution delegateExecution){
Client client = Client.create();
WebResource webResource = client
.resource("http://ipaddress:8080/project-name/rest/customer/get");
ClientResponse response = webResource.accept("application/json").get(ClientResponse.class);
if(response.getStatus() != 200){
throw new RuntimeException("Failed : HTTP error code: "+response.getStatus());
}
Response output = response.getEntity(String.class);
---------------------------
I tried to replace the last row with:
"Customer outputCustomer = response.getEntity(Customer.class);"
And to replace it with:
"Customer outputCustomer = response.getEntity(new GenericType<SkiOrder>(){});"
Both resulting in this error:
---------------------------
FATAL: A message body reader for Java class org.camunda.bpm.getstarted.projectname.Customer, and Java type class org.camunda.bpm.getstarted.projectname.Customer, and MIME media type application/json was not found
Jul 10, 2015 5:40:04 PM com.sun.jersey.api.client.ClientResponse getEntity
FATAL: The registered message body readers compatible with the MIME medi
a type are:
application/json ->
com.sun.jersey.json.impl.provider.entity.JSONJAXBElementProvider$App
com.sun.jersey.json.impl.provider.entity.JSONArrayProvider$App
com.sun.jersey.json.impl.provider.entity.JSONObjectProvider$App
com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$App
com.sun.jersey.json.impl.provider.entity.JSONListElementProvider$App
...(many more rows like the ones before)...
com.sun.jersey.api.client.ClientHandlerException: A message body reader for Java class org.camunda.bpm.getstarted.frogtravel.SkiOrder, and Java type class org.camunda.bpm.getstarted.frogtravel.SkiOrder, and MIME media type application/json was not found
at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.jav
a:549)
...(many more rows like the one before)...
---------------------------
And I also tried to parse the JSON String with the following code and imports (whereat I certainly put the imports on top of the class under the package row):
---------------------------
import static org.camunda.spin.Spin.*;
import static org.camunda.spin.DataFormats.*;
import org.camunda.spin.json.SpinJsonNode;
SpinJsonNode json = S(output, json());
Customer customer = json.mapTo(Customer.class)
---------------------------
This approach resulted in this error message:
---------------------------
log4j:WARN No appenders could be found for logger (org.camunda.spin).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more in
fo.
---------------------------
I tried to load some log4j dependencies in my pom:
---------------------------
<!-- SLF4J Logger -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.2</version>
</dependency>
---------------------------
And I'm searching solutions for that problem but I have problems solving it.
[2] It seems like the problem could be that the SLF4J logger gets wrong input. But since I'm not using the logger myself I dont know how to figure out whats wrong.
I would be very thankful for help, because I don't know how to proceed exactly from here on.
Best regards,
Tassilo
[1] https://groups.google.com/forum/#!topic/camunda-bpm-users/TiHwL0ANx9o
[2] http://stackoverflow.com/questions/6608775/please-initialize-the-log4j-system-properly-while-running-web-service