Encountered a problem that the class could not find at spring startup ~

Source: Internet
Author: User
Tags addchild

When you deploy an old project to TOMCAT7 today, spring initialization fails with the following error:
Java.lang.NoClassDefFoundError:org.springframework.beans.FatalBeanException

The stack information printed by the console is as follows:

[Org.springframework.web.context.contextloader]-[error]Context initialization failedjava.lang.NoClassDefFoundError:org.springframework.beans.FatalBeanExceptionAt Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.Docreatebean(abstractautowirecapablebeanfactory.java:547)
At Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean ( abstractautowirecapablebeanfactory.java:476)
At Org.springframework.beans.factory.support.abstractbeanfactory$1.getobject (abstractbeanfactory.java:303)
At Org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton ( defaultsingletonbeanregistry.java:230)
At Org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (abstractbeanfactory.java:299)
At Org.springframework.beans.factory.support.AbstractBeanFactory.getBean (abstractbeanfactory.java:194)
At Org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons ( defaultlistablebeanfactory.java:755)
At Org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization ( abstractapplicationcontext.java:757)
At Org.springframework.context.support.AbstractApplicationContext.refresh (abstractapplicationcontext.java:480)
At Org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext (Contextloader.java : 434)
At Org.springframework.web.context.ContextLoader.initWebApplicationContext (contextloader.java:306)
At Org.springframework.web.context.ContextLoaderListener.contextInitialized (contextloaderlistener.java:106)
At Org.apache.catalina.core.StandardContext.listenerStart (standardcontext.java:4738)
At Org.apache.catalina.core.StandardContext.startInternal (standardcontext.java:5181)
At Org.apache.catalina.util.LifecycleBase.start (lifecyclebase.java:150)
At Org.apache.catalina.core.ContainerBase.addChildInternal (containerbase.java:725)
At Org.apache.catalina.core.ContainerBase.addChild (containerbase.java:701)
At Org.apache.catalina.core.StandardHost.addChild (standardhost.java:717)
At Org.apache.catalina.startup.HostConfig.deployDescriptor (hostconfig.java:586)
At Org.apache.catalina.startup.hostconfig$deploydescriptor.run (hostconfig.java:1780)
At Java.util.concurrent.executors$runnableadapter.call (Unknown Source)
At Java.util.concurrent.FutureTask.run (Unknown Source)
At Java.util.concurrent.ThreadPoolExecutor.runWorker (Unknown Source)
At Java.util.concurrent.threadpoolexecutor$worker.run (Unknown source) at Java.lang.Thread.run (Unknown source)

Resolution process:

1. It is possible that the class was not added to the BuildPath or the class was not introduced correctly to the deployment path of Tomcat.

Ctrl+shift+t Search, this class was found under Spring-beans-3.2.0.release.jar this package, confirming that the jar package has been added to the project's Bulidpath.

Then go to the Tomcat Project deployment path under the view, found that the project has this jar package, the jar package decompression, there is indeed a fatalbeanexception class.

So strange that the class does exist, why do you still report errors that the class cannot find ?

2. follow the spring source to see where the exception is thrown.

  Using the Docreatebean method error described on the error message, locate the corresponding method under Spring-beans-3.2.0.release.jar and break the point on the method.

Then start with the debug mode, the program runs to the above breakpoint, step by step tracking, found the problem of the place:

Object exposedobject = bean;    try {        Populatebean (beanname, MBD, instancewrapper);        if (exposedobject! = null) {            exposedobject = Initializebean (Beanname, Exposedobject, mbd);}    }    catch (Throwable ex) {        if (ex instanceof beancreationexception && beanname.equals ((beancreationexception) ex). Getbeanname ()) {            throw (beancreationexception) ex;        }        else {
       //The Ex object here is actually a java.lang.StackOverflowError, ie: Stack overflow error. But the cue message from the console is:noclassdeffounderror. throw new Beancreationexception (Mbd.getresourcedescription (), Beanname, "initialization of Beans" Failed ", ex); } }

  Find the cause of the problem: the JVM stack setting is small, there is a stack overflow.

3. the problem is resolved by adjusting the stack memory size of the JVM at Tomcat startup.

Eclipse-->windows-->preference-->java-->install jres--> Select jdk-->edit--> Add startup Parameters-xss16m

  

Encountered a problem that the class could not find at spring startup ~

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.