com.tc.exception.TCRuntimeException: java.lang.IllegalArgumentException: Cannot reflectively create enum objects

Terracotta | sachin | 1 decade ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    Error in DSO : Cannot reflectively create enum objects

    Terracotta | 1 decade ago | sachin
    com.tc.exception.TCRuntimeException: java.lang.IllegalArgumentException: Cannot reflectively create enum objects
  2. 0

    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}

    Spring JIRA | 5 years ago | Andrea Vacondio
    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
  3. 0

    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}

    Spring JIRA | 5 years ago | Andrea Vacondio
    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
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    OSGi Terminal - Does not work in vanilla Karaf 2.3.7

    GitHub | 3 years ago | davsclaus
    java.security.PrivilegedActionException: java.io.IOException
  6. 0

    @DateTimeFormat(pattern="yyyy-MM-dd") with Spring Mvc Rest Service gives "error 400 request syntactically incorrect"

    Stack Overflow | 2 years ago
    org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type @org.springframework.web.bind.annotation.RequestParam @org.springframework.format.annotation.DateTimeFormat java.util.Date for value '2010-10-10'; nested exception is java.lang.IllegalArgumentException
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.IllegalArgumentException

    Cannot reflectively create enum objects

    at java.lang.reflect.Constructor.newInstance()
  2. Java RT
    Constructor.newInstance
    1. java.lang.reflect.Constructor.newInstance(Constructor.java:492)
    1 frame
  3. com.tc.object
    TCObjectPhysical.resolveReference
    1. com.tc.object.TCObjectFactoryImpl.getNewPeerObject(TCObjectFactoryImpl.java:81)
    2. com.tc.object.TCObjectFactoryImpl.getNewPeerObject(TCObjectFactoryImpl.java:72)
    3. com.tc.object.TCObjectFactoryImpl.getNewPeerObject(TCObjectFactoryImpl.java:65)
    4. com.tc.object.ClientObjectManagerImpl.createNewPeer(ClientObjectManagerImpl.java:655)
    5. com.tc.object.ClientObjectManagerImpl.createNewPeer(ClientObjectManagerImpl.java:645)
    6. com.tc.object.TCObjectImpl.createPeerObjectIfNecessary(TCObjectImpl.java:148)
    7. com.tc.object.TCObjectImpl.hydrate(TCObjectImpl.java:89)
    8. com.tc.object.ClientObjectManagerImpl.lookup(ClientObjectManagerImpl.java:321)
    9. com.tc.object.ClientObjectManagerImpl.lookupObject(ClientObjectManagerImpl.java:251)
    10. com.tc.object.TCObjectPhysical.resolveReference(TCObjectPhysical.java:101)
    10 frames
  4. com.geodesiconline.xmpp
    XMPPController.onMessage
    1. com.geodesiconline.xmpp.Resource.__tc_getresourceState(Resource.java)
    2. com.geodesiconline.xmpp.Resource.__tc_wrapped_getResourceState(Resource.java:82)
    3. com.geodesiconline.xmpp.Resource.getResourceState(Resource.java)
    4. com.geodesiconline.xmpp.handler.AbstractHandler.getResources(AbstractHandler.java:238)
    5. com.geodesiconline.xmpp.handler.AsynchronousStanzaHandler.writeToAvailableResources(AsynchronousStanzaHandler.java:520)
    6. com.geodesiconline.xmpp.handler.Subscribe.processInboundStanza(Subscribe.java:163)
    7. com.geodesiconline.xmpp.handler.AsynchronousStanzaHandler.processStanza(AsynchronousStanzaHandler.java:217)
    8. com.geodesiconline.xmpp.handler.StanzaHandler.processElement(StanzaHandler.java:124)
    9. com.geodesiconline.xmpp.handler.AbstractHandler.handleStanza(AbstractHandler.java:134)
    10. com.geodesiconline.xmpp.XMPPController.routeStanzas(XMPPController.java:1969)
    11. com.geodesiconline.xmpp.XMPPController.process(XMPPController.java:900)
    12. com.geodesiconline.xmpp.XMPPController.processData(XMPPController.java:717)
    13. com.geodesiconline.xmpp.XMPPController.messageReceived(XMPPController.java:295)
    14. com.geodesiconline.xmpp.XMPPController.onMessage(XMPPController.java:1061)
    14 frames
  5. com.geodesiconline.mjms
    MJmsTopic$Notifier.run
    1. com.geodesiconline.mjms.MJmsMessageConsumer.onMessage(MJmsMessageConsumer.java:40)
    2. com.geodesiconline.mjms.MJmsTopicSubscriber.onMessage(MJmsTopicSubscriber.java:63)
    3. com.geodesiconline.mjms.MJmsTopic.notifySubscribers(MJmsTopic.java:283)
    4. com.geodesiconline.mjms.MJmsTopic$Notifier.run(MJmsTopic.java:79)
    4 frames
  6. Java RT
    Thread.run
    1. java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
    2. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
    3. java.lang.Thread.run(Thread.java:595)
    3 frames