`
ding43930053
  • 浏览: 41587 次
社区版块
存档分类
最新评论

org.springframework.beans.factory.BeanCreationException异常产生的原因和解决方案

 
阅读更多
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext

resource [/WEB-INF/applicationContext.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError:

org/apache/commons/pool/impl/GenericObjectPool
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getDeclaredConstructor(Unknown Source)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate

(SimpleInstantiationStrategy.java:54)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean

(AbstractAutowireCapableBeanFactory.java:752)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance

(AbstractAutowireCapableBeanFactory.java:717)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean

(AbstractAutowireCapableBeanFactory.java:386)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton

(DefaultSingletonBeanRegistry.java:155)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons

(DefaultListableBeanFactory.java:291)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:245)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:18
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:987)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:909)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:495)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:28
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2009-10-28 16:14:57 org.apache.catalina.core.Standa啊ror listenerStart



该异常产生的原因:
是因为在将spring框架和hibernate框架进行整合的时候,包冲突所引起的,这个bug在myeclipse6.0的时候就开始产生了,产生冲突的两

个.jar文件是:asm.jar和asm-2.2.3.jar的冲突造成的。

解决方案:视频上说删除asm-2.2.3.jar即可正常运行!
但是我在我的机器删除了以后,却一直还是报上面的错:org.springframework.beans.factory.BeanCreationException: Error creating

bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Instantiation of bean

failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool

后来我去我的lib目录下又删除了很多的名字相似的.jar文件(删除了能有5,6个.jar文件)但是还是报上面的错,刺激了!


下一步又去接着看视频,寻找蛛丝马迹,突然发现我用的是myeclipse6.1,hibernate只支持到3.1,而视频上用的是myeclipse6.5,支持到

hibernate3.2,所以就去网上下载了myeclipse6.5,安装后,又新建了一个项目,将前面项目的相关文件都给拷贝过来(因为.jar文件不同,所

以前面那个项目是不能直接用了),又部署了项目以后,果然是高版本的功能全,报的错都比较有针对性!

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in

ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is

java.io.FileNotFoundException: class path resource [com.oristand.bean.User.hbm.xml] cannot be opened because it does not

exist
Caused by: java.io.FileNotFoundException: class path resource [com.oristand.bean.User.hbm.xml] cannot be opened because it

does not exist

分析错误才发现是:
  1. <property name="mappingResources">
  2. <list>
  3. <value>com.oristand.bean.User.hbm.xml</value>
  4. </list>
  5. </property>
复制代码
改为:
  1. <property name="mappingResources">
  2. <list>
  3. <value>com/oristand/bean/User.hbm.xml</value>
  4. </list>
  5. </property>
复制代码
再次部署运行:又出现下面的错,更刺激了:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in

ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is

java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;

[Ljava/lang/String;Ljava/lang/StringV
Caused by: java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;

[Ljava/lang/String;Ljava/lang/StringV

这时候再删除相应的asm-2.2.3.jar,再次部署运行,

成功了!!!!!!!!!!!!!!!!!!!!!!
分享到:
评论

相关推荐

    org.springframework.transaction-3.1.2.RELEASE.zip

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.interceptor.TransactionInterceptor#0': Error setting property values; nested ...

    org.springframework.web.servlet-3.0.1.RELEASE-A.jar

    nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userController' defined in ServletContext resource [/WEB-INF/springMVC-servlet.xml]: Error ...

    hibernate错误解决方案

    这些错误包括但不限于 `org.springframework.orm.ObjectRetrievalFailureException`、`org.springframework.beans.factory.BeanCreationException` 和 `org.springframework.dao.InvalidDataAccessApiUsageException...

    spring boot exception handler.zip

    《Spring Boot异常处理器详解》 在Java开发领域,Spring Boot以其简洁、高效的特性深受开发者喜爱。在实际项目中,处理异常是必不可少的一部分,Spring Boot为此提供了强大的异常处理机制。本篇将深入探讨Spring ...

    解决SpringDataJPA报错:org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null w

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/...

    springAOP demo 带错误解决文档

    在搭建spring项目时通常需要这些jar包 ...org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace ...

    基于springboot+mybatis实现的外卖订餐系统源码+项目说明(毕设).zip

    nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure...

    struts2驱动包

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested ...

    关于springboot我出过的那些错误.docx

    错误五:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping' 错误原因:...

    com.springsource.org.objectweb.asm-3.2.0.jar

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customAreaService' defined in class path resource [applicationContext.xml]: Initialization of bean failed;...

    asm5.0.jar

    2013-08-12 14:33:37.672:WARN::Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in URL [file:/E:/cloudwave-core/src/main/...

    java异常解决方案.docx

    * org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'biz' defined in class path... + 解决方案:检查 Spring 的 Bean 定义,是否存在语法错误或格式不正确的问题,尝试...

    spring框架进行简单的增加操作出现的错误,解决方法

    Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class ...

    Maven解决jar冲突调试步骤

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'shiroFilter' defined in ServletContext resource [/WEB-INF/spring/tbm_web_shiro.xml]: Cannot resolve reference to...

    SSH整合项目中容易出现的错误

    Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating...

    Spring基于注释(Annotation)的配置.pdf

    &lt;bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/&gt; ``` **示例**: ```java @Autowired private Car car; ``` 在此示例中,Spring容器将尝试查找类型为`Car`的...

    框架集合错误解决方案

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/applicationContext ``` **问题描述:** 这是由于Spring在...

    ssmDemo1:SSM框架整合练习项目 来自《2017-7黑马49期web》

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in file [F:\IdeaProjects\ssmDemo1\out\artifacts\ssmDemo1_war_exp

    JAVA定时器JAVA定时器.pdf

    * 在&lt;Beans&gt;中不能够设置default-autowire="byName"的属性,否则后台会报org.springframework.beans.factory.BeanCreationException错误。 JAVA定时器是一种基于Quartz框架的任务调度器,用于在指定的时间执行特定...

Global site tag (gtag.js) - Google Analytics