Examinez la règle JavaCallout et la ressource utilisée. Dans l'exemple ci-dessus, la règle JavaCallout utilise une ressource nommée hello.jar, comme illustré ci-dessous :
Enregistrez et stockez l'exception Java dans une variable de flux en modifiant le code source, comme décrit dans la section Gérer les erreurs dans un appel Java.
Compilez et remplacez la ressource affectée (fichier JAR) par l'artefact Java mis à jour.
Déployez le proxy d'API en tant que nouvelle révision et effectuez l'appel d'API.
Démarrez une autre session de traçage.
Notez qu'une trace de pile est disponible dans la variable JAVA_STACKTRACE. La trace de la pile répertorie l'exception réelle et le fichier source Java et le numéro de ligne où l'erreur est générée.
Utilisez ces informations pour résoudre le problème dans le code Java.
Dans cet exemple, la règle JavaCallout a échoué en raison d'une exception ArithmeticException (division par zéro) dans le fichier JavaError.java à la ligne 25.
Solution
En fonction de l'exception générée, corrigez le problème dans le ou les fichiers sources Java correspondants.
a. Dans l'exemple ci-dessus, le problème est dû à une erreur arithmétique (division par zéro). Accédez au fichier source et au numéro de ligne indiqués par la trace de la pile.
b. Comme vous ne pouvez pas effectuer de division par zéro, supprimez le bloc et tout autre bloc contenant la ligne de code défaillante afin de résoudre le problème.
Replacez le fichier JAR contenant les fichiers modifiés à l'emplacement (proxy, environnement ou organisation de l'API), où il existait auparavant.
Enregistrez et déployez le proxy d'API en tant que nouvelle révision.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/04 (UTC)."],[[["\u003cp\u003eThis documentation addresses troubleshooting for \u003ccode\u003esteps.javacallout.ExecutionError\u003c/code\u003e in Apigee and Apigee hybrid environments, specifically related to JavaCallout policies.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eExecutionError\u003c/code\u003e occurs when Java code within a JavaCallout policy throws an exception or returns \u003cem\u003enull\u003c/em\u003e.\u003c/p\u003e\n"],["\u003cp\u003eDiagnosis involves using a trace session to identify the failing JavaCallout policy and examining the relevant JAR resource, along with capturing the Java exception in a flow variable named \u003ccode\u003eJAVA_STACKTRACE\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eResolution requires identifying the specific Java exception and its location (file and line number) from the stack trace, fixing the error in the source code, and updating the corresponding JAR file.\u003c/p\u003e\n"],["\u003cp\u003eThe example given in this document outlines an \u003ccode\u003eArithmeticException\u003c/code\u003e (division by zero), for which you can resolve by removing or correcting the lines of code that cause the error, updating the jar file and deploying a new revision.\u003c/p\u003e\n"]]],[],null,["# JavaCallout policy runtime error troubleshooting\n\n*You're viewing **Apigee** and **Apigee hybrid** documentation.\nView [Apigee Edge](https://docs.apigee.com/api-platform/troubleshoot/policies/runtime/java-callout-runtime-errors) documentation.*\n| **Note:** Was this troubleshooting playbook helpful? Please let us know by clicking [Send Feedback]().\n\nExecutionError\n--------------\n\n### Error Code\n\n steps.javacallout.ExecutionError\n\n### Error response body\n\n {\n \"fault\": {\n \"faultstring\": \"Execution returned an error result\",\n \"detail\": {\n \"errorcode\": \"flow.execution.ExecutionReturnedFailure\"\n }\n }\n }\n\n### Cause\n\nThis error occurs if Java code throws an exception or returns *null* during the execution of a [JavaCallout policy](/apigee/docs/api-platform/reference/policies/java-callout-policy).\n\n### Diagnosis\n\n1. Start a [trace session](/apigee/docs/api-platform/debug/trace) to capture the error and identify which [JavaCallout policy](/apigee/docs/api-platform/reference/policies/java-callout-policy) has failed.\n\n2. Examine the [JavaCallout policy](/apigee/docs/api-platform/reference/policies/java-callout-policy) and the resource that is used. In the above example, the [JavaCallout policy](/apigee/docs/api-platform/reference/policies/java-callout-policy) uses a resource named `hello.jar`, as shown below:\n\n \u003cJavaCallout name=\"hello-java\"\u003e\n \u003cClassName\u003ecom.apigeesample.HelloJava\u003c/ClassName\u003e\n \u003cResourceURL\u003ejava://hello.jar\u003c/ResourceURL\u003e\n \u003c/JavaCallout\u003e\n\n3. Capture and store the Java exception in a flow variable by modifying the\n source code, as described in\n [Handling errors in JavaCallout policies](/apigee/docs/api-platform/develop/how-handle-java-callout-errors).\n\n4. Compile and replace the affected resource (JAR file) with the updated Java artifact.\n\n5. Deploy the API Proxy as a new revision and make the API call.\n\n6. Start another trace session.\n\n7. 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.\n\n8. Use this information to fix the issue in the Java code.\n\n9. In this example, the [JavaCallout policy](/apigee/docs/api-platform/reference/policies/java-callout-policy) failed due to an ArithmeticException (division by zero) in the `JavaError.java` file at line #25.\n\n### Resolution\n\n1. Depending on the exception thrown, fix the issue in the relevant Java source file(s).\n 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.\n\n b. Since you cannot perform division by zero, remove the complete else block containing the faulty line of code to resolve the problem.\n2. Replace the relevant JAR file containing the modified files at the appropriate level (API proxy, environment or organization), where it previously existed.\n\n3. Save and deploy the API proxy as a new revision."]]