java - ColdFusion not catching NoClassDefFoundError -
i using coldfusion 8. catch noclassdeffounderror
exception in coldfusion can't... still fails , logs error in exception.log file. here tried.
<cftry> <cfset myjavaobject.mymethod()> <cfcatch type="any"> <cfdump var="#cfcatch #"> </cfcatch> <cfcatch type="java.lang.throwable"> horrible exception. <cfdump var="#cfcatch #"> </cfcatch> </cftry>
but not work. please show me how that? need catch error @ particular place , not in onerror
function of application.cfc.
now have had more coffee, not think cfcatch capable of catching noclassdeffounderror
. according documentation, processes exceptions:
exceptions events disrupt normal flow of instructions in coldfusion page, such failed database operations, missing include files, , developer-specified events.
noclassdeffounderror
error.
an error indicates serious problems reasonable application should not try catch
it sounds cfcatch
designed handle normal "recoverable" problems. there not can once noclassdeffounderror
. severe error , cannot past (under normal circumstances). can show error message , exit.
application.onerror
seems handle uncaught errors noclassdeffounderror
, exceptions. think best can implement onerror
, have display 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..."); } }
update
the type includes error java object type of java.lang.exception. not include java.lang.throwable errors. catch throwable errors, specify java.lang.throwable in cfcatch tag type attribute
despite documentation says, catching throwable
not work in of tests (or yours). suggests bug in behavior or documentation. either way not work advertised, mentioned above, alternative know of using general error handler. if must stick application.cfm file reason, try using <cferror type="exception" ...>
(absurd) test case:
<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 </cfcatch> <cfcatch> caught </cfcatch> </cftry>
Comments
Post a Comment