Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1255566

Summary: REST API returns XML when an error is thrown even if JSON is requested
Product: [Retired] JBoss BPMS Platform 6 Reporter: William Antônio <wsiqueir>
Component: Business CentralAssignee: Marco Rietveld <mrietvel>
Status: CLOSED DUPLICATE QA Contact: Lukáš Petrovický <lpetrovi>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.1.0CC: smcgowan
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-08-25 07:51:00 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description William Antônio 2015-08-21 00:45:49 UTC
Description of problem:

When trying to start a process using using the REST API and an exception is thrown, the response is a XML even if we try to request JSON.


Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. Create a simple process that has a script task that throws an exception. Here is an example of a script task content:

throw new Exception();

2. Build and deploy the project with the script task
3. Try to start it using the REST API and request for JSON:

$ curl -X POST -u 'jesuino:redhat2014!' -H 'Accept: application/json' http://localhost:8080/business-central/rest/runtime/org.kie.example:project1:1.0/process/project1.exp_proc/start

Actual results:

The response is returned as XML:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<exception>
    <status>FAILURE</status>
    <url>http://localhost:8080/business-central/rest/runtime/org.kie.example:project1:1.0/process/project1.exp_proc/start</url>
    <message>WorkflowRuntimeException thrown with message '[project1.exp_proc:57 - :2] -- null'</message>
    <stackTrace>org.kie.remote.services.rest.exception.KieRemoteRestOperationException: [project1.exp_proc:57 - :2] -- null
	at org.kie.remote.services.rest.exception.KieRemoteRestOperationException.internalS(...)
	... 76 more
</stackTrace>
</exception>

Expected results:

Since JSON was requested, it should return JSON instead XML.

Additional info:

This happens because the DescriptiveExceptionHandler returns a String representation of the error:

https://github.com/droolsjbpm/droolsjbpm-integration/blob/master/kie-remote/kie-remote-services/src/main/java/org/kie/remote/services/rest/exception/DescriptiveExceptionHandler.java#L101

https://github.com/droolsjbpm/droolsjbpm-integration/blob/master/kie-remote/kie-remote-jaxb/src/main/java/org/kie/services/client/serialization/jaxb/impl/JaxbRestRequestException.java#L80-L85


This could be solved by setting the JaxbRestRequestException itself as the response entity instead returning the String.

Comment 2 Marco Rietveld 2015-08-25 07:51:00 UTC

*** This bug has been marked as a duplicate of bug 1071846 ***

Comment 3 Marco Rietveld 2015-08-25 07:51:53 UTC
I will make sure to solve this case as well when solving 1071846. 

I've also updated the priority of 1071846 to high (from medium).