Jaspersoft MongoDB Query Language: Aggregation and projection

Jaspersoft Community 'Read-Only' as of July 8, 2022

Transition to New TIBCO Community Just Weeks Away

You can still search, review wiki content, and review discussions in read-only mode. Please email community@tibco.com with questions or issues requiring TIBCO review or response.

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: 4 years 1 month ago

.

ano_nym_ous - 4 years 4 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 - 4 years 4 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 - 4 years 4 months ago
show 4 more...

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

tizatt - 4 years 1 month 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 - 3 years 11 months ago
kkumlien - 2 years 11 months ago

3 Answers:

See latest comment on the bug report here: https://community.jaspersoft.com/jasperreports-server/issues/10886#comme...
It might not help for Studio but it might for JasperReports Server.

kkumlien's picture
7492
Joined: Jan 22 2015 - 4:36am
Last seen: 2 weeks 4 days ago

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
132
Joined: Feb 17 2017 - 7:07pm
Last seen: 4 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 - 3 years 11 months ago

any new updates on this issue ?

mohamed.aghoulas - 2 years 11 months ago
kkumlien - 2 years 11 months ago

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: 3 years 11 months 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 - 3 years 11 months ago

any new updates on this issue ?

mohamed.aghoulas - 2 years 12 months ago

any new updates on this issue ? How is everybody handling this ?

gsoultan - 2 years 11 months ago
show 1 more...

Same error, any updates?

rjurado - 2 years 10 months ago
Feedback