錯誤一:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: could not execute query
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:535)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:433)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
org.hibernate.exception.GenericJDBCException: could not execute query
org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
org.hibernate.loader.Loader.doList(Loader.java:2148)
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
org.hibernate.loader.Loader.list(Loader.java:2024)
org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
com.lyg.dao.MessageDAO.findAll(MessageDAO.java:142)
com.lyg.service.MessageService.findAll(MessageService.java:15)
com.lyg.struts.action.MessageAction.doAdd(MessageAction.java:43)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.20 logs.
以上是耗了一上午解決的錯誤提示,原來從數據庫返回一數據時還是成功的,只是顯示不了時間信息,后面在頁面中迭代就出現這問題,奇怪的是數據庫操作成功。開始檢查源碼,Struts,Hibernate不存在配置問題,估計問題不于此,hql也肯定沒問題,想必在于GenericJDBCException,于是便google一下能解決不。。。網上這樣的解決方法形形色色,但始終解決不了;后來請教我的高手老大,一經觀察調試,原來是數據庫數據存在問題,因mysql表列里某些Date(timestamp)類型數據為“0000-00-00 00:00”(之前insert賦空值時自動生成),但Hql取出對象數據迭代時就出現以上問題!從數據庫表中的錯誤信息刪除便完美地解決問題!(當然,出現類似問題可能存在其他因素,我這只是就本人出現的問題作解決,同時幫助遇到這方面問題的朋友)。
不斷開發,不斷發現問題解決問題。。。有空不斷補充總結
以下轉自他人的:
1.
錯誤: java.lang.NullPointerException
原因: 發現 dao 實例、 manage 實例等需要注入的東西沒有被注入
解決:這個時候,你應該查看日志文件;默認是應用服務器的 log 文件,比如 Tomcat 就是 [Tomcat 安裝目錄 ]/logs ;你會發現提示你:
可能是:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sf' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.hibernate.HibernateException: could not configure from URL: file:src/hibernate.cfg.xml
org.hibernate.HibernateException: could not configure from URL: file:src/hibernate.cfg.xml
……………………….
Caused by: java.io.FileNotFoundException: src\hibernate.cfg.xml
可能是:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: Resource: com/mcc/coupon/model/UserRole.hbm.xml not found
org.hibernate.MappingException: Resource: com/mcc/coupon/model/UserRole.hbm.xml not found
然后你就知道原因是因為配置文件的解析出了錯誤,這個通過 Web 頁面是看不出來的。
更多的是持久化影射文件出的錯誤;導致了沒有被解析;當然你需要的功能就無法使用了。
2. 錯誤:
StandardWrapperValve[action]: Servlet.service() for servlet action threw exception
javax.servlet.jsp.JspException: Cannot retrieve mapping for action /settlementTypeManage
或者:
type Status report
message Servlet action is not available
description The requested resource (Servlet action is not available) is not available.
原因: 同 1
3. 錯誤
StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
java.lang.ClassNotFoundException: org.apache.struts.taglib.bean.CookieTei
界面錯誤具體描述:
org.apache.jasper.JasperException: Failed to load or instantiate TagExtraInfo class: org.apache.struts.taglib.bean.CookieTei
原因與解決:
<方案一>你的“html:”開頭的標簽沒有放在一個<html:form>中
<方案二>重新啟動你的應用服務器,自動就沒有這個問題了
4. 錯誤:
Exception in thread "main" org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
原因與解決:
因為Hibernate Tools(或者Eclipse本身的Database Explorer)生成*.hbn.xml工具中包含有catalog="***"(*表示數據庫名稱)這樣的屬性,將該屬性刪除就可以了
5. 錯誤:
org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations)
原因與解決:
方法1 刪除Set方的cascade
方法2 解決關聯關系后,再刪除
方法3 在many-to-one方增加cascade 但值不能是none
最后一招:
檢查一下hashCode equals是否使用了id作為唯一標示的選項了;我用uuid.hex時是沒有問題的;但是用了native,就不行了,怎么辦?刪除啊!
這個錯誤可以參見我的blog文章:
http://m.tkk7.com/crazycy/archive/2006/06/24/54939.html
6. 錯誤:
exception javax.servlet.ServletException: BeanUtils.populat
root cause
java.lang.IllegalArgumentException:Cannot invoke ***Form.set*** - argument type mismatch
原因
這個問題很奇怪的說,為啥說奇怪呢?
先說問題的原因:問題發生如下兩種情況:
Form中是Date類型
上傳文件時
為什么說奇怪呢?主要針對Form是日期型的來說的;因為我做過N多系統Form中都是用java.util.Date,界面使用<html:text property=”date”/>;都是沒有問題的。所以第一次遇到這個錯誤時,搗鼓了一個下午。
解決:
第一個問題:你把Date換成String;在Action中進行轉換;當然轉換要借助于SimpleDateFormate方法嘍
第二個問題:記得在form中增加enctype="multipart/form-data" 呵呵
7. 問題:
今天用Tomcat5.5.12,發現原來很好用的系統不能用了,反復測試發現頁面中不能包含 taglib,否則會出現以下提示:
HTTP Status 500 -type Exception report
Message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /index.jsp(1,1) Unable to read TLD "META-INF/tlds/struts-bean.tld" from JAR file "file:*****/WEB-INF/lib/struts.jar":
原因:
更新了工程用的lib文件夾下的jar,發布時也發布了servlet.jar和jsp-api.jar。
解決:
把jsp-api.jar刪除就解決這個問題了。
8. 問題:Tomcat5.0.20中差錯可以通過[Tomcat安裝目錄]/logs下的localhost_log.2006-07-14.txt類似的文件看具體的錯誤日志,但是在5.5中就找不到了
原因與解決:
我把[Tomcat安裝目錄]/bin下的tomcat5w.exe的logging標簽搗鼓了一會,然后重起就有了。
原因具體說不準,用非安裝版也有這個問題。
最終解決方案:
http://tomcat.apache.org/tomcat-5.5-doc/logging.html
posted on 2009-03-05 14:50
圣克爾·光 閱讀(3101)
評論(0) 編輯 收藏 所屬分類:
SSH