javarestweb-servicesmulesaxparseexception

WebService response throwing SAXParser Exception


I am getting the following error.I am requesting some WebService and receiving response in the form of json. I get 300 json files in a single webresponse.Its difficult to figure out which particular json is creating problem.Error happens after There is no peculiar special Character with the input json.

{
  "longDescription": null,
  "childProducts": [
    {
      "repositoryId": "866911"
    },
    {
      "repositoryId": "866910"
    },
    {
      "repositoryId": "866909"
    },
    {
      "repositoryId": "867075"
    },
    {
      "repositoryId": "867078"
    },
    {
      "repositoryId": "867081"
    },
    {
      "repositoryId": "867090"
    }
  ],
  "keywords": [

  ],
  "categoryImages": [

  ],
  "displayName": "TestPiece",
  "categoryPaths": [
    "/Upfront"
  ],
  "seoKeywordsDerived": "TestPiece,Clearance",
  "seoUrlSlugDerived": "TestPiece",
  "seoDescriptionDerived": "TestPiece,Clearance TestPiece",
  "description": "Clearance TestPiece",
  "active": true,
  "childCategories": null,
  "seoTitleDerived": "TestPiece",
  "fixedParentCategories": [
    {
      "repositoryId": "5000050"
    }
  ],
  "creationDate": "2018-02-22T20:41:05.000Z",
  "seoMetaInfo": {
    "repositoryId": "1500340"
  },
  "route": "/TestPiece/clearance/5000060",
  "myActive": null,
  "repositoryId": "5000060",
  "name": null,
  "links": [
    {
      "rel": "self",
      "href": "https://cctest-test-te123.oracleoutsourcing.com:443/cctest/v1/collections/5000060"
    }
  ],
  "id": "5000060"
}

Message               : org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Unexpected character 'O' (code 79) in prolog; expected '<'
 at [row,col {unknown-source}]: [1,1] (net.sf.saxon.trans.XPathException)
Type                  : org.mule.api.transformer.TransformerException
Code                  : MULE_ERROR--2
JavaDoc               : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transformer/TransformerException.html
Transformer           : XmlToDomDocument{this=6823290c, name='XmlToDom4jDocument', ignoreBadInput=false, returnClass=SimpleDataType{type=org.dom4j.Document, mimeType='*/*', encoding='null'}, sourceTypes=[SimpleDataType{type=java.lang.String, mimeType='*/*', encoding='null'}, SimpleDataType{type=[B, mimeType='*/*', encoding='null'}, SimpleDataType{type=javax.xml.transform.Source, mimeType='*/*', encoding='null'}, SimpleDataType{type=org.xml.sax.InputSource, mimeType='*/*', encoding='null'}, SimpleDataType{type=org.dom4j.Node, mimeType='*/*', encoding='null'}, SimpleDataType{type=org.dom4j.Document, mimeType='*/*', encoding='null'}, SimpleDataType{type=org.w3c.dom.Document, mimeType='*/*', encoding='null'}, SimpleDataType{type=org.w3c.dom.Element, mimeType='*/*', encoding='null'}, SimpleDataType{type=java.io.InputStream, mimeType='*/*', encoding='null'}, SimpleDataType{type=org.mule.api.transport.OutputHandler, mimeType='*/*', encoding='null'}, SimpleDataType{type=javax.xml.stream.XMLStreamReader, mimeType='*/*', encoding='null'}, SimpleDataType{type=org.mule.module.xml.transformer.DelayedResult, mimeType='*/*', encoding='null'}]}
********************************************************************************
Exception stack is:
1. Unexpected character 'O' (code 79) in prolog; expected '<'
 at [row,col {unknown-source}]: [1,1] (com.ctc.wstx.exc.WstxUnexpectedCharException)
  com.ctc.wstx.sr.StreamScanner:647 (null)
2. Unexpected character 'O' (code 79) in prolog; expected '<'
 at [row,col {unknown-source}]: [1,1] (org.xml.sax.SAXParseException)
  org.mule.module.xml.stax.StaxSource$PseudoReader:220 (null)
3. org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Unexpected character 'O' (code 79) in prolog; expected '<'
 at [row,col {unknown-source}]: [1,1] (net.sf.saxon.trans.XPathException)
  net.sf.saxon.event.Sender:460 (null)
4. org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Unexpected character 'O' (code 79) in prolog; expected '<'
 at [row,col {unknown-source}]: [1,1] (net.sf.saxon.trans.XPathException) (org.mule.api.transformer.TransformerException)
  org.mule.module.xml.transformer.XmlToDomDocument:83 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transformer/TransformerException.html)
