异常:ERROR [org.hibernate.proxy.BasicLazyInitializer] - CGLIB Enhancement failed..

用MyEclipse6.0写了一个spring2.0+struts1.2+hibernate3.0的工程,在没有加入log4j.properties时运行一切正常.该配置文件加入后启动tomcat时报以下异常:
ERROR [org.hibernate.proxy.BasicLazyInitializer] - CGLIB Enhancement failed: com.movie.model.UserInfo
java.lang.ExceptionInInitializerError
 at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:116)
 at org.hibernate.proxy.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:41)
 at org.hibernate.tuple.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:161)
 at org.hibernate.tuple.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:131)
 at org.hibernate.tuple.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
 at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:64)
 at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:257)
 at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:412)
 at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:108)
..................
Caused by: java.lang.SecurityException: class "org.objectweb.asm.CodeVisitor"'s signer information does not match signer information of other classes in the same package
 at java.lang.ClassLoader.checkCerts(Unknown Source)
 at java.lang.ClassLoader.preDefineClass(Unknown Source)
 at java.lang.ClassLoader.defineClass(Unknown Source)
 at java.security.SecureClassLoader.defineClass(Unknown Source)
 at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1634)
 at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:860)
 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1307)
 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189)
 at java.lang.ClassLoader.loadClassInternal(Unknown Source)
...............等异常
log4j.properties文件配置如下:
log4j.rootLogger=WARN, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
这个是按书上的示例抄的,应该问题不大.

经过查找相关资料,
解决方案1:

删除WEB-INF/lib/asm-2.2.3.jar 然后重启 Tomcat,无效...

解决方案2:

下载asm-all-3.0.jar替换掉所有asm开头的jar包.无效...
解决方案3:

如果在lib目录下有2.13的版本,请更换为cglib-2.2_1.jar即可。重新发布项目.无效....
项目中使用了ehcache做为hibernate的缓存,ehcache-1.1.jar也导入了.

网友们说这个问题多半是因为版本不同造成的,但实在不知道该如何修改.
再有网上多是针对java.lang.NoSuchMethodError的解决方法.但我现在报的是java.lang.ExceptionInInitializerE
rror,对这些异常都不是很熟悉.希望有高人能指点下,谢谢了. 


之前遇到过类似问题.需要升级cglib-2.1.jar到2.2





用这个版本的你在试试
http://sourceforge.net/project/showfiles.php?group_id=56933&package_id=98218&release_id=419752



再有就是把HIBERNATE需要的相关jar包10个 
COPY到工程的LIB目录下
(如果你在JAVA构建路径,通过添加外部JAR包,添加了那几个必须的包,在此还要把他们COPY到工   程的LIB目录下!)





你可能感兴趣的:(java,apache,tomcat,log4j,Hibernate)