using JarJar repackaging tool

元气小坏坏 提交于 2019-12-22 04:03:21

问题


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.


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/12612726/using-jarjar-repackaging-tool

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!