I created an application with springboot+mongoDB. I have a class Test which has an instance variable duration of class "javax.xml.datatype.Duration". Duration is an abstract class. I am able to save data using rest request.But when I am retrieving saved data from DB using get request getting following error.
{
"timestamp": "2018-06-05T09:27:28.538+0000",
"status": 500,
"error": "Internal Server Error",
"message": "Failed to instantiate com.sun.org.apache.xerces.internal.jaxp.datatype.DurationImpl using constructor NO_CONSTRUCTOR with arguments ",
"path": "/user/test"
}
I have checked the DB to get the BSON representation
{
"_id" : "Arjun",
"duration" : {
"signum" : 1,
"hours" : "2",
"minutes" : "0",
"seconds" : "0",
"_class" : "com.sun.org.apache.xerces.internal.jaxp.datatype.DurationImpl"
},
"_class" : "com.runitsimple.WebshopConnectorMangoDB3.bean.Test"
}
Like you can see mongo is mapped to the duration class instance to "com.sun.org.apache.xerces.internal.jaxp.datatype.DurationImpl"
it is a default scope class and we won't able to create the instance outside the package.
Really stuck with the problem. Please help.
class is below
public class Test {
@Id
private String name;
private Duration duration;
public Test() {
}
public Test(String name, Duration duration) {
this.name = name;
this.duration = duration;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Duration getDuration() {
return duration;
}
public void setDuration(Duration duration) {
this.duration = duration;
}
}