1、SSH错误集中分析注:本文非本人所写,乃是搜集了众多SSH框架中易犯的错误整理成文档,上传只为方便众网友学习;另有不足之处万请大家包涵!在此,先感谢原作者的贡献!一 2二SSH架构易出现的问题之Error creating bean with name * defined in file *.xml 2三 3四、SSH常遇见问题,缺包 8五、Spring的常见错误分析 10spring的又一个问题 12六、SSH整合项目中容易出现的错误整理 13七、ssh2框架易出现的错误 17八、hibernate面对几个错误的解决关键 19一String hql=from StationInfo a wh
2、ere a.stationCode like %+stCode + %;注意:hql中StationInfo 不是对应数据库中的表,而是对应值对象即:hibernate的映射类文件,org.bean.StationInfo 类二SSH架构易出现的问题之Error creating bean with name * defined in file *.xmlorg.apache.jasper.JasperException: Error creating bean with name indexall defined in file E:eclipseTomcat 5.5webappsfcWEB
3、-INFbeans.xml : Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property newsdao of bean class org.fc.classes.indexall: Bean property newsdao is not writable or has an invalid setter method: Does the parameter type of the setter matc
4、h the return type of the getter? 这是一个很头痛的问题,基本解决方法有以下两种:1,如上面提示在定义的ACTION方法里没写GET,SET方法或者是方法写的不规范解决方法:按如下编写看看能否解决. Beasn.xml文件部分 /此文件是SPRING的配置文件 /注册indexall这个ACTION /newsdao为此ACTION调用的DAO文件 /注册newsdao /最后必须在userDAOProxy中注册bean id=userDAOProxy * * Indexall这个ACTION文件部分必须定义newsdao的GET,SET方法如下 private
5、Newsdao newsdao; public Newsdao getnewsdao() return newsdao; public void setnewsdao(Newsdao newsdao) this.newsdao=newsdao; 请大家注意下划线的变量,相同颜色的名字必须一致,不可有大小写错误! 2. TOMCAT版本的问题.本人一次用TOMCAT5.0编写,出现了上面的问题,结果是怎么都解决不了,后来换成了TOMCAT5.5.就一点问题都没有了,所以第一种办法解决不了的请用此法看看,换个TOMCAT版本也许能解决问题,不过只对用5.0编写出问题有效哦.三1. org.hibe
6、rnate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): 原因:元素配置不正确,元素缺少其子元素的配置。解决方法:元素映射了相应数据库表的主键字段,对其子元素,其中class的取值可以为increment、identity、sequence、hilo、native.等,一般取其值为native 。 2. java.lang.IllegalArgumentException: id to load is required for loadi
7、ng 方案:Users user=(Users)this.getHibernateTemplate().get(Users.class, id);如果以用户名为参数不能用此方法 3. org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query 方案:sql语句有错误 4. 严重: Error star
8、ting static Resources java.lang.IllegalArgumentException: Document base D:Program FilesApache Software FoundationTomcat 5.0webappstomcat-docs does not exist or is not a readable directory 严重: Error in resourceStart() 2007-6-6 23:32:25 org.apache.catalina.core.StandardContext start 严重: Error getConfi
9、gured 2007-6-6 23:32:25 org.apache.catalina.core.StandardContext start 严重: Context startup failed due to previous errors 2007-6-6 23:32:25 org.apache.catalina.core.StandardContext start 严重: Exception during cleanup after start failed LifecycleException: Container StandardContext/tomcat-docs has not
10、been started 5.jsf+spring+hibernate 严重: 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 dataSource defined in ServletContext resource
11、 /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 严重: Error listenerStart 2007-6-8 10:31:55 org.a
12、pache.catalina.core.StandardContext start 严重: Context /shj01 startup failed due to previous errors 2007-6-8 10:31:55 org.apache.catalina.core.ApplicationContext log 方案:spring-framework-2.0.5libjakarta-commons下的commons-collections.jar commons-dbcp.jar commons-pool.jar加载到工程去 6. 严重: Exception sending c
13、ontext initialized event to listener instance of class com.sun.faces.config.ConfigureListener javax.faces.FacesException: Cant parse configuration file:jar:file:/E:/工具/apache-tomcat-6.0.9/apache-tomcat-6.0.9/webapps/jsf02/WEB-INF/lib/jsf-impl.jar!/com/sun/faces/standard-html-renderkit.xml 方案:把tomcat
14、的安装文件换了位置就没事了 7.spring MVC+hibernate 严重: StandardWrapper.Throwable 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
15、.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V Caused by: java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V 方案: 在使用Sprin
16、g的AOP编程时,会用到这几个lib: asm-2.2.2.jar asm-commons-2.2.2.jar asm-util-2.2.2.jar Hibernate使用如果lib: asm.jar asm-attrs.jar 其中asm-2.2.2.jar与asm.jar存在类上的冲突! 使用其中之一或两者都使用,可能会出现如下错误: java.lang.NoClassDefFoundError: org/objectweb/asm/CodeVisitor java.lang.NoClassDefFoundError: org/objectweb/asm/commons/EmptyVisi
17、tor java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit。 解决办法是: 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 8.spring MVC+hibernate Exception in thread main org.springfr
18、amework.dao.InvalidDataAccessResourceUsageException: Could not execute JDBC batch update; nested exception is org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update Caused by: org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update 9. org.springfram
19、ework.beans.factory.CannotLoadBeanClassException: Error loading class org.springframework.transaction.interceptor.TransactionProxyFactoryBean for bean with name userService defined in ServletContext resource /WEB-INF/applicationContext.xml: problem with class file or dependent class; nested exceptio
20、n is java.lang.NoClassDefFoundError: org/springframework/aop/framework/AbstractSingletonProxyFactoryBean Caused by: java.lang.NoClassDefFoundError: org/springframework/aop/framework/AbstractSingletonProxyFactoryBean 方案:没加 spring 2.0 aop libraries 10. org.apache.jasper.JasperException: Unable to comp
21、ile class for JSP: 方案:jsp网页中的java代码有问题 11. Exception in thread main org.springframework.beans.factory.BeanCreationException: Error creating bean with name CompanyController defined in class path resource com/company/test/company-config.xml: Error setting property values; nested exception is org.spri
22、ngframework.beans.NotWritablePropertyException: Invalid property methodNameResolver of bean class pany.action.CompanyController: Bean property methodNameResolver is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? Caused by: org
23、.springframework.beans.NotWritablePropertyException: Invalid property methodNameResolver of bean class pany.action.CompanyController: Bean property methodNameResolver is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? 控制器没继承Mul
24、tiActionController 12. Exception in thread main org.springframework.beans.factory.BeanCreationException: Error creating bean with name turDiffService defined in class path resource com/expert/test/expert-config.xml: Error setting property values; nested exception is org.springframework.beans.NotWrit
25、ablePropertyException: Invalid property turDifficultDao of bean class com.expert.operation.impl.TurDiffSerImpl: Bean property turDifficultDao is not writable or has an invalid setter method. Did you mean truDifficultDao? Caused by: org.springframework.beans.NotWritablePropertyException: Invalid prop
26、erty turDifficultDao of bean class com.expert.operation.impl.TurDiffSerImpl: Bean property turDifficultDao is not writable or has an invalid setter method. Did you mean truDifficultDao? 原因: 在定义时TurDifficultDao turDifficultDao ,把有个字母写错,后发现错误,改过来了,但没把get() set()方法中对应的改过来 13. Exception in thread main o
27、rg.springframework.beans.factory.BeanCreationException: Error creating bean with name urlMapping defined in class path resource com/expert/test/expert-config.xml: Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named is defi
28、ned Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named is defined 原因: 在expert-config.xml中创建 没有给赋值 14. org.springframework.orm.hibernate3.HibernateQueryException: Instruction is not mapped from Instruction; nested exception is org.hibernate.hql.ast.QuerySyntaxEx
29、ception: Instruction is not mapped from Instruction Caused by: org.hibernate.hql.ast.QuerySyntaxException: Instruction is not mapped from Instruction 原因:在data-config.xml中没加入com/serializ/Instruction.hbm.xml 15. java.sql.SQLException: Field userId doesnt have a default value 原因:把配置文件的主键改为 可以进行自定义主键值,因为我在设主键时没有设成自动增长的,要求填默认值是受了配置文件里g
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1