Issue in Javacallout

Hello,

I'm migrating my API Proxies from APIGE Edge to APIGEE X / Hybrid and facing an issue about serializing / deserializing and constructing JSON objects & arrays. In fact, in the Edge version the package org.json was doing the job perfectly in JAR file but now after i had migrated to APIGEE X / Hybrid,  i have this issue :

Failed to execute JavaCallout. org/json/JSONObject

I tried with another package : javax.json but still same isse : 

Failed to execute JavaCallout. javax/json/Json

So i'm thinking that maybe the problem comes from this package and that it's not compatible with version of APIGEE X

@dchiesa1, dou you have any idea about this tricky issue ?

 

Regards,

0 2 176
2 REPLIES 2

May be package dependencies as stated below..I am not using ApigeeX but if you go thru the guidelines it should help.

 

  • If your Java Callout relies on additional third-party libraries packaged as independent JAR files, then place those JAR files in the /resources/java directory as well to ensure that they are loaded correctly at runtime.
  • If there are multiple JARs, simply add them as additional resources. You do not need to modify the policy configuration to refer to additional JAR files. Putting them in /resources/java is sufficient.

 

Ref:

 

i'm thinking that maybe the problem comes from this package and that it's not compatible with version of APIGEE X

Yes. You are correct.

Please see this repo.  It includes a class that will successfully deserialize from JSON to a Map, when used within an Apigee callout. Check the README for full details.

The other option, if you don't want to be constrained by this restriction, is to use an ExternalCallout, and host your Java code in CloudRun etc.