Can I include external libraries in java callout jar?

Not applicable

I'm creating a java callout that uses external libraries, so my callout is dependent on these libraries. Can I include external libraries? How can I do that?

Solved Solved
2 5 1,357
1 ACCEPTED SOLUTION

If using the UI, just upload the JARs as additional resources in the proxy.

If using the API, Just bundle the JARs in the zip. Like this:

$ unzip -l apiproxy-rfc7523-20170412-084245.zip 
Archive:  apiproxy-rfc7523-20170412-084245.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  12-14-2016 17:58   apiproxy/
        0  12-14-2016 21:22   apiproxy/policies/
      300  12-14-2016 17:59   apiproxy/policies/AE-App.xml
      151  12-14-2016 18:02   apiproxy/policies/AE-Developer.xml
      691  12-14-2016 20:26   apiproxy/policies/AM-CleanResponseHeaders.xml
      942  12-14-2016 18:03   apiproxy/policies/AM-ExpiredApiKey.xml
      842  12-14-2016 18:03   apiproxy/policies/AM-InvalidApiKey.xml
      263  12-14-2016 18:00   apiproxy/policies/AV-GrantType.xml
      301  12-14-2016 18:00   apiproxy/policies/BA-EncodeCC.xml
      254  12-14-2016 21:22   apiproxy/policies/CL-JwtHash.xml
      354  12-14-2016 21:22   apiproxy/policies/CP-JwtHash.xml
      418  12-14-2016 17:59   apiproxy/policies/EV-ConsumerSecret.xml
      284  12-14-2016 17:59   apiproxy/policies/EV-DeveloperProfile.xml
      325  12-14-2016 17:59   apiproxy/policies/JS-ExtractIssuer.xml
      177  12-14-2016 18:00   apiproxy/policies/JS-GroomTokenResponse.xml
      263  12-14-2016 17:59   apiproxy/policies/JS-HashJwt.xml
      711  12-14-2016 18:05   apiproxy/policies/JWT-ParseAssertion.xml
     2642  12-14-2016 18:00   apiproxy/policies/OAuthV2-GenerateAccessToken-CC1.xml
      430  12-14-2016 18:00   apiproxy/policies/RF-InvalidExpiry.xml
      447  12-14-2016 17:59   apiproxy/policies/RF-InvalidJwt.xml
      785  12-14-2016 17:58   apiproxy/policies/RF-InvalidRequestJwt.xml
      533  12-14-2016 18:00   apiproxy/policies/RF-UnknownRequest.xml
     1198  12-14-2016 20:23   apiproxy/policies/VerifyAPIKey-1.xml
        0  12-14-2016 20:27   apiproxy/proxies/
     3266  12-14-2016 20:27   apiproxy/proxies/jwt2token.xml
        0  12-14-2016 18:03   apiproxy/resources/
        0  12-14-2016 17:53   apiproxy/resources/java/
   434678  12-14-2016 17:53   apiproxy/resources/java/commons-lang3-3.4.jar
  2256213  12-14-2016 17:53   apiproxy/resources/java/guava-18.0.jar
    54236  12-14-2016 17:53   apiproxy/resources/java/json-smart-1.3.jar
    32952  12-14-2016 17:53   apiproxy/resources/java/jwt-signed-edge-callout.jar
   178813  12-14-2016 17:53   apiproxy/resources/java/nimbus-jose-jwt-3.10.jar
        0  12-14-2016 18:04   apiproxy/resources/jsc/
     4663  12-14-2016 18:04   apiproxy/resources/jsc/base64codec.js
     6129  12-14-2016 18:04   apiproxy/resources/jsc/dateFormat.js
      638  12-14-2016 18:04   apiproxy/resources/jsc/extractIssuer.js
     2554  12-14-2016 18:04   apiproxy/resources/jsc/groomTokenResponse.js
      372  12-14-2016 18:04   apiproxy/resources/jsc/hashJwt.js
      418  12-14-2016 17:52   apiproxy/rfc7523.xml
    10173  12-14-2016 17:56   LICENSE
     4927  12-14-2016 21:17   README.md
---------                     -------
  3002343                     41 files



View solution in original post

5 REPLIES 5

If using the UI, just upload the JARs as additional resources in the proxy.

If using the API, Just bundle the JARs in the zip. Like this:

