Failing to upload java jar using pipeline in Apigee X proxy

Hello Everyone,

We have created a custom class VerifySignature for signature verification in the Apigee proxy. This works fine with Javacall out policy in Apigee X Dev environment.

However, when we try to get the same proxy deployed in QA environment,  the deployment is failing with error  steps.javacallout.JavaCalloutInstantiationFailed: "Failed to instantiate the JavaCallout Class com.apigee.VerifySignature"

The process of deployment is using CICD pipieline. The proxy application is imported into Github repository from Dev instance and then deployed into QA instance via pipelines. 

Can someone help to understand how to fix this issue.

3 9 216
9 REPLIES 9

If it were me, I would look in the Apigee logs.

But having experience with this sort of thing, the cause of the"failed to instantiate" error is

  • the main class you specified in the java callout configuration, is not available in the JAR you cited
  • The JAR you cited depends on some other class, which is not available 

Apigee resolves dependencies first by looking in the java resources for the API proxy. So if you have a Java Callout that specifies ClassName foo.bar.Callout , and ResourceURL java://A.jar , and that class depends on io.something.SupportingClass , which is provided by B.jar, then one way to allow the Java callout to instantiate correctly is to provide both A.jar and B.jar in the resources/java directory of the API proxy bundle. 

In Apigee you can also create environment-scoped resources.  So another way to allow the Java callout to instantiate correctly is to provide A.jar in the resources/java directory of the API proxy bundle, and upload B.jar as an environment scoped resource. 

In light of all that, here are some possible explanations for what you are seeing :

  1. the API proxy bundle in Dev includes all the necessary dependencies for your Java callout VerifySignature class, but somehow the api proxy bundle that you import into QA does not include those dependencies. 
  2. The DEV environment has environment-scoped java resources that allow dependency resolution, but the QA environment does not have those same environment-scoped dependencies. 

Thanks @dchiesa1  for the response!

Have verified the above points before starting this conversation. Everything looks good from jar perspective. The manual deployment in QA with the same jar went on fine and could test the API successfully.

The issue seems to be with pipeline through which QA deployment was triggered. 

 

Ahhh, I see!  Well I won't know anything about that pipeline.  Good luck sorting that out!

I have the exact same issue, and i am also using java for signature validation. Small world 🙂 

This is my mvn command

- mvn install -Ptest -Dfile=gcloud-api-key.json -Dapigee.config.options=create -Dbearer=${access_token} -Dorg=$APIGEE_ORG_NPROD -Denv=$DEV_ENV_2
 
Build command in POM file
 
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>copy-resources-step</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<outputDirectory>${basedir}/target/apiproxy</outputDirectory>
<resources>
<resource>
<directory>apiproxy</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.apigee.build-tools.enterprise4g</groupId>
<artifactId>apigee-edge-maven-plugin</artifactId>
<version>2.3.0</version>
<executions>
<execution>
<id>configure-bundle-step</id>
<phase>package</phase>
<goals>
<goal>configure</goal>
</goals>
</execution>
<execution>
<id>deploy-bundle</id>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
 
 
Pipeline fails with the below error - 
 
{
[ERROR] "type": "MISSING_DEPENDENCY",
[ERROR] "subject": "organizations/$APIGEE_ORG_NPROD/environments/$DEV_ENV_2/resourcefiles/java/apigee-signaturegeneration-1.2.jar",
[ERROR] "description": "Required resource file java/apigee-signaturegeneration-1.2.jar does not exist."
[ERROR] }
 
 

maybe @ssvaidyanathan will be able to help you.

Hi @NikhilAnand_whp - set the overwrite config to false. Overwrite is changing the contents of the jar

Thanks for your response!

Is there a pipeline/pom example, which would first build the jar from the java class files and then use that built jar for APIGEE deployment.

Currently my repo settings doesn't allow me to upload jars.

@NikhilAnand_whp - what I usually do is add a pom for the actual Java code build (https://github.com/ssvaidyanathan/apigee-java-callout-pemdecode/blob/main/callout/pom.xml) and then once the jar is created, move it to the apiproxy/resources/jar directly. See L150 in the pom. It copies it over.

Once thats there, you just run the pom to package the apigee proxy bundle and deploy it

Thanks !!

So, I will have to find a way to run the JAVA POM first, to build the jar, and then APIGEE POM to package and deploy the proxy.

I know, it's outside the APIGEE remit, but would you happen to have a reference link as how can I achieve this ? I have only limited knowledge on CICD.