java.lang.InstantiationException: boolean

Spring JIRA | Abdurehim Ablimit | 7 years ago
tip
Do you find the tips below useful? Click on the to mark them and say thanks to rafael . Or join the community to write better ones.
  1. 0

    *I have a very simple test class and it has two constructors as shown below. I also have bean definition as below.* {color:blue} public class TestSpringBean { private boolean bool; private Map<String,String> prop; public TestSpringBean(boolean b,Map<String,String> prop) { //doing the constructor job } public TestSpringBean(Map<String,String> prop) { this(true,prop); } } {color} {color:green} <bean id="mytestbean" class="org.uytech.bugtrack.appclient.TestSpringBean"> <constructor-arg type="java.util.Map" index="0"> <map> <entry><key><value>yup an entry</value></key><value>just some string</value></entry> <entry><key><value>yup an entry2</value></key><value>just some string2</value></entry> <entry><key><value>yup an entry3</value></key><value>just some string3</value></entry> <entry><key><value>yup an entry4</value></key><value>just some string4</value></entry> </map> </constructor-arg> </bean> {color} *Unless I specify the constructor-arg type (java.util.Map in this case), Spring throws exception as shown below. The same is true for java.util.Properties class. Fortunately, this is not showstopper, users can still continue.* *One workaround for this issue is to make the Map first parameter, but this not better than specifying the constructor-arg type in app context.* *I did some investigation and found this issue comes from protected Map convertToTypedMap(Map original, String propertyName, Class requiredType, TypeDescriptor typeDescriptor) in TypeConvertorDelegate class. I don't understand why this class tries to convert a map to boolean.* {color:red}java.lang.InstantiationException: boolean at java.lang.Class.newInstance0(Class.java:340) at java.lang.Class.newInstance(Class.java:308) at org.springframework.beans.TypeConverterDelegate.convertToTypedMap(TypeConverterDelegate.java:634) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:236) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:104) at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:419) at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:657) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:191) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:984) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:888) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:562) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423){color}

    Spring JIRA | 7 years ago | Abdurehim Ablimit
    java.lang.InstantiationException: boolean
  2. 0

    *I have a very simple test class and it has two constructors as shown below. I also have bean definition as below.* {color:blue} public class TestSpringBean { private boolean bool; private Map<String,String> prop; public TestSpringBean(boolean b,Map<String,String> prop) { //doing the constructor job } public TestSpringBean(Map<String,String> prop) { this(true,prop); } } {color} {color:green} <bean id="mytestbean" class="org.uytech.bugtrack.appclient.TestSpringBean"> <constructor-arg type="java.util.Map" index="0"> <map> <entry><key><value>yup an entry</value></key><value>just some string</value></entry> <entry><key><value>yup an entry2</value></key><value>just some string2</value></entry> <entry><key><value>yup an entry3</value></key><value>just some string3</value></entry> <entry><key><value>yup an entry4</value></key><value>just some string4</value></entry> </map> </constructor-arg> </bean> {color} *Unless I specify the constructor-arg type (java.util.Map in this case), Spring throws exception as shown below. The same is true for java.util.Properties class. Fortunately, this is not showstopper, users can still continue.* *One workaround for this issue is to make the Map first parameter, but this not better than specifying the constructor-arg type in app context.* *I did some investigation and found this issue comes from protected Map convertToTypedMap(Map original, String propertyName, Class requiredType, TypeDescriptor typeDescriptor) in TypeConvertorDelegate class. I don't understand why this class tries to convert a map to boolean.* {color:red}java.lang.InstantiationException: boolean at java.lang.Class.newInstance0(Class.java:340) at java.lang.Class.newInstance(Class.java:308) at org.springframework.beans.TypeConverterDelegate.convertToTypedMap(TypeConverterDelegate.java:634) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:236) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:104) at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:419) at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:657) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:191) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:984) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:888) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:562) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423){color}

    Spring JIRA | 7 years ago | Abdurehim Ablimit
    java.lang.InstantiationException: boolean
  3. 0

    *I have a very simple test class and it has two constructors as shown below. I also have bean definition as below.* {color:blue} public class TestSpringBean { private boolean bool; private Map<String,String> prop; public TestSpringBean(boolean b,Map<String,String> prop) { //doing the constructor job } public TestSpringBean(Map<String,String> prop) { this(true,prop); } } {color} {color:green} <bean id="mytestbean" class="org.uytech.bugtrack.appclient.TestSpringBean"> <constructor-arg type="java.util.Map" index="0"> <map> <entry><key><value>yup an entry</value></key><value>just some string</value></entry> <entry><key><value>yup an entry2</value></key><value>just some string2</value></entry> <entry><key><value>yup an entry3</value></key><value>just some string3</value></entry> <entry><key><value>yup an entry4</value></key><value>just some string4</value></entry> </map> </constructor-arg> </bean> {color} *Unless I specify the constructor-arg type (java.util.Map in this case), Spring throws exception as shown below. The same is true for java.util.Properties class. Fortunately, this is not showstopper, users can still continue.* *One workaround for this issue is to make the Map first parameter, but this not better than specifying the constructor-arg type in app context.* *I did some investigation and found this issue comes from protected Map convertToTypedMap(Map original, String propertyName, Class requiredType, TypeDescriptor typeDescriptor) in TypeConvertorDelegate class. I don't understand why this class tries to convert a map to boolean.* {color:red}java.lang.InstantiationException: boolean at java.lang.Class.newInstance0(Class.java:340) at java.lang.Class.newInstance(Class.java:308) at org.springframework.beans.TypeConverterDelegate.convertToTypedMap(TypeConverterDelegate.java:634) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:236) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:104) at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:419) at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:657) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:191) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:984) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:888) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:562) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423){color}

    Spring JIRA | 7 years ago | Abdurehim Ablimit
    java.lang.InstantiationException: boolean
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    *I have a very simple test class and it has two constructors as shown below. I also have bean definition as below.* {color:blue} public class TestSpringBean { private boolean bool; private Map<String,String> prop; public TestSpringBean(boolean b,Map<String,String> prop) { //doing the constructor job } public TestSpringBean(Map<String,String> prop) { this(true,prop); } } {color} {color:green} <bean id="mytestbean" class="org.uytech.bugtrack.appclient.TestSpringBean"> <constructor-arg type="java.util.Map" index="0"> <map> <entry><key><value>yup an entry</value></key><value>just some string</value></entry> <entry><key><value>yup an entry2</value></key><value>just some string2</value></entry> <entry><key><value>yup an entry3</value></key><value>just some string3</value></entry> <entry><key><value>yup an entry4</value></key><value>just some string4</value></entry> </map> </constructor-arg> </bean> {color} *Unless I specify the constructor-arg type (java.util.Map in this case), Spring throws exception as shown below. The same is true for java.util.Properties class. Fortunately, this is not showstopper, users can still continue.* *One workaround for this issue is to make the Map first parameter, but this not better than specifying the constructor-arg type in app context.* *I did some investigation and found this issue comes from protected Map convertToTypedMap(Map original, String propertyName, Class requiredType, TypeDescriptor typeDescriptor) in TypeConvertorDelegate class. I don't understand why this class tries to convert a map to boolean.* {color:red}java.lang.InstantiationException: boolean at java.lang.Class.newInstance0(Class.java:340) at java.lang.Class.newInstance(Class.java:308) at org.springframework.beans.TypeConverterDelegate.convertToTypedMap(TypeConverterDelegate.java:634) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:236) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:104) at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:419) at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:657) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:191) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:984) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:888) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:562) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423){color}

    Spring JIRA | 7 years ago | Abdurehim Ablimit
    java.lang.InstantiationException: boolean
  6. 0
    samebug tip
    This happens when you try to instantiate a class that can't be instantiated, either because the class object is abstract, an interface, an array class, a primitive type, void, or because the class has no nullary constructor.

  1. osvzs 1 times, last 3 weeks ago
  2. Andreas Häber 2 times, last 4 weeks ago
  3. filpgame 8 times, last 3 months ago
  4. tzrlk 1 times, last 6 months ago
  5. lribeiro 2 times, last 8 months ago
9 more registered users
45 unregistered visitors
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.InstantiationException

    boolean

    at java.lang.Class.newInstance0()
  2. Java RT
    Class.newInstance
    1. java.lang.Class.newInstance0(Class.java:340)
    2. java.lang.Class.newInstance(Class.java:308)
    2 frames
  3. Spring Beans
    DefaultListableBeanFactory.preInstantiateSingletons
    1. org.springframework.beans.TypeConverterDelegate.convertToTypedMap(TypeConverterDelegate.java:634)
    2. org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:236)
    3. org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:104)
    4. org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:419)
    5. org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:657)
    6. org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:191)
    7. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:984)
    8. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:888)
    9. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
    10. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
    11. org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
    12. org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    13. org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
    14. org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
    15. org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:562)
    15 frames
  4. Spring Context
    AbstractApplicationContext.finishBeanFactoryInitialization
    1. org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)
    1 frame