{"action":"created","issue":{"url":"https://api.github.com/repos/wso2/product-ei/issues/2523","repository_url":"https://api.github.com/repos/wso2/product-ei","labels_url":"https://api.github.com/repos/wso2/product-ei/issues/2523/labels{/name}","comments_url":"https://api.github.com/repos/wso2/product-ei/issues/2523/comments","events_url":"https://api.github.com/repos/wso2/product-ei/issues/2523/events","html_url":"https://github.com/wso2/product-ei/issues/2523","id":347399381,"node_id":"MDU6SXNzdWUzNDczOTkzODE=","number":2523,"title":"JsonStreamFormatter fail to convert XML to JSON in a Data Service","user":{"login":"jsdjayanga","id":5029961,"node_id":"MDQ6VXNlcjUwMjk5NjE=","avatar_url":"https://avatars2.githubusercontent.com/u/5029961?v=4","gravatar_id":"","url":"https://api.github.com/users/jsdjayanga","html_url":"https://github.com/jsdjayanga","followers_url":"https://api.github.com/users/jsdjayanga/followers","following_url":"https://api.github.com/users/jsdjayanga/following{/other_user}","gists_url":"https://api.github.com/users/jsdjayanga/gists{/gist_id}","starred_url":"https://api.github.com/users/jsdjayanga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsdjayanga/subscriptions","organizations_url":"https://api.github.com/users/jsdjayanga/orgs","repos_url":"https://api.github.com/users/jsdjayanga/repos","events_url":"https://api.github.com/users/jsdjayanga/events{/privacy}","received_events_url":"https://api.github.com/users/jsdjayanga/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-03T13:35:26Z","updated_at":"2018-10-25T08:35:09Z","closed_at":null,"author_association":"NONE","body":"**Description:**\r\nA data service is created and Result (Output Mapping) was as follows;\r\nGrouped by element=Employees\r\nRow name=Employees\r\nSo, it will generate an output like below,\r\n\r\n`<Employees xmlns=\"www.wso2.org/dss\">\r\n    <Employees>\r\n        <FirstNameValue>B</FirstNameValue>\r\n        <LastNameValue>B</LastNameValue>\r\n        <TeamName>B</TeamName>\r\n    </Employees>\r\n</Employees>`\r\n\r\nWhen the request is made with the header \"Accept application/json\", the request fails with following stack trace\r\n\r\n[2018-08-03 18:58:24,979] [EI-Core] ERROR - JsonStreamFormatter Error occurred while writing to application/json\r\njava.lang.reflect.InvocationTargetException\r\n\tat sun.reflect.GeneratedMethodAccessor152.invoke(Unknown Source)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.lang.reflect.Method.invoke(Method.java:498)\r\n\tat org.wso2.carbon.integrator.core.json.JsonStreamFormatter.writeTo(JsonStreamFormatter.java:107)\r\n\tat org.apache.synapse.transport.passthru.PassThroughHttpSender.submitResponse(PassThroughHttpSender.java:595)\r\n\tat org.apache.synapse.transport.passthru.PassThroughHttpSender.invoke(PassThroughHttpSender.java:279)\r\n\tat org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)\r\n\tat org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.invokeBusinessLogic(AbstractInOutSyncMessageReceiver.java:45)\r\n\tat org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)\r\n\tat org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)\r\n\tat org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:337)\r\n\tat org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:158)\r\n\tat org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\r\n\tat java.lang.Thread.run(Thread.java:748)\r\nCaused by: java.lang.StackOverflowError\r\n\tat org.apache.ws.commons.schema.XmlSchema.getElementByName(XmlSchema.java:260)\r\n\tat org.apache.axis2.json.gson.factory.XmlNodeGenerator.processElement(XmlNodeGenerator.java:129)\r\n\tat org.apache.axis2.json.gson.factory.XmlNodeGenerator.processSchemaType(XmlNodeGenerator.java:167)\r\n\t...\r\n\tat org.apache.axis2.json.gson.factory.XmlNodeGenerator.processSchemaType(XmlNodeGenerator.java:167)\r\n\tat org.apache.axis2.json.gson.factory.XmlNodeGenerator.processElement(XmlNodeGenerator.java:138)\r\n[2018-08-03 18:58:24,998] [EI-Core] ERROR - PassThroughHttpSender Failed to submit the response\r\norg.apache.axis2.AxisFault\r\n\tat org.wso2.carbon.integrator.core.json.JsonStreamFormatter.writeTo(JsonStreamFormatter.java:113)\r\n\tat org.apache.synapse.transport.passthru.PassThroughHttpSender.submitResponse(PassThroughHttpSender.java:595)\r\n\tat org.apache.synapse.transport.passthru.PassThroughHttpSender.invoke(PassThroughHttpSender.java:279)\r\n\tat org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)\r\n\tat org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.invokeBusinessLogic(AbstractInOutSyncMessageReceiver.java:45)\r\n\tat org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)\r\n\tat org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)\r\n\tat org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:337)\r\n\tat org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:158)\r\n\tat org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\r\n\tat java.lang.Thread.run(Thread.java:748)\r\n[2018-08-03 18:58:25,001] [EI-Core] ERROR - ServerWorker Error processing GET request for : /services/MYSqlSP/mySQL?empID=2\r\norg.apache.axis2.AxisFault: Failed to submit the response\r\n\tat org.apache.synapse.transport.passthru.PassThroughHttpSender.handleException(PassThroughHttpSender.java:657)\r\n\tat org.apache.synapse.transport.passthru.PassThroughHttpSender.invoke(PassThroughHttpSender.java:281)\r\n\tat org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)\r\n\tat org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.invokeBusinessLogic(AbstractInOutSyncMessageReceiver.java:45)\r\n\tat org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)\r\n\tat org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)\r\n\tat org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:337)\r\n\tat org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:158)\r\n\tat org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\r\n\tat java.lang.Thread.run(Thread.java:748)\r\nCaused by: org.apache.axis2.AxisFault\r\n\tat org.wso2.carbon.integrator.core.json.JsonStreamFormatter.writeTo(JsonStreamFormatter.java:113)\r\n\tat org.apache.synapse.transport.passthru.PassThroughHttpSender.submitResponse(PassThroughHttpSender.java:595)\r\n\tat org.apache.synapse.transport.passthru.PassThroughHttpSender.invoke(PassThroughHttpSender.java:279)\r\n\t... 10 more\r\n\r\n\r\nBut if the Result (Output Mapping) changed as follows it work fine\r\nGrouped by element=Employees\r\nRow name=Employee\r\n\r\n**Suggested Labels:**\r\nBug\r\n\r\n**Suggested Assignees:**\r\n@isudana \r\n\r\n**Affected Product Version:**\r\n6.2.0\r\n\r\n**OS, DB, other environment details and versions:**    \r\nALL\r\n\r\n**Steps to reproduce:**\r\n1. Create a DataService with a query like below\r\n\r\n`<query id=\"Q2\" useConfig=\"MysqlSP\">\r\n      <sql>SELECT FirstName, LastName, Team from Employees where EmployeeID = :eid</sql>\r\n      <result element=\"Employees\" rowName=\"Employees\">\r\n         <element column=\"FirstName\" name=\"FirstName\" xsdType=\"string\"/>\r\n         <element column=\"LastName\" name=\"LastName\" xsdType=\"string\"/>\r\n         <element column=\"Team\" name=\"Team\" xsdType=\"string\"/>\r\n      </result>\r\n      <param name=\"eid\" sqlType=\"STRING\"/>\r\n   </query>`\r\n\r\n2. Invoke it with \"Accept application/json\"\r\n\r\n**Related Issues:**\r\nN/A"},"comment":{"url":"https://api.github.com/repos/wso2/product-ei/issues/comments/432963201","html_url":"https://github.com/wso2/product-ei/issues/2523#issuecomment-432963201","issue_url":"https://api.github.com/repos/wso2/product-ei/issues/2523","id":432963201,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMjk2MzIwMQ==","user":{"login":"SangeethKarunaratne","id":32442096,"node_id":"MDQ6VXNlcjMyNDQyMDk2","avatar_url":"https://avatars2.githubusercontent.com/u/32442096?v=4","gravatar_id":"","url":"https://api.github.com/users/SangeethKarunaratne","html_url":"https://github.com/SangeethKarunaratne","followers_url":"https://api.github.com/users/SangeethKarunaratne/followers","following_url":"https://api.github.com/users/SangeethKarunaratne/following{/other_user}","gists_url":"https://api.github.com/users/SangeethKarunaratne/gists{/gist_id}","starred_url":"https://api.github.com/users/SangeethKarunaratne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SangeethKarunaratne/subscriptions","organizations_url":"https://api.github.com/users/SangeethKarunaratne/orgs","repos_url":"https://api.github.com/users/SangeethKarunaratne/repos","events_url":"https://api.github.com/users/SangeethKarunaratne/events{/privacy}","received_events_url":"https://api.github.com/users/SangeethKarunaratne/received_events","type":"User","site_admin":false},"created_at":"2018-10-25T08:35:09Z","updated_at":"2018-10-25T08:35:09Z","author_association":"CONTRIBUTOR","body":"Hi, the your facing the error because the output mapping had been generated for xml. Refer this documentation for JSON output mapping.\r\nhttps://docs.wso2.com/display/EI640/Using+JSON+with+Data+Services"}}
{"actor":{"display_login":"SangeethKarunaratne"}}