extjs4 - ExtJs 4 File upload with RESTEasy 2.3.0.GA , Invalid JSON response -


there lot of discussion topic no real solution.

here problem if use

1) @produce("application/json") json response show in <pre> tag

2) if use @produce("application/html") or @produce("text/html"),then resteasy breakdown , error out jaxb exception :

uncaught ext.error: you're trying decode invalid json string:

http status 500 - not find jaxbcontextfinder media type: text/html

type status report

message not find jaxbcontextfinder media type: text/html

description server encountered internal error (could not find jaxbcontextfinder media type: text/html) prevented fulfilling request.

jboss web/3.0.0-cr2

i desperate , there solution suggested in forms: 1) change contect type text/html 2) update extjs source code 3) parse <pre> tag in fron the json response don't want 2nd , 3rd in ist want valid json output. how can ?

here is serverice class:

 @post     @path("/bulkupdate")     @consumes("multipart/form-data")     @produces({"application/json"})     public extjsjson<dataexception> uploadfile(multipartformdatainput input) {          map<string, list<inputpart>> uploadform = input.getformdatamap();         list<inputpart> inputparts = uploadform.get("uploadedfile");         list<dataexception> list = new arraylist<dataexception>();         final extjsjson<dataexception> returnobj = new extjsjson<dataexception>();         (inputpart inputpart : inputparts) {             try {                 multivaluedmap<string, string> header = inputpart.getheaders();                 string filename  = getfilename(header);                 inputstream inputstream = inputpart.getbody(inputstream.class, null);                 byte[] bytes = ioutils.tobytearray(inputstream);                  //handle excel file upload , return error if file not have valid data like..                 dataexception error = new dataexception("supervisor", "columnname", 1, "sheetname", "this not valid supervisor");                    list.add(error);             } catch (ioexception e) {                 e.printstacktrace();             }         }         returnobj.setsuccess(true);         returnobj.setresults(list);         return returnobj;     } 

here response object dataexception.java

@data @xmlrootelement @xmlaccessortype(xmlaccesstype.field) public class dataexception {      //private static final long serialversionuid = 1l;      /** excel sheet name */     private string sheetname;      /** row number of excel sheet */     private int rownumber;      /** field name/cell header **/     private string fieldname;      /** cell value */     private string fieldvalue;      private string description; } 

here error (json response tag)

uncaught ext.error: you're trying decode invalid json string: <pre style="word-wrap: break-word; white-space: pre-wrap;">{"total":1,"success":true,"results":[{"description":"this not valid supervisor","fieldname":"supervisor","fieldvalue":"testpm","rownumber":1,"sheetname":"sheet1"}]}</pre>

i had same problem , solution was:

  1. use @produces("text/html")
  2. your method need send string frontend:

    public string uploadfile (...)

  3. easiest way implement tostring() method in extjsjson class returns in string format.

Comments

Popular posts from this blog

How do you change vbulletin's home page to the forums instead of the default (CMS or Activity Stream)? -

c++ - Troubles when compiling phash program -