$ unzip -l apiproxy-rfc7523-20170412-084245.zip 
Archive:  apiproxy-rfc7523-20170412-084245.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  12-14-2016 17:58   apiproxy/
        0  12-14-2016 21:22   apiproxy/policies/
      300  12-14-2016 17:59   apiproxy/policies/AE-App.xml
      151  12-14-2016 18:02   apiproxy/policies/AE-Developer.xml
      691  12-14-2016 20:26   apiproxy/policies/AM-CleanResponseHeaders.xml
      942  12-14-2016 18:03   apiproxy/policies/AM-ExpiredApiKey.xml
      842  12-14-2016 18:03   apiproxy/policies/AM-InvalidApiKey.xml
      263  12-14-2016 18:00   apiproxy/policies/AV-GrantType.xml
      301  12-14-2016 18:00   apiproxy/policies/BA-EncodeCC.xml
      254  12-14-2016 21:22   apiproxy/policies/CL-JwtHash.xml
      354  12-14-2016 21:22   apiproxy/policies/CP-JwtHash.xml
      418  12-14-2016 17:59   apiproxy/policies/EV-ConsumerSecret.xml
      284  12-14-2016 17:59   apiproxy/policies/EV-DeveloperProfile.xml
      325  12-14-2016 17:59   apiproxy/policies/JS-ExtractIssuer.xml
      177  12-14-2016 18:00   apiproxy/policies/JS-GroomTokenResponse.xml
      263  12-14-2016 17:59   apiproxy/policies/JS-HashJwt.xml
      711  12-14-2016 18:05   apiproxy/policies/JWT-ParseAssertion.xml
     2642  12-14-2016 18:00   apiproxy/policies/OAuthV2-GenerateAccessToken-CC1.xml
      430  12-14-2016 18:00   apiproxy/policies/RF-InvalidExpiry.xml
      447  12-14-2016 17:59   apiproxy/policies/RF-InvalidJwt.xml
      785  12-14-2016 17:58   apiproxy/policies/RF-InvalidRequestJwt.xml
      533  12-14-2016 18:00   apiproxy/policies/RF-UnknownRequest.xml
     1198  12-14-2016 20:23   apiproxy/policies/VerifyAPIKey-1.xml
        0  12-14-2016 20:27   apiproxy/proxies/
     3266  12-14-2016 20:27   apiproxy/proxies/jwt2token.xml
        0  12-14-2016 18:03   apiproxy/resources/
        0  12-14-2016 17:53   apiproxy/resources/java/
   434678  12-14-2016 17:53   apiproxy/resources/java/commons-lang3-3.4.jar
  2256213  12-14-2016 17:53   apiproxy/resources/java/guava-18.0.jar
    54236  12-14-2016 17:53   apiproxy/resources/java/json-smart-1.3.jar
    32952  12-14-2016 17:53   apiproxy/resources/java/jwt-signed-edge-callout.jar
   178813  12-14-2016 17:53   apiproxy/resources/java/nimbus-jose-jwt-3.10.jar
        0  12-14-2016 18:04   apiproxy/resources/jsc/
     4663  12-14-2016 18:04   apiproxy/resources/jsc/base64codec.js
     6129  12-14-2016 18:04   apiproxy/resources/jsc/dateFormat.js
      638  12-14-2016 18:04   apiproxy/resources/jsc/extractIssuer.js
     2554  12-14-2016 18:04   apiproxy/resources/jsc/groomTokenResponse.js
      372  12-14-2016 18:04   apiproxy/resources/jsc/hashJwt.js
      418  12-14-2016 17:52   apiproxy/rfc7523.xml
    10173  12-14-2016 17:56   LICENSE
     4927  12-14-2016 21:17   README.md
---------                     -------
  3002343                     41 files



I used the UI. Thanks for the quick response, it worked!

Also, if you want multiple proxies to use the libraries, you can also store the JARs at an environment or organization scope, described here: http://docs.apigee.com/api-services/content/resource-files. If you store JARs with a proxy, only that proxy can use 'em.

Hi Dino

Is this the correct approach or bundling the required jars inside the main javacallout jar is good?

hi. I don't know what you are asking. Also, when you ask a new question, please ask a new question, instead of posting a comment to an 8-month old thread.

6174-ask-a-question.png