*********************************************
*********************************************
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