How to upload dependencies jar in lib folder

I created one jar file and in that i have class files, .classpath file, .project file In sample on github, i see apiproxy, callout and lib folder. when i deploy it, i getting error that traffic can't flow , i get error like traffic.How to upload dependencies jar in lib folder However when i upload my main jar file in resources folder, i don't see any lib folder for dependencies jars. Should i place all jars in one resources folder. in my .classpath file, i can see all lib jars like message-flow-1.0.0.jar, expressions-1.0.0.jar and itextpdf-5.5.6.jar. However in documentation, its given to deploy by maven but i don't know maven, from UI how should i create lib folder and upload jars there.

0 4 1,742
4 REPLIES 4

Hmm, none of what you are describing sounds familiar to me.

a .classpath file?

a .project file?

??

To create your first Java callout, I suggest that you follow the directions in the cookbook.

Hi DIno, i went through the cookbook, its not mentioned there that what all folders and files should be inside jar.

I can see below lines

<JavaCallout name="hello-java">
  <ClassName>com.apigeesample.HelloJava</ClassName>
  <ResourceURL>java://edge-custom-policy-java-hello.jar</ResourceURL>
</JavaCallout>

can you please help me like what all folders or files should be inside the .jar

The jar is just a standard java jar file. It needs no manifest or META-INF directory. Just include the class files for your callout.

When you specify a JAR to run a java program from a terminal, the jar should contain the compiled .class file for the class that provides the static main() method. And you also need to specify the classpath, which is the way you tell Java where to look to find all the other dependencies (in the form of other .class files, or other JAR files that contain class files) that the main() method may require, directly or indirectly.

It works similarly in the Java callout for Apigee Edge, with a few differences.

  • When defining a Java callout, you don't define a static main() method. Instead you define a Callout class, which must implement the "Execution" interface. Specify the class name in the JavaCallout policy configuration.
  • When defining a callout, you don't specify a class path. Instead, you provide the other jars that provide all the dependencies, in the same java/resources folder that holds your main jar (** but see note below) . You do not need to specify those "other" JARs in the JavaCallout policy configuration.

If you are building a "hello world" Java callout, then you probably have no dependencies, and probably you need exactly ONE class in the JAR file: the class that defines com.apigeesample.HelloJava, or whatever is the packaged-qualified name of the class that defines your callout.

** it is also possible to specify JARs in the environment scope or the organization scope, but you don't need to worry about that when doing your first "HelloJava" example callout.

Hi Dino, i tried these ways also

1. one time kept only class files in jar

2. kept class file with manifest files in jar

Still i am getting same error like 'traffic can't flow' when deplyoing. I am not getting where is the issue