org.springframework.beans.factory.BeanCreationException: Could not autowire field org.springfram… [How to Solve]

Jul 01, 2019 4:34:20 PM org.apache.catalina.core.StandardContext listenerStart

…..
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘xxxxx’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.xxxDao com.xxx.service.xxxxImpl.xxxDao; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [com.xxxx.service.sys.impl.ProcEndListener] for bean with name ‘procEndListener’ defined in file [D:\EclipseWorkSpace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\xxxxxxx\WEB-INF\classes\com\xxxx\service\sys\impl\ProcEndListener.class]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/activiti/engine/delegate/TaskListener
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1122)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)
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:5099)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5615)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1571)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1561)
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:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.xxxx.mapper.kw.bm.xxxDao com.xxxx.service.bm.impl.DtypeServiceImpl.dtypeDao; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [com.xxxx.service.sys.impl.ProcEndListener] for bean with name ‘procEndListener’ defined in file [D:\EclipseWorkSpace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\xxxxxxx\WEB-INF\classes\com\xxxx\service\sys\impl\ProcEndListener.class]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/activiti/engine/delegate/TaskListener
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:514)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
… 22 more
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [com.xxxx.service.sys.impl.ProcEndListener] for bean with name ‘procEndListener’ defined in file [D:\EclipseWorkSpace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\xxxxxxx\WEB-INF\classes\com\xxxx\service\sys\impl\ProcEndListener.class]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/activiti/engine/delegate/TaskListener
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1272)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:578)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1338)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNaxxxForType(DefaultListableBeanFactory.java:356)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNaxxxForType(DefaultListableBeanFactory.java:335)
at org.springframework.beans.factory.BeanFactoryUtils.beanNaxxxForTypeIncludingAncestors(BeanFactoryUtils.java:187)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:895)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:853)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:768)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:486)
… 24 more
Caused by: java.lang.NoClassDefFoundError: org/activiti/engine/delegate/TaskListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:3175)
at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:1372)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1860)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1734)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:260)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:416)
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1290)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1261)
… 33 more
Caused by: java.lang.ClassNotFoundException: org.activiti.engine.delegate.TaskListener
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1891)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1734)
… 44 more

Just started using MyEclipse import project, start no problem, the framework Spring + mybatis, later imported to eclipse on this error, said bean was not created successfully, how to solve this problem, there are probably the following ideas: 1.

1. services or dao (here mybatis with dynamic proxy, when the server is introduced to inject the next) annotated not annotated, or the server is not annotated when the dao layer is introduced

2. Add @RequestParam to the method

3. The configuration file is not scanned, there are others you can search

….

I have tried these kinds of things here, did not solve, and finally clicked on the place where the error was reported, found that the jump can not introduce the jar package, look carefully, Referenced Libraries and lib under both, but just can not jump, and then copied the myeclipse, and then build path and then add, surprisingly not reported this error, and then reported Another error, this did not look deeper … Then I found that the package I couldn’t find was in a folder under lib, and then I moved all the packages out of the folder under lib, and then add, and it started successfully!

Reason: eclipse can’t read the jar in the folder under lib

I don’t know if this is considered a bug in eclipse, it’s fine under Myeclipse, here’s my lib directory structure!

Similar Posts: