Java callout policy throws error when JAXB-API library is used in the java code.

I am using Java callout policy to convert XML response to meaningful objects. for this I am using JAXB-API libraries. But upn execution of this policy, I am getting following error message:
  1. org.apache.commons.lang3.Validate.inclusiveBetween(JJJLjava/lang/String;

Is there any limitation for javacallout? Please suggest me how this could be fixed.

1 9 668
9 REPLIES 9

Hi, and thanks for your question. It looks like you are also asking the same on stackoverflow!

I understand that you have a custom Java callout policy, and within your code you are using JAXB to de-serialize an object from XML into a Java Class.

You are getting an error message.

Can you provide more details? Where are you seeing this error message?

Is there an Exception being thrown, and if so what is it? And What is the stack trace?

I don't think that the JAXB classes in Java7 have any dependency on the Apache commons-lang JAR. So it may be that the error you are seeing is completely independent of JAXB.

More information may help us figure it out.

I am able to see the above error message in variable "error.message".

I am able to see the above error message in variable "error.message"

We're going to need more information than that.

I suspect there is an exception being thrown in your code.

You need to catch it, and then emit the stacktrace into a context.variable.

You can use the Apache commons ExceptionUtils class for that purpose.

import org.apache.commons.lang.exception.ExceptionUtils;
...


    try {
        // do the work of the callout here
    }
    catch (Exception e) {
        String error = e.toString();
        msgCtxt.setVariable("mycallout_exception", error);
        msgCtxt.setVariable("mycallout_stacktrace", ExceptionUtils.getStackTrace(e));
        return ExecutionResult.ABORT;
    }

Hi, Thanks for replying.

I tried to debug the java callout using context variables. I find that jaxb-api librariries are working fine. I am also using HAPI-FHIR libraries that creates Fhir complaint data. I see that execution stops when FhirContext class is initialized.

Also a strange behavior is observed. The execution is not directed towards catch block, as the variables are not getting initialized.

I'm very interested in what you're building. Is it possible that you have not included the required JARs in the API proxy bundle, when you deploy it? The FHIR JAR and it's dependencies need to be in the set of files in ( apiproxy/resources/java ), along with your callout jar.

2092-put-jars-here.png

If you don't have the required jars, then there will be a loader error when Edge tries to load your class. And your code will never run. Which would explain the behavior you see : no catch clause being entered.

the code seems to be executing as I am able to set variables using message context and am able to red the variables via AssignMessage policy in apigee.

If that's the case, then a try...catch will catch and log your exception. We need the stacktrace and the exception.