久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

ColdFusion 沒有捕捉到 NoClassDefFoundError

ColdFusion not catching NoClassDefFoundError(ColdFusion 沒有捕捉到 NoClassDefFoundError)
本文介紹了ColdFusion 沒有捕捉到 NoClassDefFoundError的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在使用 ColdFusion 8.我想在 ColdFusion 中捕獲 NoClassDefFoundError 異常,但是我不能...它仍然失敗并在 exception.log 文件中記錄錯誤.這是我嘗試過的.

I am using ColdFusion 8. I would like to catch a NoClassDefFoundError exception in ColdFusion however I can't... It still fails and logs the error in the exception.log file. Here is what I tried.

<cftry>
    <cfset myJavaObject.myMethod()>
    <cfcatch type="any">
        <cfdump var="#cfcatch #">
    </cfcatch>
    <cfcatch type="java.lang.Throwable">
        Horrible exception.
        <cfdump var="#cfcatch #">
    </cfcatch>
</cftry>

但這不起作用.你能告訴我怎么做嗎?我需要在特定位置捕獲此錯誤,而不是在 Application.cfc 的 OnError 函數中.

But this does not work. Could you please show me how to do that? I need to catch this error at a particular place and not in the OnError function of my Application.cfc.

推薦答案

現在我喝了更多的咖啡,我不認為 cfcatch 能夠捕獲 NoClassDefFoundError.根據文檔,它只處理 Exceptions:

Now that I have had more coffee, I do not think cfcatch is capable of catching a NoClassDefFoundError. According to the documentation, it only processes Exceptions:

異常是破壞正常指令流的事件在 ColdFusion 頁面中,例如數據庫操作失敗、丟失包括文件和開發人員指定的事件.

Exceptions are events that disrupt the normal flow of instructions in a ColdFusion page, such as failed database operations, missing include files, and developer-specified events.

NoClassDefFoundError 是一個 錯誤.

一個錯誤表示嚴重的問題,一個合理的應用程序不應該試圖抓住

An Error indicates serious problems that a reasonable application should not try to catch

聽起來 cfcatch 只是為了處理正常的可恢復"問題而設計的.一旦你得到 NoClassDefFoundError,你真的無能為力.這是一個嚴重的錯誤,你無法克服它(在正常情況下).您最多只能顯示錯誤消息并退出.

It sounds like cfcatch was only designed to handle normal "recoverable" problems. There is really not much you can do once you get a NoClassDefFoundError. It is a severe error and you cannot get past it (under normal circumstances). The most you can do is show an error message and exit.

Application.onErrora> 似乎可以處理 NoClassDefFoundError 等未捕獲的錯誤以及異常.所以我認為你能做的最好的就是實現 onError 并讓它顯示一個錯誤頁面.

Application.onError seems to handle uncaught Errors like NoClassDefFoundError, as well as Exceptions. So I think the best you can do is implement onError and have it display an error page.

    <!---- test code --->
    <cfset myJavaObject = createObject("java", "path.to.MyClass") />
    <cfset myJavaObject.myMethod() />

    <!---- Application.cfc --->
    <cfcomponent>
         .... settings ...
         <cffunction name="onError" returnType="void"> 
             <cfargument name="Exception" required="true" /> 
             <cfargument name="EventName" type="string" required="true" /> 
             <h1>onError Test</h1>
             <cfdump var="#Exception#" />
         </cffunction>
    </cfcomponent>

    // test class
    public class MyClass {
        public void myMethod() {
            throw new NoClassDefFoundError ("Testing...");
        }
    }

<小時>

更新

Any 類型包括 Java 對象類型的所有錯誤java.lang.異常.它不包括 java.lang.Throwable 錯誤.要捕獲 Throwable 錯誤,請在 cfcatch 中指定 java.lang.Throwable標簽類型屬性

The Any type includes all error with the Java object type of java.lang.Exception. It does not include java.lang.Throwable errors. To catch Throwable errors, specify java.lang.Throwable in the cfcatch tag type attribute

盡管文檔說了什么,捕獲 Throwable 在我(或您的)的任何測試中都不起作用.這強烈表明行為或文檔中存在錯誤.無論哪種方式,它都像宣傳的那樣工作,所以如上所述,我所知道的唯一替代方法是使用通用錯誤處理程序.如果您出于某種原因必須堅持使用 Application.cfm 文件,請嘗試使用 <cferror type="exception" ...>

Despite what the documentation says, catching Throwable does not work in any of my tests (or yours). That strongly suggests a bug in the behavior or the documentation. Either way it does not work as advertised, so as mentioned above, the only alternative I know of is using a general error handler. If you must stick with an Application.cfm file for some reason, try using <cferror type="exception" ...>

(荒謬)測試用例:

<cftry>
   <cfset myJavaObject = createObject("java", "path.to.MyClass")>
   <cfset myJavaObject.myMethod()>
   <cfcatch type="java.lang.NoClassDefFoundError">
      CAUGHT java.lang.NoClassDefFoundError
   </cfcatch>
   <cfcatch type="java.lang.LinkageError">
      CAUGHT java.lang.LinkageError
   </cfcatch>
   <cfcatch type="java.lang.Error">
      CAUGHT java.lang.Error
   </cfcatch>
   <cfcatch type="java.lang.Throwable">
      CAUGHT java.lang.Throwable 
   </cfcatch>
   <cfcatch type="any">
      CAUGHT ANY
   </cfcatch>
   <cfcatch>
      CAUGHT
   </cfcatch>
</cftry>

這篇關于ColdFusion 沒有捕捉到 NoClassDefFoundError的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環繞文本?)
MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何獲取插入的自動生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數據庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 91禁在线观看 | 亚洲欧美日韩国产精品 | av色在线| 国产盗摄一区二区三区 | aa久久| 久久只有精品 | 99精品欧美一区二区蜜桃免费 | 日韩网站免费观看 | 欧美福利视频 | 欧美日韩精品一区 | 国产精品一级二级 | 国产乱码精品一品二品 | 日日日干干干 | 日本欧美亚洲 | 国产精品美女久久久久久久久 | 欧美片网站yy | 日本公妇乱偷中文字幕 | 久久国产一区 | 欧美成人综合 | 三级网站视频 | 97在线免费 | 日韩欧美在线免费观看 | 欧美激情网| 特黄一级毛片 | 99久久婷婷国产综合精品草原 | 国产美女一区二区三区 | 日韩欧美精品一区二区 | 欧洲色综合 | 中文字幕在线一区二区三区 | 红桃av在线| 快播少女爱欢乐 | 97超碰在线播放 | 中文字幕超清在线观看 | 久久久久久逼 | av高清在线| 毛片毛片毛片毛片毛片 | 中文字幕一二三四区 | 欧美精品999| 国产在线成人 | 伊人久久免费视频 | 国产精品美女久久久久久久久 |