org.springframework.data.mapping.model.MappingInstantiationException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • When trying to switch to spring-data-mongo-1.1.M2 from 1.0.3, I had the following stacktrace : {code} org.springframework.data.mapping.model.MappingInstantiationException: Could not instantiate bean class [com.mycompany.catalog.Transaction]: Illegal arguments for constructor; nested exception is java.lang.IllegalArgumentException: argument type mismatch at org.springframework.data.convert.ReflectionEntityInstantiator.createInstance(ReflectionEntityInstantiator.java:77) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:230) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:210) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:174) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:170) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:73) at org.springframework.data.mongodb.core.MongoTemplate$ReadDbObjectCallback.doWith(MongoTemplate.java:1718) at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:1441) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1244) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1233) at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:471) at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:466) at com.mycompany.catalog.repositories.AbstractRepositoryCustomMongo.findByQueryPageable(AbstractRepositoryCustomMongo.java:35) at com.mycompany.catalog.repositories.TransactionRepositoryCustomMongo.findByProduct(TransactionRepositoryCustomMongo.java:64) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:334) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:309) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at $Proxy26.findByProduct(Unknown Source) at com.mycompany.catalog.repositories.TransactionRepositoryTest.testFindByProduct(TransactionRepositoryTest.java:49) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.junit.runner.JUnitCore.run(JUnitCore.java:157) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:62) Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.mycompany.catalog.Transaction]: Illegal arguments for constructor; nested exception is java.lang.IllegalArgumentException: argument type mismatch at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:158) at org.springframework.data.convert.ReflectionEntityInstantiator.createInstance(ReflectionEntityInstantiator.java:75) ... 50 more Caused by: java.lang.IllegalArgumentException: argument type mismatch at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147) ... 51 more {code} After further investigation, I found that the problem come from the instanciation of my Transaction document which use @PersistenceConstructor on this constructor : {code} @PersistenceConstructor public Transaction( ObjectId id, Product product, List<Operation> operations ) {code} Spring try to instantiate it with an HashSet instead of a List for the third constructor argument. The HashSet is passed from the method {{org.springframework.data.mongodb.core.convert.MappingMongoConverter#readCollectionOrArray}} resulting in the a {{IllegalArgumentException: argument type mismatch}} The {{readCollectionOrArray}} method should return an empty collection which matches the type of the constructor param at line https://github.com/SpringSource/spring-data-mongodb/blob/master/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MappingMongoConverter.java#L724 It may be related to : * issue DATAMONGO-458 * commit https://github.com/SpringSource/spring-data-mongodb/commit/b3a891c69b38f5b53b5f6041c9af6aa3f89afe24
    via by Ludovic Praud,
  • When trying to switch to spring-data-mongo-1.1.M2 from 1.0.3, I had the following stacktrace : {code} org.springframework.data.mapping.model.MappingInstantiationException: Could not instantiate bean class [com.mycompany.catalog.Transaction]: Illegal arguments for constructor; nested exception is java.lang.IllegalArgumentException: argument type mismatch at org.springframework.data.convert.ReflectionEntityInstantiator.createInstance(ReflectionEntityInstantiator.java:77) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:230) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:210) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:174) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:170) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:73) at org.springframework.data.mongodb.core.MongoTemplate$ReadDbObjectCallback.doWith(MongoTemplate.java:1718) at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:1441) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1244) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1233) at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:471) at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:466) at com.mycompany.catalog.repositories.AbstractRepositoryCustomMongo.findByQueryPageable(AbstractRepositoryCustomMongo.java:35) at com.mycompany.catalog.repositories.TransactionRepositoryCustomMongo.findByProduct(TransactionRepositoryCustomMongo.java:64) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:334) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:309) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at $Proxy26.findByProduct(Unknown Source) at com.mycompany.catalog.repositories.TransactionRepositoryTest.testFindByProduct(TransactionRepositoryTest.java:49) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.junit.runner.JUnitCore.run(JUnitCore.java:157) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:62) Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.mycompany.catalog.Transaction]: Illegal arguments for constructor; nested exception is java.lang.IllegalArgumentException: argument type mismatch at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:158) at org.springframework.data.convert.ReflectionEntityInstantiator.createInstance(ReflectionEntityInstantiator.java:75) ... 50 more Caused by: java.lang.IllegalArgumentException: argument type mismatch at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147) ... 51 more {code} After further investigation, I found that the problem come from the instanciation of my Transaction document which use @PersistenceConstructor on this constructor : {code} @PersistenceConstructor public Transaction( ObjectId id, Product product, List<Operation> operations ) {code} Spring try to instantiate it with an HashSet instead of a List for the third constructor argument. The HashSet is passed from the method {{org.springframework.data.mongodb.core.convert.MappingMongoConverter#readCollectionOrArray}} resulting in the a {{IllegalArgumentException: argument type mismatch}} The {{readCollectionOrArray}} method should return an empty collection which matches the type of the constructor param at line https://github.com/SpringSource/spring-data-mongodb/blob/master/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MappingMongoConverter.java#L724 It may be related to : * issue DATAMONGO-458 * commit https://github.com/SpringSource/spring-data-mongodb/commit/b3a891c69b38f5b53b5f6041c9af6aa3f89afe24
    via by Ludovic Praud,
  • I have the following sample model with enum values implementing an abstract method: {code:title=Entity.java} @Document public class Entity { private String id; private ImAnEnum testEnums = ImAnEnum.ONE; public String getId() { return id; } } {code} {code:title=ImAnEnum.java} @Document public enum ImAnEnum { ONE { @Override boolean somethingToDo() { return false; } }, TWO { @Override boolean somethingToDo() { return false; } }, THREE { @Override boolean somethingToDo() { return true; } }; abstract boolean somethingToDo(); } {code} When I save the entity the document looks like: {code:title=db document} { "_id" : ObjectId("4eb6bf6ef5981c320579e48b"), "_class" : "com.sejda.persistence.MongoTestEnum$Entity", "testEnums" : { "_class" : "com.sejda.persistence.MongoTestEnum$ImAnEnum$1", "name" : "ONE", "ordinal" : 0 } } {code} and when I run: {code} Entity foundEntity = mongoOps.findById(entity.getId(), Entity.class); {code} I get the following exception: {code} org.springframework.data.mapping.model.MappingInstantiationException: Could not instantiate bean class [com.sejda.persistence.MongoTestEnum$ImAnEnum$1]: Illegal arguments for constructor; nested exception is java.lang.IllegalArgumentException: Cannot reflectively create enum objects at org.springframework.data.mapping.model.BeanWrapper.<init>(BeanWrapper.java:122) at org.springframework.data.mapping.model.BeanWrapper.create(BeanWrapper.java:73) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:255) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:203) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.getValueInternal(MappingMongoConverter.java:762) at org.springframework.data.mongodb.core.convert.MappingMongoConverter$2.doWithPersistentProperty(MappingMongoConverter.java:268) at org.springframework.data.mongodb.core.convert.MappingMongoConverter$2.doWithPersistentProperty(MappingMongoConverter.java:258) at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:173) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:258) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:203) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:171) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:77) at org.springframework.data.mongodb.core.MongoTemplate$ReadDbObjectCallback.doWith(MongoTemplate.java:1505) at org.springframework.data.mongodb.core.MongoTemplate.executeFindOneInternal(MongoTemplate.java:1237) at org.springframework.data.mongodb.core.MongoTemplate.doFindOne(MongoTemplate.java:1081) at org.springframework.data.mongodb.core.MongoTemplate.findById(MongoTemplate.java:478) at org.springframework.data.mongodb.core.MongoTemplate.findById(MongoTemplate.java:471) at com.sejda.persistence.MongoTestEnum.testInsertAndRetrieve(MongoTestEnum.java:37) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.sejda.persistence.MongoTestEnum$ImAnEnum$1]: Illegal arguments for constructor; nested exception is java.lang.IllegalArgumentException: Cannot reflectively create enum objects at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:137) at org.springframework.data.mapping.model.BeanWrapper.<init>(BeanWrapper.java:120) ... 45 more Caused by: java.lang.IllegalArgumentException: Cannot reflectively create enum objects at java.lang.reflect.Constructor.newInstance(Constructor.java:511) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126) ... 46 more {code}
    via by Andrea Vacondio,
  • I have the following sample model with enum values implementing an abstract method: {code:title=Entity.java} @Document public class Entity { private String id; private ImAnEnum testEnums = ImAnEnum.ONE; public String getId() { return id; } } {code} {code:title=ImAnEnum.java} @Document public enum ImAnEnum { ONE { @Override boolean somethingToDo() { return false; } }, TWO { @Override boolean somethingToDo() { return false; } }, THREE { @Override boolean somethingToDo() { return true; } }; abstract boolean somethingToDo(); } {code} When I save the entity the document looks like: {code:title=db document} { "_id" : ObjectId("4eb6bf6ef5981c320579e48b"), "_class" : "com.sejda.persistence.MongoTestEnum$Entity", "testEnums" : { "_class" : "com.sejda.persistence.MongoTestEnum$ImAnEnum$1", "name" : "ONE", "ordinal" : 0 } } {code} and when I run: {code} Entity foundEntity = mongoOps.findById(entity.getId(), Entity.class); {code} I get the following exception: {code} org.springframework.data.mapping.model.MappingInstantiationException: Could not instantiate bean class [com.sejda.persistence.MongoTestEnum$ImAnEnum$1]: Illegal arguments for constructor; nested exception is java.lang.IllegalArgumentException: Cannot reflectively create enum objects at org.springframework.data.mapping.model.BeanWrapper.<init>(BeanWrapper.java:122) at org.springframework.data.mapping.model.BeanWrapper.create(BeanWrapper.java:73) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:255) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:203) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.getValueInternal(MappingMongoConverter.java:762) at org.springframework.data.mongodb.core.convert.MappingMongoConverter$2.doWithPersistentProperty(MappingMongoConverter.java:268) at org.springframework.data.mongodb.core.convert.MappingMongoConverter$2.doWithPersistentProperty(MappingMongoConverter.java:258) at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:173) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:258) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:203) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:171) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:77) at org.springframework.data.mongodb.core.MongoTemplate$ReadDbObjectCallback.doWith(MongoTemplate.java:1505) at org.springframework.data.mongodb.core.MongoTemplate.executeFindOneInternal(MongoTemplate.java:1237) at org.springframework.data.mongodb.core.MongoTemplate.doFindOne(MongoTemplate.java:1081) at org.springframework.data.mongodb.core.MongoTemplate.findById(MongoTemplate.java:478) at org.springframework.data.mongodb.core.MongoTemplate.findById(MongoTemplate.java:471) at com.sejda.persistence.MongoTestEnum.testInsertAndRetrieve(MongoTestEnum.java:37) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.sejda.persistence.MongoTestEnum$ImAnEnum$1]: Illegal arguments for constructor; nested exception is java.lang.IllegalArgumentException: Cannot reflectively create enum objects at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:137) at org.springframework.data.mapping.model.BeanWrapper.<init>(BeanWrapper.java:120) ... 45 more Caused by: java.lang.IllegalArgumentException: Cannot reflectively create enum objects at java.lang.reflect.Constructor.newInstance(Constructor.java:511) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126) ... 46 more {code}
    via by Andrea Vacondio,
    • org.springframework.data.mapping.model.MappingInstantiationException: Could not instantiate bean class [com.mycompany.catalog.Transaction]: Illegal arguments for constructor; nested exception is java.lang.IllegalArgumentException: argument type mismatch at org.springframework.data.convert.ReflectionEntityInstantiator.createInstance(ReflectionEntityInstantiator.java:77) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:230) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:210) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:174) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:170) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:73) at org.springframework.data.mongodb.core.MongoTemplate$ReadDbObjectCallback.doWith(MongoTemplate.java:1718) at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:1441) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1244) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1233) at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:471) at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:466) at com.mycompany.catalog.repositories.AbstractRepositoryCustomMongo.findByQueryPageable(AbstractRepositoryCustomMongo.java:35) at com.mycompany.catalog.repositories.TransactionRepositoryCustomMongo.findByProduct(TransactionRepositoryCustomMongo.java:64) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:334) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:309) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at $Proxy26.findByProduct(Unknown Source) at com.mycompany.catalog.repositories.TransactionRepositoryTest.testFindByProduct(TransactionRepositoryTest.java:49) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.junit.runner.JUnitCore.run(JUnitCore.java:157) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:62) Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.mycompany.catalog.Transaction]: Illegal arguments for constructor; nested exception is java.lang.IllegalArgumentException: argument type mismatch at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:158) at org.springframework.data.convert.ReflectionEntityInstantiator.createInstance(ReflectionEntityInstantiator.java:75) ... 47 more Caused by: java.lang.IllegalArgumentException: argument type mismatch at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147) ... 49 more

    Users with the same issue

    Unknown visitor1 times, last one,
    tvrmsmith
    21 times, last one,
    Unknown visitor1 times, last one,
    Nikolay Rybak
    2 times, last one,
    Unknown visitor1 times, last one,
    21 more bugmates