[JAVA-2822] com.mongodb.AggregateIterableImpl does not implement toCollection Created: 26/Mar/18  Updated: 27/Oct/23  Resolved: 26/Mar/18

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: 3.6.3
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Brian Ghigiarelli Assignee: Unassigned
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

With the 3.6.3 Java driver running on Java 8u141, the AggregateIterableImpl returned from the DBCollection.aggregate(...) method throws a NoSuchMethodError when attempting to run the toCollection method. However, the AggregateIterable interface defines this method.

Compilation of the class is successful. The error appears to only be at runtime.

Reflection over the class shows the following methods are available:

  • iterator
  • iterator
  • execute
  • first
  • forEach
  • map
  • createBsonDocumentList
  • useCursor
  • into
  • bypassDocumentValidation
  • maxTime
  • batchSize
  • batchSize
  • allowDiskUse

Example to reproduce:

AggregateIterable<Document> pipeline = collection.aggregate(stages);
pipeline.toCollection();

The actual error is:

java.lang.NoSuchMethodError: com.mongodb.client.AggregateIterable.toCollection()V



 Comments   
Comment by Jeffrey Yemin [ 26/Mar/18 ]

OK, thanks for letting us know. Closing as Works as Designed.

Comment by Brian Ghigiarelli [ 26/Mar/18 ]

After further investigation, this may have simply been a class loading collision between both 3.2.2 and 3.6.3 JARs.

Generated at Thu Feb 08 08:58:09 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.