Note that there are some explanatory texts on larger screens.

plurals
  1. POExtJs 4 File upload with RESTEasy 2.3.0.GA , Invalid JSON response
    primarykey
    data
    text
    <p>There is a lot of discussion about this topic but no real solution. </p> <p>Here is my problem if I use </p> <p>1) @Produce("application/Json") the json response show up with in &lt;pre&GT; tag</p> <p>2) if I use @Produce("application/html") or @Produce("text/html"),then resteasy breakdown and error out with JAXB exception :</p> <p>Uncaught Ext.Error: You're trying to decode an invalid JSON String: <h1>HTTP Status 500 - Could not find JAXBContextFinder for media type: text/html</h1><p><b>type</b> Status report</p><p><b>message</b> Could not find JAXBContextFinder for media type: text/html</p><p><b>description</b> The server encountered an internal error (Could not find JAXBContextFinder for media type: text/html) that prevented it from fulfilling this request.</p><h3>JBoss Web/3.0.0-CR2</h3> </p> <p>I am desperate to get some help and there is some solution that is suggested in the forms: 1) Change the content type to text/html 2) Update the ExtJs source code 3) Parse the &LT; Pre&GT; tag in from the JSON response don't want to do 2nd and 3rd but in the Ist, I want a valid JSON output. How can I do that?</p> <p>Here is is my serverice class:</p> <pre><code> @POST @Path("/bulkUpdate") @Consumes("multipart/form-data") @Produces({"application/json"}) public ExtjsJson&lt;DataException&gt; uploadFile(MultipartFormDataInput input) { Map&lt;String, List&lt;InputPart&gt;&gt; uploadForm = input.getFormDataMap(); List&lt;InputPart&gt; inputParts = uploadForm.get("uploadedFile"); List&lt;DataException&gt; list = new ArrayList&lt;DataException&gt;(); final ExtjsJson&lt;DataException&gt; returnObj = new ExtjsJson&lt;DataException&gt;(); for (InputPart inputPart : inputParts) { try { MultivaluedMap&lt;String, String&gt; header = inputPart.getHeaders(); String fileName = getFileName(header); InputStream inputStream = inputPart.getBody(InputStream.class, null); byte[] bytes = IOUtils.toByteArray(inputStream); //handle the excel file upload and return the error if the file does not have valid data some like... DataException error = new DataException("supervisor", "columnName", 1, "SheetName", "this is not a valid supervisor"); list.add(error); } catch (IOException e) { e.printStackTrace(); } } returnObj.setSuccess(true); returnObj.setResults(list); return returnObj; } </code></pre> <p>Here is my response Object DataException.java</p> <pre><code>@Data @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class DataException { //private static final long serialVersionUID = 1L; /** excel sheet name */ private String sheetName; /** row number of the excel sheet */ private int rowNumber; /** field name/cell header **/ private String fieldName; /** cell value */ private String fieldValue; private String description; } </code></pre> <p>Here is the error (JSON response with tag)</p> <p>Uncaught Ext.Error: You're trying to decode an invalid JSON String: &LT;pre style="word-wrap: break-word; white-space: pre-wrap;">{"total":1,"success":true,"results":[{"description":"this is not a valid supervisor","fieldName":"supervisor","fieldValue":"testPM","rowNumber":1,"sheetName":"sheet1"}]}&LT;/pre&GT; </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload