Apigee Emulator and Java Callout with properties

Hi there

I am trying to get the sample java callout with properties (from the github apigee-platform-samples/doc-samples/java-properties) working in the vscode Apigee emulator.

As per the github sample, my java policy looks as follows:

supadudey_0-1678880490707.png

Additionally the Java class is as follows:

supadudey_1-1678885699848.png

 

However when I try to run a sample proxy using the above within an Emulator within VSCode, I experience the following "No appropriate constructor found in JavaCallout class com.apigeesample.JavaProperties" error when deploying the API proxy to a sample environment:

 

03/15/2023 3:11 PM EMULATOR INFO Deploying environment dev, to Container vcg-apigee-01 (1.6.1)
03/15/2023 3:11 PM EMULATOR ERROR Code : steps.javacallout.NoAppropriateConstructor
03/15/2023 3:11 PM EMULATOR ERROR Message: No appropriate constructor found in JavaCallout class com.apigeesample.JavaProperties
03/15/2023 3:11 PM EMULATOR ERROR File : /opt/work/users/panagos/vodacom/apigee/apigee-workspace/vcg-workspace/src/main/apigee/apiproxies/helloworld/apiproxy/policies/FirstJavaPolicy.xml:2:34
03/15/2023 3:11 PM EMULATOR ERROR Code : steps.javacallout.NoAppropriateConstructor
03/15/2023 3:11 PM EMULATOR ERROR Message: No appropriate constructor found in JavaCallout class com.apigeesample.JavaProperties
03/15/2023 3:11 PM EMULATOR ERROR File : /opt/work/users/panagos/vodacom/apigee/apigee-workspace/vcg-workspace/src/main/apigee/apiproxies/helloworld/apiproxy/policies/java-callout.xml:2:34
03/15/2023 3:11 PM EMULATOR ERROR Environment dev deployment, to Container vcg-apigee-01 (1.6.1) failed with Error: 400
03/15/2023 3:11 PM EMULATOR ERROR Deploy to Container vcg-apigee-01 (1.6.1), failed with Error: Environment dev deployment, to Container vcg-apigee-01 (1.6.1) failed with Error: 400

Any suggestions on how to workaround this? It would appear that the error occurs whenever I try to define a constructor with a Map parameter.

 

0 5 327
5 REPLIES 5

Did you manage to find a workaround? I'm experiencing the same issue.

"No Appropriate Constructor" could mean ...the emulator is looking for a default constructor, one that accepts no parameters.

I don't know why that would be. in fact it seems like a bug.  (I haven't read the documentation extensively on the emulator, but it seems to me it should run valid Java callouts).   Try to add the default ctor and see if you get past the error.

default constructor worked for me.

facing the same issue, any workarounds?

You need to add an empty constructor to the class. It worked for me.