javaSSH框架错误解析.docx

上传人:b****8 文档编号:30647594 上传时间:2023-08-18 格式:DOCX 页数:44 大小:32.38KB
下载 相关 举报
javaSSH框架错误解析.docx_第1页
第1页 / 共44页
javaSSH框架错误解析.docx_第2页
第2页 / 共44页
javaSSH框架错误解析.docx_第3页
第3页 / 共44页
javaSSH框架错误解析.docx_第4页
第4页 / 共44页
javaSSH框架错误解析.docx_第5页
第5页 / 共44页
点击查看更多>>
下载资源
资源描述

javaSSH框架错误解析.docx

《javaSSH框架错误解析.docx》由会员分享,可在线阅读,更多相关《javaSSH框架错误解析.docx(44页珍藏版)》请在冰豆网上搜索。

javaSSH框架错误解析.docx

javaSSH框架错误解析

一2

二SSH架构易出现的问题之Errorcreatingbeanwithname'*'definedinfile[*.xml]2

三3

四、SSH常遇见问题,缺包8

五、Spring的常见错误分析10

spring的又一个问题12

六、SSH整合项目中容易出现的错误整理13

七、ssh2框架易出现的错误17

八、hibernate面对几个错误的解决关键19

Stringhql="fromStationInfoawherea.stationCodelike'%"+stCode+"%'";

注意:

hql中StationInfo不是对应数据库中的表,而是对应值对象即:

hibernate的映射类文件,org.bean.StationInfo类

 

二SSH架构易出现的问题之Errorcreatingbeanwithname'*'definedinfile[*.xml]

org.apache.jasper.JasperException:

Errorcreatingbeanwithname'indexall'definedinfile[E:

\eclipse\Tomcat5.5\webapps\fc\WEB-INF\beans.xml]:

Errorsettingpropertyvalues;

nestedexceptionisorg.springframework.beans.NotWritablePropertyException:

Invalidproperty'newsdao'ofbeanclass[org.fc.classes.indexall]:

Beanproperty'newsdao'isnotwritableorhasaninvalidsettermethod:

Doestheparametertypeofthesettermatchthereturntypeofthegetter?

这是一个很头痛的问题,基本解决方法有以下两种:

1,如上面提示在定义的ACTION方法里没写GET,SET方法或者是方法写的不规范

解决方法:

按如下编写看看能否解决.

Beasn.xml文件部分//此文件是SPRING的配置文件

//注册indexall这个ACTION

//newsdao为此ACTION调用的DAO文件

//注册newsdao

//最后必须在userDAOProxy中注册

*********************************************

*********************************************

Indexall这个ACTION文件部分必须定义newsdao的GET,SET方法如下

privateNewsdaonewsdao;

publicNewsdaogetnewsdao(){

returnnewsdao;

}

publicvoidsetnewsdao(Newsdaonewsdao){

this.newsdao=newsdao;

}

请大家注意下划线的变量,相同颜色的名字必须一致,不可有大小写错误!

2.TOMCAT版本的问题.本人一次用TOMCAT5.0编写,出现了上面的问题,结果是怎么都解决不了,后来换成了TOMCAT5.5.就一点问题都没有了,所以第一种办法解决不了的请用此法看看,换个TOMCAT版本也许能解决问题,不过只对用5.0编写出问题有效哦.

1.

org.hibernate.id.IdentifierGenerationException:

idsforthisclassmustbemanuallyassignedbeforecallingsave():

原因:

元素配置不正确,元素缺少其子元素的配置。

解决方法:

元素映射了相应数据库表的主键字段,对其子元素,其中class的取值可以为increment、identity、sequence、hilo、native......等,一般取其值为native。

2.

java.lang.IllegalArgumentException:

idtoloadisrequiredforloading

方案:

Usersuser=(Users)this.getHibernateTemplate().get(Users.class,id);如果以用户名为参数不能用此方法

3.

org.springframework.dao.InvalidDataAccessResourceUsageException:

couldnotexecutequery;nestedexceptionisorg.hibernate.exception.SQLGrammarException:

couldnotexecutequery

方案:

sql语句有错误

4.

严重:

ErrorstartingstaticResources

java.lang.IllegalArgumentException:

DocumentbaseD:

\ProgramFiles\ApacheSoftwareFoundation\Tomcat5.0\webapps\tomcat-docsdoesnotexistorisnotareadabledirectory

严重:

ErrorinresourceStart()

2007-6-623:

32:

25org.apache.catalina.core.StandardContextstart

严重:

ErrorgetConfigured

2007-6-623:

32:

25org.apache.catalina.core.StandardContextstart

严重:

Contextstartupfailedduetopreviouserrors

2007-6-623:

32:

25org.apache.catalina.core.StandardContextstart

严重:

Exceptionduringcleanupafterstartfailed

LifecycleException:

ContainerStandardContext[/tomcat-docs]hasnotbeenstarted

5.jsf+spring+hibernate

严重:

Exceptionsendingcontextinitializedeventtolistenerinstanceofclassorg.springframework.web.context.ContextLoaderListener

org.springframework.beans.factory.BeanCreationException:

Errorcreatingbeanwithname'dataSource'definedinServletContextresource[/WEB-INF/applicationContext.xml]:

Instantiationofbeanfailed;nestedexceptionisjava.lang.NoClassDefFoundError:

org/apache/commons/pool/impl/GenericObjectPool

Causedby:

java.lang.NoClassDefFoundError:

org/apache/commons/pool/impl/GenericObjectPool

严重:

ErrorlistenerStart

