using JarJar repackaging tool

2019-04-23 22:09发布

I have deployed a web application to the Google app engine and my web service uses the jersey 1.14 framework. When I try to consume or invoke the web services on the GAE I get a java.lang.IncompatibleClassChangeError: Implementing class. I searched around and got to realize that jersey 1.14 depends on asm 3.1 and google app engine uses asm 4.0 and realize that I had to use JarJar to package the dependencies to fix this problem but I don't have a clue about how to do this with JarJar. The tutorial I found was very cryptic and geared towards experience programmers.So can someone post a tutorial that is geared towards a beginner or walk me through the steps to solve this problem.

2条回答
啃猪蹄的小仙女
2楼-- · 2019-04-23 22:26

You can use jar command of jdk to extract and merge the jar files.
jar -xvf firstjar.jar .... It will extract the jar classes folder/package wise -com/pak1/pak2
Now same extract second jar and merge the both expanded folders
No you can create a single jar of merged class files.
jar -cvf mergedjar.jar [folders name [ex com org ...]], for details check how jar commands works.

查看更多
贪生不怕死
3楼-- · 2019-04-23 22:42

Well this is quite late answer, but if someone crosses by may be it would help. I will take an example and explain this. jarjar can be used to repackage java libraries. it can be used to change namespace for example org.apache.common.codec needs to be changed to some_random_name.org.apache.common.codec. Download jarjar from jarjar download site later paste the jar file you want to change (myinjar.jar) and downloaded jarjar into one folder and run this command java -jar jarjar-1.4.jar process myrules.txt myinjar.jar myoutjar.jar in myrules.txt add these lines

rule org.apache.commons.codec.** some_random_name.org.apache.commons.codec.@1

the output myoutjar.jar will be saved into same folder and you can use it in your project without any conflicts

查看更多
登录 后发表回答