Reputation: 61
i am getting
Failed to instantiate java.util.List using constructor NO_CONSTRUCTOR with arguments ] with root cause
org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.util.List]: Specified class is an interface
this exception while updating the mongodb nested document.
the problem is the same as it is dicscuseed it this link
but still no clue how to solve it. anyone gone thorugh this??
Upvotes: 4
Views: 19098
Reputation: 830
I just had the same problem and solved it thanks to: Mongo db java unwind operation in aggregate query throwing exception
When in the aggregation the unwind happened, the results are flattened so in my case I had a class like:
MyClass {
String _id;
List<SomeObject> objectList;
}
The exception occurs because of the flattening, the results on my list object instead of coming up in an array, now are just a single object because of the $unwind.
What I did to fix this was to create the same class without the list:
MyClassAggregationResult {
String _id;
SomeObject objectList;
}
This way the results are mapped correctly.
Hope this works for you as well.
Upvotes: 8