2007-6-810:

31:

55org.apache.catalina.core.StandardContextstart

严重:

Context[/shj01]startupfailedduetopreviouserrors

2007-6-810:

31:

55org.apache.catalina.core.ApplicationContextlog

方案:

spring-framework-2.0.5\lib\jakarta-commons下的commons-collections.jarcommons-dbcp.jarcommons-pool.jar加载到工程去

6.

严重:

Exceptionsendingcontextinitializedeventtolistenerinstanceofclasscom.sun.faces.config.ConfigureListener

javax.faces.FacesException:

Can'tparseconfigurationfile:

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的安装文件换了位置就没事了

7.springMVC+hibernate

严重:

StandardWrapper.Throwable

org.springframework.beans.factory.BeanCreationException:

Errorcreatingbeanwithname'sessionFactory'definedinServletContextresource[/WEB-INF/applicationContext.xml]:

Invocationofinitmethodfailed;nestedexceptionisjava.lang.NoSuchMethodError:

org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V

Causedby:

java.lang.NoSuchMethodError:

org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V

方案:

在使用Spring的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/EmptyVisitor

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.springMVC+hibernate

Exceptioninthread"main"org.springframework.dao.InvalidDataAccessResourceUsageException:

CouldnotexecuteJDBCbatchupdate;nestedexceptionisorg.hibernate.exception.SQLGrammarException:

CouldnotexecuteJDBCbatchupdate

Causedby:

org.hibernate.exception.SQLGrammarException:

CouldnotexecuteJDBCbatchupdate

9.

org.springframework.beans.factory.CannotLoadBeanClassException:

Errorloadingclass[org.springframework.transaction.interceptor.TransactionProxyFactoryBean]forbeanwithname'userService'definedinServletContextresource[/WEB-INF/applicationContext.xml]:

problemwithclassfileordependentclass;nestedexceptionisjava.lang.NoClassDefFoundError:

org/springframework/aop/framework/AbstractSingletonProxyFactoryBean

Causedby:

java.lang.NoClassDefFoundError:

org/springframework/aop/framework/AbstractSingletonProxyFactoryBean

方案:

没加spring2.0aoplibraries

10.

org.apache.jasper.JasperException:

UnabletocompileclassforJSP:

方案:

jsp网页中的java代码有问题

11.

Exceptioninthread"main"org.springframework.beans.factory.BeanCreationException:

Errorcreatingbeanwithname'CompanyController'definedinclasspathresource[com/company/test/company-config.xml]:

Errorsettingpropertyvalues;nestedexceptionisorg.springframework.beans.NotWritablePropertyException:

Invalidproperty'methodNameResolver'ofbeanclass[pany.action.CompanyController]:

Beanproperty'methodNameResolver'isnotwritableorhasaninvalidsettermethod.Doestheparametertypeofthesettermatchthereturntypeofthegetter?

Causedby:

org.springframework.beans.NotWritablePropertyException:

Invalidproperty'methodNameResolver'ofbeanclass[pany.action.CompanyController]:

Beanproperty'methodNameResolver'isnotwritableorhasaninvalidsettermethod.Doestheparametertypeofthesettermatchthereturntypeofthegetter?

控制器没继承MultiActionController

12.

Exceptioninthread"main"org.springframework.beans.factory.BeanCreationException:

Errorcreatingbeanwithname'turDiffService'definedinclasspathresource[com/expert/test/expert-config.xml]:

Errorsettingpropertyvalues;nestedexceptionisorg.springframework.beans.NotWritablePropertyException:

Invalidproperty'turDifficultDao'ofbeanclass[com.expert.operation.impl.TurDiffSerImpl]:

Beanproperty'turDifficultDao'isnotwritableorhasaninvalidsettermethod.Didyoumean'truDifficultDao'?

Causedby:

org.springframework.beans.NotWritablePropertyException:

Invalidproperty'turDifficultDao'ofbeanclass[com.expert.operation.impl.TurDiffSerImpl]:

Beanproperty'turDifficultDao'isnotwritableorhasaninvalidsettermethod.Didyoumean'truDifficultDao'?

原因:

在定义时TurDifficultDaoturDifficultDao,把有个字母写错,后发现错误,改过来了,但没把get()set()方法中对应的改过来

13.

Exceptioninthread"main"org.springframework.beans.factory.BeanCreationException:

Errorcreatingbeanwithname'urlMapping'definedinclasspathresource[com/expert/test/expert-config.xml]:

Initializationofbeanfailed;nestedexceptionisorg.springframework.beans.factory.NoSuchBeanDefinitionException:

Nobeannamed''isdefined

Causedby:

org.springframework.beans.factory.NoSuchBeanDefinitionException:

Nobeannamed''isdefined

原因:

在expert-config.xml中创建

没有给赋值

14.

org.springframework.orm.hibernate3.HibernateQueryException:

Instructionisnotmapped

[fromInstruction];nestedexceptionisorg.hibernate.hql.ast.QuerySyntaxException:

Instructionisnotmapped[fromInstruction]

Causedby:

org.hibernate.hql.ast.QuerySyntaxException:

Instructionisnotmapped[from

Instruction]

原因:

在data-config.xml中没加入com/serializ/Instruction.hbm.xml

15.

java.sql.SQLException:

Field'userId'doesn'thaveadefaultvalue

原因:

把配置文件的主键改为可以进行自定义主键值,因为我在设主键时没有设成自动增长的,要求填默认值是受了配置文件里的影响了。

16.org.apache.jasper.JasperException:

Unab

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 理学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1