Uploaded image for project: 'ZZZ-WSO2 Data Services Server'
  1. ZZZ-WSO2 Data Services Server
  2. DS-1215

NPE when mapping a MongoDB result set to a complex JSON struct

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: 3.5.0
    • Fix Version/s: 3.5.1-Beta, 3.5.1
    • Component/s: None
    • Labels:
      None
    • Environment:

      JDK 1.8.0

    • Severity:
      Major
    • Estimated Complexity:
      Moderate
    • Test cases added:
      Yes

      Description

      When DSS is connected to MongoDB can map the result of a mongo query to a simple JSON struct in the output mapping.

      Query

      restaurants.find( {}, { restaurant_id: 1, address: 1 })
      

      Output mapping

      {
          "restaurants": {
              "restaurant": [{
                  "id": $document._id.$oid,
                  "address": $document.address.street
              }]
          }
      }
      

      Following output mapping result in an NPE

      {
          "restaurants": {
              "restaurant": [{
                  "id": $document._id.$oid,
                  "address": {
                      "street": $document.address.street,
                      "zipcode": $document.address.zipcode
                  }
              }]
          }
      }
      

      Error,

      [2016-07-07 16:07:52,047]  INFO {com.mongodb.diagnostics.logging.JULLogger} -  Opened connection [connectionId{localValue:3, serverValue:49}] to localhost:27017
      [2016-07-07 16:07:52,076] ERROR {org.wso2.carbon.dataservices.core.engine.DataService} -  DS Code: UNKNOWN_ERROR_Source Data Service:-_Name: MongoDS_Location: /MongoDS.dbs_Description: N/A_Default Namespace: http://ws.wso2.org/dataservice_Current Request Name: testop_Current Params: {}_Nested Exception:-_java.lang.NullPointerException_ (Sanitized)
      java.lang.NullPointerException
      	at org.wso2.carbon.dataservices.core.description.query.MongoQuery.getElementValueFromJson(MongoQuery.java:136)
      	at org.wso2.carbon.dataservices.core.description.query.MongoQuery.wrapMongoRow(MongoQuery.java:116)
      	at org.wso2.carbon.dataservices.core.description.query.MongoQuery.runPostQuery(MongoQuery.java:98)
      	at org.wso2.carbon.dataservices.core.description.query.Query.execute(Query.java:293)
      	at org.wso2.carbon.dataservices.core.engine.CallQuery.executeElement(CallQuery.java:286)
      	at org.wso2.carbon.dataservices.core.engine.OutputElement.execute(OutputElement.java:89)
      	at org.wso2.carbon.dataservices.core.description.operation.Operation.execute(Operation.java:61)
      	at org.wso2.carbon.dataservices.core.engine.DataService.invoke(DataService.java:583)
      	at org.wso2.carbon.dataservices.core.engine.DSOMDataSource.execute(DSOMDataSource.java:96)
      	at org.wso2.carbon.dataservices.core.engine.DSOMDataSource.serialize(DSOMDataSource.java:107)
      	at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.internalSerialize(OMSourcedElementImpl.java:691)
      	at org.apache.axiom.om.impl.util.OMSerializerUtil.serializeChildren(OMSerializerUtil.java:562)
      	at org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:875)
      	at org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.serializeInternally(SOAPEnvelopeImpl.java:283)
      	at org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.internalSerialize(SOAPEnvelopeImpl.java:245)
      	at org.apache.axiom.om.impl.llom.OMSerializableImpl.serializeAndConsume(OMSerializableImpl.java:193)
      	at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:74)
      	at org.apache.axis2.transport.http.CommonsHTTPTransportSender.sendUsingOutputStream(CommonsHTTPTransportSender.java:411)
      	at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:288)
      	at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
      	at org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.invokeBusinessLogic(AbstractInOutSyncMessageReceiver.java:45)
      	at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
      	at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
      	at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:173)
      	at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:146)
      	at org.wso2.carbon.core.transports.CarbonServlet.doPost(CarbonServlet.java:231)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      	at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
      	at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:128)
      	at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:68)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      	at org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.service(DelegationServlet.java:68)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      	at org.wso2.carbon.ui.filters.CSRFPreventionFilter.doFilter(CSRFPreventionFilter.java:88)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      	at org.wso2.carbon.ui.filters.CRLFPreventionFilter.doFilter(CRLFPreventionFilter.java:59)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      	at org.wso2.carbon.tomcat.ext.filter.CharacterSetFilter.doFilter(CharacterSetFilter.java:61)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
      	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
      	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
      	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
      	at org.wso2.carbon.tomcat.ext.valves.CompositeValve.continueInvocation(CompositeValve.java:99)
      	at org.wso2.carbon.tomcat.ext.valves.CarbonTomcatValve$1.invoke(CarbonTomcatValve.java:47)
      	at org.wso2.carbon.webapp.mgt.TenantLazyLoaderValve.invoke(TenantLazyLoaderValve.java:57)
      	at org.wso2.carbon.tomcat.ext.valves.TomcatValveContainer.invokeValves(TomcatValveContainer.java:47)
      	at org.wso2.carbon.tomcat.ext.valves.CompositeValve.invoke(CompositeValve.java:62)
      	at org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:159)
      	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
      	at org.wso2.carbon.tomcat.ext.valves.CarbonContextCreatorValve.invoke(CarbonContextCreatorValve.java:57)
      	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
      	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
      	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074)
      	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
      	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1739)
      	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1698)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      	at java.lang.Thread.run(Thread.java:745)
      

        Attachments

          Activity

            People

            • Assignee:
              manurip@wso2.com Manuri Amaya Perera
              Reporter:
              chintana@wso2.com Chintana Wilamuna
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: