Jaspersoft MongoDB Query Language: Aggregation and projection

4

Hello,

I have a Mongo Query which is extracting the subducument from a collection and projects its fields.

The query is working fine, but I am not able to put it into the Jaspersoft MongoDB Query which is necessary for getting the dataset!

I looked through https://community.jaspersoft.com/wiki/jaspersoft-mongodb-query-language

but without success.

Is anybody able to convert this statement into a working query for a jasper report?

 

db.getCollection('a').aggregate({
    $unwind: "$b"
}, {
    $project: {
        attribute: "$b.attribute"
    }
})

 

Any help would be highly appreciated!

 

ano_nym_ous's picture
Joined: Feb 1 2018 - 5:00am
Last seen: 11 months 1 week ago

.

ano_nym_ous - 1 year 2 months ago

Ok.. so at the moment I think my query is correct.. but the problem seems to be the 

"JRException: The 'cursor' option is required, except for aggregate with the explain argument"

Has anyone experience with this problem?

ano_nym_ous - 1 year 2 months ago

I also getting this error since upgrading to MongoDB 3.6.3. It only occurs when doing an aggregation query.


2018-03-05 10:15:32,130 ERROR GenericExceptionMapper,http-nio-8080-exec-3:50 - Unexpected error occurs
net.sf.jasperreports.engine.JRException: The 'cursor' option is required, except for aggregate with the explain argument
    at com.jaspersoft.mongodb.query.MongoDbQueryWrapper.runCommand(MongoDbQueryWrapper.java:207)
    at com.jaspersoft.mongodb.query.MongoDbQueryWrapper.processQuery(MongoDbQueryWrapper.java:115)
    at com.jaspersoft.mongodb.query.MongoDbQueryWrapper.<init>(MongoDbQueryWrapper.java:93)
    at com.jaspersoft.mongodb.query.MongoDbQueryExecuter.createDatasource(MongoDbQueryExecuter.java:104)

When specifying the options field using the  jaspersoft-mongodb-query-language, i get the following error in the log:

2018-03-05 10:14:12,893 ERROR JRQueryExecuterAdapter,http-nio-8080-exec-7:155 - Error while executing query
net.sf.jasperreports.engine.JRException: unrecognized field 'options'

I've replaced the java driver in the server lib dir but the error persists.

 

ben.strydom - 1 year 1 month ago
show 3 more...

I have gotten the exact same error after upgrading to MongoDB 3.6.  Haven't found a solution either

tizatt - 11 months 1 week ago

Hi All - We are hitting the same issue in our deployment. Upgraded MongoDB to latest build and started getting this issue. Anyone found any hacks or fixed "jar".

deepakgup - 9 months 1 week ago

2 Answers:

0

There was a change in MongoDB version 3.6. Per MongoDB docs (https://docs.mongodb.com/manual/reference/command/aggregate/#dbcmd.aggre...):

Changed in version 3.6: MongoDB 3.6 removes the use of aggregate command without the cursor option unless the command includes the explain option. Unless you include the explain option, you must specify the cursor option.

So, you just need to add an empty "cursor" document.

Also, pipeline needs to be an array.

So, your query in JR needs to be similar to the following example:

{
    "runCommand": {
        "aggregate" : "{collection name}",
        "pipeline" : [
            {
                "$match": {
                    ...
                }
            },
            {
                ...
            }
        ],
        "cursor": {}
    }
}

pjacekm's picture
24
Joined: Feb 17 2017 - 7:07pm
Last seen: 7 months 2 weeks ago

It doesn't work even if the empty cursor block is given.

The issue is that the Jaspersoft mongodb Connector (js-mongodb-datasource-2.0.9.jar) - the code is expecting the result data as inline results ('results' field). But MongoDB 3.6 results a cursor.
So it gives a 'No results exception' . This requires code change in the js-mongodb-datasource-2.0.9.jar and needs to be rebuilt. I could n't find the source of this component any where.

Due to this issue, Jasper report is almost unusable in all typical reports with MongoDB 3.6 and 4.0

Please help to resolve this issue

cto_2 - 9 months 1 week ago
0

There is an updated js-mongodb-datasource-2.0.10.jar available at http://jaspersoft.artifactoryonline.com/jaspersoft/jaspersoft-repo/com/j....

Does it contains this fix?

How to apply this patch?

pratik.g's picture
Joined: Jul 14 2018 - 5:43am
Last seen: 8 months 2 weeks ago

No. The latest js-mongodb-datasource-2.0.10.jar also doesn't solve this issue.

We need either need the fix or the source code for this jar file so that we ccan fix it.

cto_2 - 9 months 5 days ago
Feedback