How to upload dependencies jar in lib folder in apigee from Edge UI - apigee

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.

Okay, in my understanding of your point.
You can upload jar file into apigee from Scripts > import file > in file type choose "JAR" > select jar file from your work space > and finally, define your jar name and then use policy Java Callout to call your jar.
If you have to modified your jar and want to deploy it, delete your existing jar in apigee and upload the new jar by following 1. In case of new jar has the same name of existing jar, you do not need to do anything with Java Callout policy. But the new jar has the different name, don't forget to modified Java Callout for refer to your new jar.

Please create the single jar file which contains jars like message-flow-1.0.0.jar, expressions-1.0.0.jar and itextpdf-5.5.6.jar. As per the apigee doc in create a Java Callout policy and make sure you have mentioned the package name & class name in Java Callout Poliy
<ClassName>package.ClassName</ClassName
<ResourceURL>java://SingleJar.jar</ResourceURL>

Related

How to update a JAR file with a modfied Java file

I have one JAR named as abc.jar with 15 class files. In JAR file I need to modify xyz.class, so I decompiled to xyz.java and modified it.
How can I update that JAR with the modified Java file? While trying to create (compile) the JAR file I am getting errors.
You can add your newly compiled class to the jar and overwrite the old one, here is how to add xyz.class and xyz.java to the jar :
jar uf abc.jar xyz.class xyz.java
See here for more about updating a jar file.
Or simply you can use any archiving tool, like winrar to open and add files to the jar.
Compile the xyz.java and replace the xyz.class file directly in jar without building the jar again, if the single class has been modified.

External configuration file

I'm working on a spring-mvc project and was wondering if, like grails, I can create an external configuration file in tomcat with the appconfig folder. My project lives in /var/lib/tomcat7/webapps/<app> and was wondering if placing a configuration file in /var/lib/tomcat7/appconfigs/<config.xml> would work? If so, is it like grails and the application searches that location by default, or do I need to specify where that configuration lives? Thanks
What do you mean by "external configuration file"? Would this config file be separate from the war file? Or would it be packaged along with war file?
If packaged along with war file, you can put it under src/main/resources folder and it should be automatically packaged and placed in classpath.
If not packaged with war file, I usually put the configuration parameters under Tomcat's context.xml. Here's the documentation: http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Environment_Entries

How to use Gradle to download JAR dependencies on production site?

In the hope of finding the solution on Google as it seems a very general task, I've been trying to do this past few weeks but strangely I couldn't find anything!
What I'm doing:
I am writing an small application, It will be at most a 20KB JAR file in the end. However it has many dependencies, Hibernate and SLF4J to name a few. Directly including these dependencies with the jar file will make it 9Mb.
What is used:
Gradle is used as the build tool. the custom task fatJar creates the jar including all required dependency jar files from (the original) maven repository.
The problem
with my slow internet connection I'd rather not to directly include dependencies, but download these them on the server and not my local production site. What would be the Gradle task like to:
Read the dependencies from jar file
Download them (I know how to do it during Gradle build task).
Add them to class path
Add classpath defined in MANIFEST.mf too
run the jar, by main class defined in MANIFEST.mf
I've read gradle documentation over and over, but no help.

Add external jars to Eclipse plugin classpath

In the manifest file for an eclipse plugin its possible to add jar files and
folders to the classpath (on the Runtime tab).
In the root of my plugin I have a folder lib containing a-1.0.1.jar, b-1.0.0-SNAPSHOT.jar. But only when I select each jar separately:
Bundle-ClassPath: .,
lib/a-1.0.1.jar,
lib/b-1.0.0-SNAPSHOT.jar
...can they be used inside my project. Why is it not possible to add them to the classpath by adding the common root folder only:
Bundle-ClassPath: .,
lib/
?
No, you can't. Eclipse is based on OSGi, which is the platform providing MANIFEST.MF support to build plugins.
When you set values under Bundle-ClassPath, OSGi search into each one to find class files. So you can put folders containing Java packages and class files. When you put a jar file, it is uncompressed in memory and viewed by OSGi as a regular folder, still searching for class files.
Unfortunately, there is no way to load all jar from a folder. No wildcard mechanism or something like that is allowed here.

jar -uf is deleting the file inside the jar

I am using jar -uf to update my MANIFEST.MF file like this:
a. jar xf jarfile.jar META-INF\MANIFEST.MF
b. edit the file
c. jar uf jarfile.jar META-INF\MANIFEST.MF
But the 'uf' command is removing MANIFEST.MF from within my jar.
What is the right way to change a file inside a jar (windows 7, jdk 1.6)?
You can always use winrar (or any equivalent) to open the jar, and drag/drop the files. worked for me.
For updating the manifest file the jar command provides different option -
jar umf manifest jar-file
The m option indicates that you want to update the JAR file's manifest.
manifest is the manifest whose contents you want to merge into the manifest of the existing JAR file.
examples # http://java.sun.com/developer/Books/javaprogramming/JAR/basics/update.html
There is a special option (m) for the manifest file: http://download.oracle.com/javase/1.4.2/docs/tooldocs/windows/jar.html
Could you try with
jar um jarfile.jar META-INF/MANIFEST.MF

Resources