JavaCallout policy runtime error troubleshooting

You're viewing Apigee Edge documentation.
Go to the Apigee X documentation.
info

ExecutionError

Error Code

steps.javacallout.ExecutionError

Error response body

{
  "fault": {
    "faultstring": "Execution returned an error result",
    "detail": {
      "errorcode": "flow.execution.ExecutionReturnedFailure"
    }
  }
}

Cause

This error occurs if Java code throws an exception or returns null during the execution of a JavaCallout policy.

Diagnosis

  1. Start a trace session to capture the error and identify which JavaCallout policy has failed.

  2. Examine the JavaCallout policy and the resource that is used. In the above example, the JavaCallout policy uses a resource named hello.jar, as shown below:

    <JavaCallout name="hello-java">
       <ClassName>com.apigeesample.HelloJava</ClassName>
       <ResourceURL>java://hello.jar</ResourceURL>
    </JavaCallout>
    
    
  3. Capture and store the Java exception in a flow variable by modifying the source code, as described in Handling errors in a Java Callout.

  4. Compile and replace the affected resource (JAR file) with the updated Java artifact.

  5. Deploy the API Proxy as a new revision and make the API call.

  6. Start another trace session.

  7. Notice that a stack trace is available in the JAVA_STACKTRACE variable. The stack trace lists the actual exception and the Java source file and line number at which the error is being thrown.

  8. Use this information to fix the issue in the Java code.

  9. In this example, the JavaCallout policy failed due to an ArithmeticException (division by zero) in the JavaError.java file at line #25.

Resolution

  1. Depending on the exception thrown, fix the issue in the relevant Java source file(s). a. In the example shown above, the issue was caused by an arithmetic error (division by zero). Go to the specific source file and line number indicated by the stack trace.

    b. Since you cannot perform division by zero, remove the complete else block containing the faulty line of code to resolve the problem.

  2. Replace the relevant JAR file containing the modified files at the appropriate level (API proxy, environment or organization), where it previously existed.

  3. Save and deploy the API proxy as a new revision.