原文引自:http://blog.sina.com.cn/s/reader_53edf7c101009gy3.html
1.
org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save():
原因:<id>元素配置不正確,<id>元素缺少其子元素<generator></generator>的配置。解決方法:<id>元素映射了相應數據庫表的主鍵字段,對其子元素<generator class="">,其中class的取值可以為increment、identity、sequence、hilo、native......等,一般取其值為native 。
2.
java.lang.IllegalArgumentException: id to load is required for loading
方案:Users user=(Users)this.getHibernateTemplate().get(Users.class, id);如果以用戶(hù)名為參數不能用此方法
3.
org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query
方案:sql語(yǔ)句有錯誤
4.
嚴重: Error starting static Resources
java.lang.IllegalArgumentException: Document base D:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\tomcat-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 getConfigured
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 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 [/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.apache.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.5\lib\jakarta-commons下的commons-collections.jar commons-dbcp.jar commons-pool.jar加載到工程去
6.
嚴重: Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener
javax.faces.FacesException: Can't 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的安裝文件換了位置就沒(méi)事了
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.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
方案:
在使用Spring的AOP編程時(shí),會(huì )用到這幾個(gè)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存在類(lèi)上的沖突?。?!
使用其中之一或兩者都使用,可能會(huì )出現如下錯誤:
java.lang.NoClassDefFoundError: org/objectweb/asm/CodeVisitor
java.lang.NoClassDefFoundError: org/objectweb/asm/commons/EmptyVisitor
java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit。。。。。。
解決辦法是:
1.去掉類(lèi)路徑上的關(guān)于Hibernate的3個(gè)lib
asm.jar
asm-attrs.jar
cglib-2.1.3.jar
2.加入Spring中的以下4個(gè)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.springframework.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.springframework.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 exception is java.lang.NoClassDefFoundError: org/springframework/aop/framework/AbstractSingletonProxyFactoryBean
Caused by: java.lang.NoClassDefFoundError: org/springframework/aop/framework/AbstractSingletonProxyFactoryBean
方案:沒(méi)加 spring 2.0 aop libraries
10.
org.apache.jasper.JasperException: Unable to compile class for JSP:
方案:jsp網(wǎng)頁(yè)中的java代碼有問(wèn)題
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.springframework.beans.NotWritablePropertyException: Invalid property 'methodNameResolver' of bean class [com.company.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.springframework.beans.NotWritablePropertyException: Invalid property 'methodNameResolver' of bean class [com.company.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?
控制器沒(méi)繼承MultiActionController
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.NotWritablePropertyException: 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 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'?
原因:
在定義時(shí)TurDifficultDao turDifficultDao ,把有個(gè)字母寫(xiě)錯,后發(fā)現錯誤,改過(guò)來(lái)了,但沒(méi)把get() set()方法中對應的改過(guò)來(lái)
13.
Exception in thread "main" org.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 defined
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named '' is defined
原因:
在expert-config.xml中創(chuàng )建
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key=""></prop>
</props>
</property>
</bean>
沒(méi)有給<prop key=""></prop>賦值
14.
org.springframework.orm.hibernate3.HibernateQueryException: Instruction is not mapped
[from Instruction]; nested exception is org.hibernate.hql.ast.QuerySyntaxException:
Instruction is not mapped [from Instruction]
Caused by: org.hibernate.hql.ast.QuerySyntaxException: Instruction is not mapped [from
Instruction]
原因:在data-config.xml中沒(méi)加入<value>com/serializ/Instruction.hbm.xml</value>
15.
java.sql.SQLException: Field 'userId' doesn't have a default value
原因:把配置文件的主鍵改為<generator class="assigned" /> 可以進(jìn)行自定義主鍵值,因為我在設主鍵時(shí)沒(méi)有設成自動(dòng)增長(cháng)的,要求填默認值是受了配置文件里<generator class="native"/>的影響了。
16.org.apache.jasper.JasperException: Unable to compile class for JSP
原因:jsp頁(yè)面中的java代碼括號不對稱(chēng)!