Project start times wrong instantiation of Bean failed; Nested exception is Java.lang.ExceptionInInitializerError

Source: Internet
Author: User
Tags addchild

Problem Details:

When starting the project, error:
Org.springframework.beans.factory.BeanCreationException:Error creating Bean with Name ' Searchipattributionservice ' defined in file [***\service\searchipattributionservice.class]:
Instantiation of Bean failed; Nested exception is Java.lang.ExceptionInInitializerErrorat 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.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext ( frameworkservlet.java:651) at Org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext ( frameworkservlet.java:599) at Org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext ( frameworkservlet.java:665) at Org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext ( frameworkservlet.java:518) at Org.springframework.web.servlet.FrameworkServlet.initServletBean ( frameworkservlet.java:459) at ORG.SPRINGFRamework.web.servlet.HttpServletBean.init (httpservletbean.java:136) at Javax.servlet.GenericServlet.init ( genericservlet.java:158) at Org.apache.catalina.core.StandardWrapper.initServlet (standardwrapper.java:1284) at Org.apache.catalina.core.StandardWrapper.loadServlet (standardwrapper.java:1197) at Org.apache.catalina.core.StandardWrapper.load (standardwrapper.java:1087) at Org.apache.catalina.core.StandardContext.loadOnStartup (standardcontext.java:5266) at Org.apache.catalina.core.StandardContext.startInternal (standardcontext.java:5554) at Org.apache.catalina.util.LifecycleBase.start (lifecyclebase.java:150) at Org.apache.catalina.core.ContainerBase.addChildInternal (containerbase.java:901) at Org.apache.catalina.core.ContainerBase.addChild (containerbase.java:877) at Org.apache.catalina.core.StandardHost.addChild (standardhost.java:652) at Org.apache.catalina.startup.HostConfig.deployDirectory (hostconfig.java:1263) at Org.apache.catalina.startup.hostconfig$deploydirectory.run (hostconfig.java:1948) at JAva.util.concurrent.executors$runnableadapter.call (executors.java:471) at Java.util.concurrent.FutureTask.run ( futuretask.java:262) at Java.util.concurrent.ThreadPoolExecutor.runWorker (threadpoolexecutor.java:1145) at Java.util.concurrent.threadpoolexecutor$worker.run (threadpoolexecutor.java:615) at Java.lang.Thread.run ( thread.java:744) caused By:java.lang.ExceptionInInitializerErrorat 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:526) at Org.springframework.beans.BeanUtils.instantiateClass (beanutils.java:148) at Org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate ( simpleinstantiationstrategy.java:87) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantIatebean (abstractautowirecapablebeanfactory.java:1006) ... Morecaused By:java.lang.NullPointerExceptionat ***.service. Searchipattributionservice.load (searchipattributionservice.java:133) at ***.service. Searchipattributionservice.load (searchipattributionservice.java:66) at ***.service. Searchipattributionservice.<clinit> (searchipattributionservice.java:28) ... More

Resolution process:

1, check the configuration, repeatedly looked at many times, confirmed that there is no problem.

2, the Internet to find a lot of information, a lot of similar problems, after reading the answer is still not its essentials. I had to keep reading the wrong code until I saw this sentence:

caused By:java.lang.NullPointerExceptionat ***.service. Searchipattributionservice.load (searchipattributionservice.java:133) at ***.service. Searchipattributionservice.load (searchipattributionservice.java:66) at ***.service. Searchipattributionservice.<clinit> (searchipattributionservice.java:28)

The problem should be on its own code, but I remember that the code was tested, no problem. However, there is no other way, you can only follow the hint to find the problem in one step. Finally, the problem is the code. When spring instantiates this class, the null pointer error is reported when a static method is first executed, and a class is not instantiated.

Lessons learned:

1, solve problems, not impatient, to calm, calm, calm.

2, carefully read the wrong information.

3, every time you modify the code, you should remember to test, to ensure that the changes are correct.

Project start times wrong instantiation of Bean failed; Nested exception is Java.lang.ExceptionInInitializerError

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.