Intermittent Java Execution Error

10988-microsoftteams-image-20.png

I'm using java callout within my API proxy, deploying API proxy on Apigee hybrid. I'm able to get absolute response from API proxy from java callouts as well. After some time - 1 day or 2 days - I'm getting an execution error in the Java callout.

If I undeploy and then re-deploy the api proxy, i am able to see the expected response from the API proxy. This seems to be happening every time.

Has anyone else seen this problem? and if so how did you resolve it?

0 3 62
3 REPLIES 3

If you are using Apigee hybrid, I advise you to examine the logs for the MPs. There will be a stacktrace or similar in the MP logs giving you additional data for the error you are seeing.

If you have access to the source code for the Java callout, You may also be able to get additional information if you get a stacktrace from the callout itself. "ExecutionError" can mean many things, but the root cause is some exception in the callout, either an exception at runtime (like a null pointer exception), or an exception loading the class.

In summary, get some additional information and that will help you diagnose the issue.

Thankyou dino for response

I have access for source code what I see in main class code object is created for another class and calling another class in main class is that affecting the execution of the class?

sample code for understading:

class Applicationmain implements Execution {

public ExecutionResult execute(final MessageContext messageContext, final ExecutionContext executionContext) {

Abc ab = new Abc();

}

}


class Abc{

fun(){

}

}

I suggest that you surround your code with a try...catch, and in the case of an exception, you emit the exception message into a context variable. You can then view this context variable in the Trace UI.

Some sample code here:

  public ExecutionResult execute(MessageContext msgCtxt, 
                                 ExecutionContext exeCtxt) {
    try {

       // your code here

    } catch (Exception e) {
      
      String error = e.toString().replaceAll("\n", " ");
      msgCtxt.setVariable("callout_exception", error);

      String stacktrace = getStackTraceAsString(e);
      msgCtxt.setVariable("callout_stacktrace", stacktrace);
      
      return ExecutionResult.ABORT;
    }
    return ExecutionResult.SUCCESS;
  }