title: Spring threw nested exception java.lang.ExceptionInInitializerError
body: <p>I defined bookingEngineDao bean in my config property file as below in scope as a autowired </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!--Repository and Service layers--&gt;
  &lt;beans  xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:p="http://www.springframework.org/schema/p" 
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:tx="http://www.springframework.org/schema/tx" 
      xmlns:mongo="http://www.springframework.org/schema/data/mongo"
      xsi:schemaLocation="http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/data/jpa 
            http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
            http://www.springframework.org/schema/tx 
            http://www.springframework.org/schema/tx/spring-tx.xsd
            http://www.springframework.org/schema/data/mongo
            http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
            http://www.springframework.org/schema/context 
            http://www.springframework.org/schema/context/spring-context.xsd"&gt;
  
  &lt;!-- ========================= RESOURCE DEFINITIONS ========================= --&gt;
  
  &lt;!--add data access property file--&gt;
  &lt;context:property-placeholder location="classpath:spring/data-access.properties" system-properties-mode="OVERRIDE"/&gt;
  
  &lt;!--Add Base Package--&gt;
  &lt;context:component-scan base-package="com.linklk.ticketslk.backend.logic.handler"/&gt;
  &lt;context:component-scan base-package="com.link.booking.engine.resources"/&gt;
  &lt;!--&lt;context:component-scan base-package="com.link.booking.engine.mongo"/&gt;--&gt;
  
  &lt;tx:annotation-driven /&gt;
  
  &lt;!--Add classes which we need as a new Objects with object id--&gt;
  &lt;bean id="appHelper" class="com.linklk.ticketslk.util.AppHelper"/&gt;
  &lt;bean id="response" class="com.linklk.ticketslk.util.RestServiceResponse"/&gt;
  &lt;bean id="data" class="com.linklk.ticketslk.domain.data.Data"/&gt;
  &lt;bean id="customException" class="com.linklk.ticketslk.exception.ServiceException"/&gt;
  
  &lt;bean id="eventServiceManager" class="com.linklk.ticketslk.backend.logic.handler.EventServiceManagerImpl"/&gt;
  &lt;bean id="venueServiceManager" class="com.linklk.ticketslk.backend.logic.handler.VenueServiceManagerImpl"/&gt;
  &lt;bean id="eventVenueTimeServiceManager" class="com.linklk.ticketslk.backend.logic.handler.EventVenueTimeServiceManagerImpl"/&gt;
  &lt;bean id="eventTicketTypeServiceManager" class="com.linklk.ticketslk.backend.logic.handler.EventTicketTypeServiceManagerImpl"/&gt;
  &lt;bean id="eventTypeServiceManager" class="com.linklk.ticketslk.backend.logic.handler.EventTypeServiceManagerImpl"/&gt;
  &lt;bean id="locationServiceManager" class="com.linklk.ticketslk.backend.logic.handler.LocationServiceManagerImpl"/&gt;
  &lt;bean id="sessionDetailServiceManager" class="com.linklk.ticketslk.backend.logic.handler.SessionDetailServiceManagerImpl"/&gt;
  &lt;bean id="venueWorkDaysServiceManager" class="com.linklk.ticketslk.backend.logic.handler.VenueWorkDaysServiceManagerImpl"/&gt;
  
  &lt;bean id="bookingEngineDao" class="com.linklk.ticketslk.booking.engine.dao.BookingEngineDaoImpl"/&gt;
  
  &lt;!-- START BOOKING ENGINE DEPENDENCIES --&gt;
  
  &lt;bean id="resourceDefinition" class="com.link.booking.engine.dto.ResourceDefinition" scope="prototype"/&gt;
  &lt;bean id="bookingHelper" class="com.link.booking.engine.util.BookingHelper"/&gt;
  &lt;bean id="priceCalculation" class="com.link.booking.engine.util.PriceCalculation" scope="prototype"/&gt;
  
  &lt;bean id="linkBookingEngine" class="com.link.booking.engine.initiator.LinkBookingEngine" scope="prototype"/&gt;
  
  &lt;bean id="linkBookableResource" class="com.link.booking.engine.resources.LinkBookableResource" scope="prototype"/&gt;
  
  &lt;!--Layer Implementation beans--&gt;
  &lt;bean id="groupResourcesImpl" class="com.link.booking.engine.layers.GroupResourcesImpl" scope="prototype"/&gt;
  
  &lt;bean id="userTypeResourceImpl" class="com.link.booking.engine.layers.UserTypeResourceImpl" scope="prototype"/&gt;
  
  &lt;bean id="priceResourcesImpl" class="com.link.booking.engine.layers.PriceResourcesImpl" scope="prototype"/&gt;
  &lt;!--End of Layer Implementation beans--&gt;
  
  &lt;!-- END BOOKING ENGINE DEPENDENCIES --&gt;
  
  &lt;!--Mongo db configuration. also add correspond xml namespace(xmlns) to above--&gt;
  &lt;!--Below profiles active or disabled from web.xml also can active only one profile at once--&gt;
  &lt;beans profile="mongodb"&gt;
      &lt;!--&lt;bean id="mongo" class="org.springframework.data.mongodb.core.MongoFactoryBean"&gt;--&gt;
      &lt;bean id="mongoFactoryBean" class="org.springframework.data.mongodb.core.MongoFactoryBean"&gt;
          &lt;property name="host" value="192.168.0.130" /&gt;
      &lt;/bean&gt;
      &lt;bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"&gt;
          &lt;!--&lt;constructor-arg name="mongo" ref="mongo" /&gt;--&gt;
          &lt;constructor-arg name="mongo" ref="mongoFactoryBean" /&gt;
          &lt;constructor-arg name="databaseName" value="TICKETSLK" /&gt;
      &lt;/bean&gt;
      &lt;bean id="mongoDbFactory" class="org.springframework.data.mongodb.core.SimpleMongoDbFactory"&gt;
          &lt;!--&lt;constructor-arg name="mongo" ref="mongo"/&gt;--&gt;
          &lt;constructor-arg name="mongo" ref="mongoFactoryBean"/&gt;
          &lt;constructor-arg name="databaseName" value="BOOKING_ENGINE"/&gt;
      &lt;/bean&gt;
      &lt;context:component-scan base-package="com.linklk.ticketslk.repository.mongo"/&gt;
      &lt;context:component-scan base-package="com.link.booking.engine.mongo"/&gt;
  &lt;/beans&gt;
  &lt;beans profile="jdbc"&gt;
      &lt;context:component-scan base-package="com.linklk.ticketslk.repository.jdbc"/&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p></p>
  
  <p>also i used this bean in my java code </p>
  
  <pre><code>@Autowired
  private BookingEngineDao bookingEngineDao;
  </code></pre>
  
  <p>and i used this bean for manipulate some of my resources in another java class</p>
  
  <p>when i compile it threw below error i coudnt understand the reason</p>
  
  <pre><code>ERROR 2014-04-02 12:13:09,441 ContainerBackgroundProcessor[StandardEngine[Catalina]]::ContextLoader - Context initialization failed
  DEBUG 2014-04-02 12:13:09,439 ContainerBackgroundProcessor[StandardEngine[Catalina]]::DisposableBeanAdapter - Invoking destroy() on bean with name 'mongoFactoryBean'
  ERROR 2014-04-02 12:13:09,441 ContainerBackgroundProcessor[StandardEngine[Catalina]]::ContextLoader - Context initialization failed
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bookingEngineDao' defined in class path resource [spring/business-config.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.linklk.ticketslk.booking.engine.dao.BookingEngineDaoImpl]: Constructor threw exception; nested exception is java.lang.ExceptionInInitializerError
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1013)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:959)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:490)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)
  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
  at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
  at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
  at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
  at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)
  at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3920)
  at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1271)
  at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1440)
  at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:301)
  at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
  at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
  at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1374)
  at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1530)
  at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1540)
  at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1519)
  at java.lang.Thread.run(Thread.java:722)
  Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.linklk.ticketslk.booking.engine.dao.BookingEngineDaoImpl]: Constructor threw exception; nested exception is java.lang.ExceptionInInitializerError
  at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163)
  at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1006)
  ... 27 more
  Caused by: java.lang.ExceptionInInitializerError
  at com.linklk.ticketslk.booking.engine.dao.BookingEngineDaoImpl.&lt;init&gt;(BookingEngineDaoImpl.java:27)
  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:148)
  ... 29 more
  Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'eventServiceManagerImpl' defined in file [/rcapl/apache/tomcat/webapps/ticketslk/WEB-INF/classes/com/linklk/ticketslk/backend/logic/handler/EventServiceManagerImpl.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [com.linklk.ticketslk.repository.EventRepository]: : No qualifying bean of type [com.linklk.ticketslk.repository.EventRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.linklk.ticketslk.repository.EventRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
  at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:730)
  at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:196)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1051)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:955)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:490)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)
  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
  at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:139)
  at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:83)
  at com.link.booking.engine.util.ServiceConstant.&lt;clinit&gt;(ServiceConstant.java:19)
  ... 35 more
  Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.linklk.ticketslk.repository.EventRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:986)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:856)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:768)
  at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:795)
  at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:723)
  ... 50 more
  Apr 02, 2014 12:13:09 PM org.apache.catalina.core.StandardContext startInternal
  SEVERE: Error listenerStart
  Apr 02, 2014 12:13:09 PM org.apache.catalina.core.StandardContext startInternal
  SEVERE: Context [/ticketslk] startup failed due to previous errors
  Apr 02, 2014 12:13:09 PM org.apache.catalina.core.StandardContext reload
  INFO: Reloading Context with name [/ticketslk] is completed
  </code></pre>