********************************************************************************
Root Exception stack trace:
com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'O' (code 79) in prolog; expected '<'
 at [row,col {unknown-source}]: [1,1]
    at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:647)
    at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2054)
    at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1131)
    at org.mule.module.xml.stax.XMLStreamReaderToContentHandler.bridge(XMLStreamReaderToContentHandler.java:98)
    at org.mule.module.xml.stax.StaxSource$PseudoReader.parse(StaxSource.java:206)
    at org.mule.module.xml.stax.StaxSource$PseudoReader.parse(StaxSource.java:191)
    at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:440)
    at net.sf.saxon.event.Sender.send(Sender.java:145)
    at net.sf.saxon.jaxp.IdentityTransformer.transform(IdentityTransformer.java:363)
    at org.mule.module.xml.transformer.XmlToDomDocument.transformMessage(XmlToDomDocument.java:77)
    at org.mule.transformer.AbstractMessageTransformer.transform(AbstractMessageTransformer.java:141)
    at org.mule.transformer.AbstractMessageTransformer.transform(AbstractMessageTransformer.java:69)
    at org.mule.DefaultMuleMessage.getPayload(DefaultMuleMessage.java:425)
    at org.mule.DefaultMuleMessage.getPayload(DefaultMuleMessage.java:373)
    at org.mule.module.xml.expression.AbstractXPathExpressionEvaluator.getPayloadForXPath(AbstractXPathExpressionEvaluator.java:163)
    at org.mule.module.xml.expression.AbstractXPathExpressionEvaluator.evaluate(AbstractXPathExpressionEvaluator.java:124)
    at org.mule.expression.AbstractExpressionEvaluator.evaluateTyped(AbstractExpressionEvaluator.java:26)
    at org.mule.expression.DefaultExpressionManager.evaluateTyped(DefaultExpressionManager.java:333)
    at org.mule.expression.DefaultExpressionManager.evaluateTyped(DefaultExpressionManager.java:576)
    at org.mule.util.AttributeEvaluator.resolveTypedValue(AttributeEvaluator.java:106)
    at org.mule.transformer.simple.AbstractAddVariablePropertyTransformer.transformMessage(AbstractAddVariablePropertyTransformer.java:53)
    at org.mule.transformer.AbstractMessageTransformer.transform(AbstractMessageTransformer.java:141)
    at org.mule.transformer.AbstractMessageTransformer.transform(AbstractMessageTransformer.java:89)
    at org.mule.DefaultMuleMessage.transformMessage(DefaultMuleMessage.java:1602)
    at org.mule.DefaultMuleMessage.applyAllTransformers(DefaultMuleMessage.java:1509)
    at org.mule.DefaultMuleMessage.applyTransformers(DefaultMuleMessage.java:1487)
    at org.mule.DefaultMuleMessage.applyTransformers(DefaultMuleMessage.java:1479)
    at org.mule.transformer.AbstractTransformer.process(AbstractTransformer.java:114)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
    at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
    at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:94)
    at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:56)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
    at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
    at org.mule.routing.AbstractSelectiveRouter.processEventWithProcessor(AbstractSelectiveRouter.java:303)
    at org.mule.routing.AbstractSelectiveRouter.routeWithProcessors(AbstractSelectiveRouter.java:293)
    at org.mule.routing.AbstractSelectiveRouter.process(AbstractSelectiveRouter.java:193)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
    at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:107)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
    at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:85)
    at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:56)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
    at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:94)
    at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:56)
    at org.mule.interceptor.AbstractEnv...
********************************************************************************

Solution

  • WebService is expecting XML and you are passing JSON. Read API documentation how to provide the request in JSON, not XML.