[JAVA-2420] Aggregates.replaceRoot and Aggregates.addFields Created: 28/Dec/16 Updated: 27/Oct/23 Resolved: 28/Dec/16 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | API |
| Affects Version/s: | 3.4.1 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | himnaz | Assignee: | Unassigned |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows, Java 8 |
||
| Description |
|
Hi I am trying to use Aggregates.replaceRoot and Aggregates.addFields in MongoDb Java Driver in our application. I have the following codes used to test this function which is failing. Can you please tell me if it is a bug or syntax error in my code. public ArrayList<Document> testAggregation5() { MongoCollection<Document> collection = databasePuttPutt.getCollection("Merchant"); return collection.aggregate( Arrays.asList( Aggregates.addFields(new Field("merchantId", "testval")), Aggregates.unwind("$promotion_list"), Aggregates.sort(orderBy(ascending("pro_created_date"))) ) ).into(new ArrayList<Document>()); }public ArrayList<Document> testAggregation6a() { MongoCollection<Document> collection = databasePuttPutt.getCollection("Merchant"); return collection.aggregate( Arrays.asList( Aggregates.replaceRoot("$promotion_list") ) ).into(new ArrayList<Document>()); }///////////////////////////////////////////////////////////////////////Error Stack is follwos///////////// Caused by: java.lang.NoSuchMethodError: com.mongodb.client.model.Aggregates.replaceRoot(Ljava/lang/Object;)Lorg/bson/conversions/Bson; |
| Comments |
| Comment by himnaz [ 28/Dec/16 ] | |||
|
Thanks. You are right. | |||
| Comment by Jeffrey Yemin [ 28/Dec/16 ] | |||
|
It's almost certainly the case that in the JBoss environment in which you are running there is an older version of the driver in the classpath that is taking precedence over the 3.4.1 version with which you compiled those tests. You might try enabling verbose class loading using the -verbose:class VM options to figure out what's happening. For example, when I run your example in a test program with -verbose:class specified on the command line, I see this output:
|