Sunday, January 20, 2013

Spring org.springframework.beans.BeanInstantiationException - Solved

I was working on JAX-RS and encountered with BeanInstantiationException.

Exception :
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.anuj.services.CountryServiceImpl]: Constructor threw exception; nested exception is com.anuj.common.errors.InternalServerException: Internal Server Error Occured
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:162)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:76)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:983)
    ... 41 more
Caused by: com.anuj.common.errors.InternalServerException: Internal Server Error Occured
    at com.anuj.services.CountryServiceImpl.initialize(CountryServiceImpl.java:160)
    at com.anuj.services.CountryServiceImpl.(CountryServiceImpl.java:44)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
    ... 43 more



After looking at Exception I found that Constructor of Impl(Resource) class was Throwing null exception and hence Spring was unable to initialize bean. nested exception was java.lang.NullPointerException. After solving that issue, Got expected JAX-RS Response.

Author : Anuj Patel
Blog : http://goldenpackagebyanuj.blogspot.in/

No comments:

Post a Comment