Hi Anjana,
I compared the sample with my service, and noticed I haven't defined a
result tag for the query. And it was the cause of the issue. The working
service is as follows. Thanks for the help! :)
<data name="testMongoService">
<config id="capedev-mongo">
<property name="mongoDB_servers">172.17.0.4:27017</property>
<property name="mongoDB_database">TestDB</property>
<property name="mongoDB_write_concern">NONE</property>
<property name="mongoDB_read_preference">PRIMARY</property>
<property name="mongoDB_autoConnectRetry">true</property>
</config>
<query id="mongo_find" useConfig="capedev-mongo">
<expression>TestCollection.findOne()</expression>
<result element="Documents" rowName="Document">
<element column="document" name="Data" xsdType="string"/>
</result>
</query>
<operation name="mongo_find">
<description>mongo find operation</description>
<call-query href="mongo_find"/>
</operation>
<resource method="GET" path="test">
<call-query href="mongo_find"/>
</resource>
</data>
The stack trace for the NPE I got earlier is as follows. Shall I report
this anyway?
Caused by: java.lang.NullPointerException
at
org.wso2.carbon.dataservices.core.description.query.Query.writeResultEntry(Query.java:396)
at
org.wso2.carbon.dataservices.core.description.query.MongoQuery.runQuery(MongoQuery.java:97)
Regards,
Chamila de Alwis
Software Engineer | WSO2 | +94772207163
Blog: code.chamiladealwis.com
On Mon, Dec 1, 2014 at 2:02 PM, Anjana Fernando <[email protected]> wrote:
> Oh I see .. if we get an NPE, that's anyways a bug then. Can you please
> report this in DSS JIRA [1] (put the log in the console too). Also, do
> check the MongDB sample we have in the product. That should work. You can
> compare that and the one you have. The sample is at
> "$SERVER_ROOT/samples/dbs/mongoDB/MongoDBSampleService.dbs".
>
> [1] https://wso2.org/jira/browse/DS
>
> Cheers,
> Anjana.
>
> On Mon, Dec 1, 2014 at 1:57 PM, Chamila De Alwis <[email protected]>
> wrote:
>
>> Hi Anjana,
>>
>> I tried that too. :) It resulted in an NPE.
>>
>> <soapenv:Fault xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"
>> xmlns:axis2ns43="http://ws.wso2.org/dataservice">
>> <soapenv:Code>
>> <soapenv:Value>axis2ns43:UNKNOWN_ERROR</soapenv:Value>
>> </soapenv:Code>
>> <soapenv:Reason>
>> <soapenv:Text xml:lang="en-US">DS Fault Message: Error in DS non
>> result invoke.
>> DS Code: UNKNOWN_ERROR
>> Nested Exception:-
>> javax.xml.stream.XMLStreamException: DS Fault Message: Error in
>> MongoQuery.runQuery: null
>> DS Code: UNKNOWN_ERROR
>> Source Data Service:-
>> Name: testMongoService
>> Location: /testMongoService.dbs
>> Description: N/A
>> Default Namespace: http://ws.wso2.org/dataservice
>> Current Request Name: mongo_find
>> Current Params: {}
>> Nested Exception:-
>> java.lang.NullPointerException
>>
>> </soapenv:Text>
>> </soapenv:Reason>
>> <soapenv:Detail>
>> <axis2ns42:DataServiceFault xmlns:axis2ns42="
>> http://ws.wso2.org/dataservice">
>> <axis2ns42:current_params>{}</axis2ns42:current_params>
>>
>> <axis2ns42:current_request_name>mongo_find</axis2ns42:current_request_name>
>>
>>
>> <axis2ns42:nested_exception>java.lang.NullPointerException</axis2ns42:nested_exception>
>> <axis2ns42:source_data_service>
>> <axis2ns42:location>/testMongoService.dbs</axis2ns42:location>
>> <axis2ns42:default_namespace>http://ws.wso2.org/dataservice
>> </axis2ns42:default_namespace>
>> <axis2ns42:description>N/A</axis2ns42:description>
>>
>> <axis2ns42:data_service_name>testMongoService</axis2ns42:data_service_name>
>> </axis2ns42:source_data_service>
>> <axis2ns42:ds_code>UNKNOWN_ERROR</axis2ns42:ds_code>
>> </axis2ns42:DataServiceFault>
>> </soapenv:Detail>
>> </soapenv:Fault>
>>
>>
>> Regards,
>> Chamila de Alwis
>> Software Engineer | WSO2 | +94772207163
>> Blog: code.chamiladealwis.com
>>
>>
>>
>> On Mon, Dec 1, 2014 at 1:54 PM, Anjana Fernando <[email protected]> wrote:
>>
>>> Hi Chamila,
>>>
>>> Just use "TestCollection.findOne()" as the query expression, basically
>>> drop the "db" part. It should work then.
>>>
>>> Cheers,
>>> Anjana.
>>>
>>> On Mon, Dec 1, 2014 at 1:38 PM, Chamila De Alwis <[email protected]>
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> I'm trying to query a mongoDb, using the following data service.
>>>>
>>>> <data name="testMongoService">
>>>> <config id="capedev-mongo">
>>>> <property name="mongoDB_servers">172.17.0.4:27017</property>
>>>> <property name="mongoDB_database">*TestDB*</property>
>>>> <property name="mongoDB_write_concern">NONE</property>
>>>> <property name="mongoDB_read_preference">PRIMARY</property>
>>>> <property name="mongoDB_autoConnectRetry">true</property>
>>>> </config>
>>>> <query id="mongo_find" useConfig="capedev-mongo">
>>>> <expression>*db.TestCollection.findOne()*</expression>
>>>> </query>
>>>> <operation name="mongo_find">
>>>> <description>mongo find operation</description>
>>>> <call-query href="mongo_find"/>
>>>> </operation>
>>>> <resource method="GET" path="test">
>>>> <call-query href="mongo_find"/>
>>>> </resource>
>>>> </data>
>>>>
>>>>
>>>> I can't get data from this service, it fails with the following error
>>>> message. However I can execute the same expression on the mongo db browser
>>>> I'm using because I've created the TestDB database and the TestCollection
>>>> collection.
>>>>
>>>> <soapenv:Fault xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"
>>>> xmlns:axis2ns38="http://ws.wso2.org/dataservice">
>>>> <soapenv:Code>
>>>> <soapenv:Value>axis2ns38:UNKNOWN_ERROR</soapenv:Value>
>>>> </soapenv:Code>
>>>> <soapenv:Reason>
>>>> <soapenv:Text xml:lang="en-US">DS Fault Message: Error in DS non
>>>> result invoke.
>>>> DS Code: UNKNOWN_ERROR
>>>> Nested Exception:-
>>>> javax.xml.stream.XMLStreamException: DS Fault Message: Error in
>>>> MongoQuery.runQuery: DS Fault Message: *Unknown MongoDB operation
>>>> 'TestCollection.findOne'*
>>>> DS Code: UNKNOWN_ERROR
>>>>
>>>> DS Code: UNKNOWN_ERROR
>>>> Source Data Service:-
>>>> Name: testMongoService
>>>> Location: /testMongoService.dbs
>>>> Description: N/A
>>>> Default Namespace: http://ws.wso2.org/dataservice
>>>> Current Request Name: mongo_find
>>>> Current Params: {}
>>>> Nested Exception:-
>>>> DS Fault Message: Unknown MongoDB operation 'TestCollection.findOne'
>>>> DS Code: UNKNOWN_ERROR
>>>>
>>>>
>>>> </soapenv:Text>
>>>> </soapenv:Reason>
>>>> <soapenv:Detail>
>>>> <axis2ns37:DataServiceFault xmlns:axis2ns37="
>>>> http://ws.wso2.org/dataservice">
>>>> <axis2ns37:current_params>{}</axis2ns37:current_params>
>>>>
>>>>
>>>> <axis2ns37:current_request_name>mongo_find</axis2ns37:current_request_name>
>>>> <axis2ns37:nested_exception>DS Fault Message: Unknown MongoDB
>>>> operation 'TestCollection.findOne'
>>>> DS Code: UNKNOWN_ERROR
>>>> </axis2ns37:nested_exception>
>>>> <axis2ns37:source_data_service>
>>>>
>>>> <axis2ns37:location>/testMongoService.dbs</axis2ns37:location>
>>>> <axis2ns37:default_namespace>http://ws.wso2.org/dataservice
>>>> </axis2ns37:default_namespace>
>>>> <axis2ns37:description>N/A</axis2ns37:description>
>>>>
>>>> <axis2ns37:data_service_name>testMongoService</axis2ns37:data_service_name>
>>>> </axis2ns37:source_data_service>
>>>> <axis2ns37:ds_code>UNKNOWN_ERROR</axis2ns37:ds_code>
>>>> </axis2ns37:DataServiceFault>
>>>> </soapenv:Detail>
>>>> </soapenv:Fault>
>>>>
>>>>
>>>> Regards,
>>>> Chamila de Alwis
>>>> Software Engineer | WSO2 | +94772207163
>>>> Blog: code.chamiladealwis.com
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Dev mailing list
>>>> [email protected]
>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>>
>>>>
>>>
>>>
>>> --
>>> *Anjana Fernando*
>>> Senior Technical Lead
>>> WSO2 Inc. | http://wso2.com
>>> lean . enterprise . middleware
>>>
>>
>>
>
>
> --
> *Anjana Fernando*
> Senior Technical Lead
> WSO2 Inc. | http://wso2.com
> lean . enterprise . middleware
>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev