SSH问题集锦

我用STRUTS1.2和和hibernet3.0,写的程序遇到的jar缺少问题,从网上搜了一些,自己再补充些,希望更多的人补充啊!


1.问题:Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException

    at HibernateTest.main(HibernateTest.java:14)

方法:添加dom4j.jar(解析hibernate.cfg.xml文件)



2.问题:Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory

    at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:116)

    at HibernateTest.main(HibernateTest.java:14)

方法:添加commons-logging.jar(记录解析过程)



3.问题:Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/collections/SequencedHashMap

方法:添加commons-collections.jar(在解析映射文件时,需要把所有持久化对象的定义放在一个HashMap中)



4.问题:Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException

方法:添加ehcache.jar(高速缓存,提高存取速度)



5.问题:2009-2-22 23:45:40 net.sf.ehcache.config.Configurator configure

警告: No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/F:/MyJava/Hibernate/lib/ehcache-1.1.jar!/ehcache-failsafe.xml

Exception in thread "main" java.lang.NoClassDefFoundError

方法:把ehcache-1.1.jar解压,把其中的ehcache-failsafe.xml改成ehcache.xml。



6.问题:Caused by: java.lang.ClassNotFoundException: net.sf.cglib.transform.impl.InterceptFieldEnabled

方法:添加cglib-full-2.0.02.jar



7.问题:Caused by: java.lang.NoSuchMethodError: net.sf.cglib.proxy.Enhancer.setInterceptDuringConstruction(Z)V

方法:添加cglib-nodep-2.1_3.jar



8.问题:Exception in thread "main" java.lang.NoClassDefFoundError: javax/transaction/Synchronization

方法:添加jta.jar(事务处理)




9.问题:Exception in thread "main" java.lang.NoClassDefFoundError: antlr/ANTLRException

方法:添加antlr-2.7.5h3.jar



10问题:Caused by: java.sql.SQLException: The statement (1) has no open cursor.

    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2901)

    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:773)

方法: <!-- <property name="jdbc.fetch_size">50 </property>  -->
把上面这个属性按上面这样注释掉就可以了. (如果mysql-connector的版本早于3.2.1而且服务器的版本早于5.0.3,"setFetchSize()"是没有效果的.)

11问题:java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer
2009-09-16 2:15
由MyEclipse自动导入的Spring,Hibernate,Struts 类库

发布到Tomcat发现问题:

java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer

随之 sessionFactory bean 也就创建失败

究其原因是 cglib-2.1.3.jar 与 cglib-nodep-2.1_3.jar 这两个包冲突,

删除 cglib-2.1.3.jar

保留 cglib-nodep-2.1_3.jar

要用 cglib-nodep-2.1_3.jar , 对应 spring 版本2.5

12问题:Caused by: java.lang.SecurityException: class "org.yh.vo.Money$$EnhancerByCGLIB$$4c50d3c2"'s signer
information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(ClassLoader.java:775)
at java.lang.ClassLoader.preDefineClass(ClassLoader.java:487)
at java.lang.ClassLoader.defineClass(ClassLoader.java:614)
... 43 more

把MYECLIPSE自带的commons-beanutils.jar去掉,从apache官网下载最新的jar包

13问题:org.apache.commons.collections.SequencedHashMap"'s signer information does not match signer informationf错误解


当Web层和Struts整合后,就抛出如下异常:

%%%% Error Creating SessionFactory %%%%  java.lang.SecurityException: class "org.apache.commons.collections.SequencedHashMap"'s signer information does not match signer information of other classes in the same package





解决方案:

1)下载 MyEclipse 6.0.1 来开发;

2)或者去http://commons.apache.org/collections/ 下载一个新的包,把原来的commons-collections-xxx.jar给删了,然后用新的包替换。注意:一定要到应用的发布目录去做这个工作,而且替换后不能重新发布应用,然后立即重启Tomcat再测试。

如果再报下面的错误:
ERROR [org.hibernate.proxy.BasicLazyInitializer] - CGLIB Enhancement failed: dao.User
java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
at net.sf.cglib.core.ClassEmitter.begin_class(ClassEmitter.java:77)
则是:
Spring 和 Hibernate 共用的一些 jar 文件发生了版本冲突, 删除 WEB-INF/lib/asm-2.2.3.jar即可

14问题: Hibernate异常:java.lang.NoClassDefFoundError: org/objectweb/asm/Type

加入asm.jar包

你可能感兴趣的:(ssh)