---
title: "Spring集成Hibernate的BeanCreationException解决方法"
author: "wayne446"
date: "2009-05-12T17:58:27Z"
tags: []
slug: "spring-hibernate-beancreationexception"
draft: false
lastmod: "2009-05-18T18:03:37Z"
id: 384407
url: "https://wayne446.iteye.com/blog/384407"
---

现象：  
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener  
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService' defined in ServletContext resource \[/WEB-INF/applicationContextService.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError

问题：  
在使用Spring的AOP编程时，会用到这几个lib：  
asm-2.2.2.jar  
asm-commons-2.2.2.jar  
asm-util-2.2.2.jar

cglib-nodep-2.1\_3.jar  
Hibernate使用的lib：  
asm.jar  
asm-attrs.jar  
其中asm-2.2.2.jar与asm.jar存在类上的冲突

解决办法：  
1.去掉类路径上的关于Hibernate的3个lib  
asm.jar  
asm-attrs.jar  
cglib-2.1.3.jar  
2.加入Spring中的以下4个lib  
asm-2.2.2.jar  
asm-commons-2.2.2.jar  
asm-util-2.2.2.jar  
cglib-nodep-2.1\_3.jar