TRapping Errors from a Java Component

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default TRapping Errors from a Java Component

    I am using "creatObject" to use a Java Class and need to have ColdFusion trap
    any errors returned by this class. My code is as follows:

    <cftry>
    <cfset co = createObject("java", "CNRP_SP")>
    <cfset CoBAP = co.CNRP_SP()>
    <cfset CoTable = co.callBAPI(#arguments.BAPIName#, #arguments.queryTable#)>
    <cfset CoTable.firstRow()>
    <cfset count = #CoTable.getNumRows()#>
    <!--- create a query --->
    <cfset qSPtable = queryNew("Item, Company_Code, Company_Name")>
    <cfloop index = "i" from = 1 to = #count#>
    <cfset newrow = queryaddrow(qSPtable, 1)>
    <!--- set values in cells --->
    <cfset temp = querysetcell(qSPtable, 'Item', i)>
    <cfset temp = querysetcell(qSPtable, 'Company_Code',
    ToString(CoTable.getString("COMP_CODE")))>
    <cfset temp = querysetcell(qSPtable, 'Company_Name',
    ToString(CoTable.getString("COMP_NAME")))>
    <cfset CoTable.nextRow()>
    </cfloop>

    <cfcatch>
    Do Something Here - Errors in the Java code
    never get caught here
    </cfcatch>
    </cftry>

    In the Java code when I throw an error ColdFusion displays the text and stops
    processing before it ever gets to <cfcatch>

    Is there a way to handle this? How can I "catch" errors in CF?

    TIA

    mherel Guest

  2. Similar Questions and Discussions

    1. Trapping errors
      Is there a way to implement a global error trap at the application level? I added an event listener on my application tag, but it doesn't trap the...
    2. WSDL Errors with Java and CF
      hello. I'm trying to make a call to a Java WSDL service. The Java programmer says that nothing's wrong with the WSDL. Yet, I keep getting the...
    3. Trapping datatype errors for web methods
      I've set up a web method with several parameters with UDT's using enums. If a user submits an entry with an invalid value, it throws an exception,...
    4. Trapping errors from stored procedure calls
      We often use code in stored procedures for premature exit, such as SET @returnerror = @@ERROR IF ( @returnerror <> 0 ) BEGIN RAISERROR(...
    5. trapping compile time errors
      Hi, I want to catch compile time errors with my own method. In Perl, you can do this: $SIG{__DIE__} = \&die; sub die { print "Error...
  3. #2

    Default Re: TRapping Errors from a Java Component

    Just guessing here, but did you try specifying the type of exception to catch?




    <cfcatch type="java.lang.ArrayIndexOutOfBoundsException">
    <cfdump var="#CFCATCH#">
    </cfcatch>
    mxstu Guest

  4. #3

    Default Re: TRapping Errors from a Java Component

    No, I left the specifics blank to try to catch any errors. I am not really a
    java guy so I am not sure of the specifics for java errors. Can I be more
    genereic and do something like:

    <cfcatch type="java.lang">
    <cfdump var="#CFCATCH#">
    </cfcatch>


    I am concerned though, that it looks like it never makes it to the "catch"
    block...

    mherel Guest

  5. #4

    Default Re: TRapping Errors from a Java Component

    Thanks a lot, that did the trick....
    mherel Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139