是在eclipse中编译java文件的方法,并将其添加到解压缩的jar并重命名jar正确吗?

时间:2022-07-23 19:41:32

I have a jar called framework.jar. I'm renaming it to framework.zip, decompiling one of its class files, modifing it, and putting it back in to the zip and renaming it back to framework.jar.

我有一个名为framework.jar的jar。我将它重命名为framework.zip,对其中一个类文件进行反编译,对其进行修改,然后将其重新放入zip并将其重命名为framework.jar。

While I do this without making any modifications to any of the .class files, my tomcat runs fine. However, with my modifications, I get a Lifecycle exception. Note that I took the corresponding latest compiled .class file from eclipse and replaced the same .class file file.

虽然我这样做而没有对任何.class文件进行任何修改,但我的tomcat运行正常。但是,通过我的修改,我得到了一个Lifecycle异常。请注意,我从eclipse中获取了相应的最新编译的.class文件,并替换了相同的.class文件文件。

update:

SEVERE: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngin
e[Catalina].StandardHost[localhost].StandardContext[/enovia]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:901)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:87
7)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)

        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.jav
a:1120)
        at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig
.java:1678)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:51
1)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.tomee.catalina.TomEERuntimeException: org.apache.openejb.O
penEJBException: Unable to create annotation scanner for web module enovia: null

        at org.apache.tomee.catalina.TomcatWebAppBuilder.loadApplication(TomcatW
ebAppBuilder.java:2049)
        at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWeb
AppBuilder.java:1091)
        at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWe
bAppBuilder.java:1051)
        at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(Global
ListenerSupport.java:127)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:119)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBa
se.java:90)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContex
t.java:5322)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        ... 10 more
Caused by: org.apache.openejb.OpenEJBException: Unable to create annotation scan
ner for web module enovia: null
        at org.apache.openejb.config.DeploymentLoader.addWebModule(DeploymentLoa
der.java:838)
        at org.apache.openejb.config.DeploymentLoader.load(DeploymentLoader.java
:219)
        at org.apache.tomee.catalina.TomcatWebAppBuilder.loadApplication(TomcatW
ebAppBuilder.java:2047)
        ... 17 more
Caused by: java.lang.IllegalArgumentException
        at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
        at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
        at org.apache.xbean.asm4.ClassReader.<init>(Unknown Source)
        at org.apache.xbean.finder.AnnotationFinder.readClassDef(AnnotationFinde
r.java:1120)
        at org.apache.xbean.finder.AnnotationFinder.<init>(AnnotationFinder.java
:139)
        at org.apache.xbean.finder.AnnotationFinder.<init>(AnnotationFinder.java
:152)
        at org.apache.xbean.finder.AsynchronousInheritanceAnnotationFinder.<init
>(AsynchronousInheritanceAnnotationFinder.java:43)
        at org.apache.openejb.config.FinderFactory.newFinder(FinderFactory.java:
114)
        at org.apache.openejb.config.FinderFactory.create(FinderFactory.java:68)

        at org.apache.openejb.config.FinderFactory.createFinder(FinderFactory.ja
va:57)
        at org.apache.openejb.config.DeploymentLoader.addWebModule(DeploymentLoa
der.java:830)
        ... 19 more

May 13, 2015 9:14:52 PM org.apache.catalina.startup.HostConfig deployDirectory
SEVERE: Error deploying web application directory D:\16x_tomcat\apache-tomee-plu
s-1.6.0\webapps\enovia
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catal
ina.LifecycleException: Failed to start component [StandardEngine[Catalina].Stan
dardHost[localhost].StandardContext[/enovia]]
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:904)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:87
7)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)

        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.jav
a:1120)
        at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig
.java:1678)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:51
1)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:617)
        at java.lang.Thread.run(Thread.java:745)

update 2:

As greg-449's comment pointed out, the issue was because I was using a java 8 compiler. And that jar was built on a java 7 compiler.

正如greg-449的评论指出的那样,问题是因为我使用的是java 8编译器。那个jar是基于java 7编译器构建的。

1 个解决方案

#1


Tomcat: LifecycleException when deploying

Tomcat:部署时出现LifecycleException

Based on the post referenced above you might be missing some start up, note that there should be a log file for a more detailed error report.

基于上面引用的帖子,您可能会遗漏一些启动,请注意应该有一个日志文件以获取更详细的错误报告。

Also the legally behind editing pre-compiled jar files... In almost all cases it is illegal to redistribute work. So therefore if you redistributed in most cases it would not be legal but you really need to check the copyright.

合法编辑预编译的jar文件......在几乎所有情况下,重新分配工作都是非法的。因此,如果您在大多数情况下重新分发,那么它将不合法,但您确实需要检查版权。

One way to get around it... shhh I didn't tell you this, is to make the user download the jar legally and have them modify it. Normally this is done by giving them a program to do so. And almost all the time the program involves Byte code, so you should use ASM or BCEL. This will shift the legal implications from you to the user. Therefore the user will be violating the terms of user agreement.

解决它的一种方法...嘘我没有告诉你这个,是让用户合法地下载jar并让他们修改它。通常这是通过给他们一个程序来完成的。几乎所有程序都涉及字节代码,所以你应该使用ASM或BCEL。这将把您的法律影响转移给用户。因此,用户将违反用户协议的条款。

For example I used to be apart of the development team for a runescape bot, They used java so we had the user download the jar from the game as they needed anyway and before running it we would inject listeners in the jar. Using BCEL or Reflection

例如,我曾经是runescape机器人的开发团队的一部分,他们使用java,所以我们让用户无论如何都需要从游戏中下载jar,在运行它之前我们会在jar中注入监听器。使用BCEL或反射

#1


Tomcat: LifecycleException when deploying

Tomcat:部署时出现LifecycleException

Based on the post referenced above you might be missing some start up, note that there should be a log file for a more detailed error report.

基于上面引用的帖子,您可能会遗漏一些启动,请注意应该有一个日志文件以获取更详细的错误报告。

Also the legally behind editing pre-compiled jar files... In almost all cases it is illegal to redistribute work. So therefore if you redistributed in most cases it would not be legal but you really need to check the copyright.

合法编辑预编译的jar文件......在几乎所有情况下,重新分配工作都是非法的。因此,如果您在大多数情况下重新分发,那么它将不合法,但您确实需要检查版权。

One way to get around it... shhh I didn't tell you this, is to make the user download the jar legally and have them modify it. Normally this is done by giving them a program to do so. And almost all the time the program involves Byte code, so you should use ASM or BCEL. This will shift the legal implications from you to the user. Therefore the user will be violating the terms of user agreement.

解决它的一种方法...嘘我没有告诉你这个,是让用户合法地下载jar并让他们修改它。通常这是通过给他们一个程序来完成的。几乎所有程序都涉及字节代码,所以你应该使用ASM或BCEL。这将把您的法律影响转移给用户。因此,用户将违反用户协议的条款。

For example I used to be apart of the development team for a runescape bot, They used java so we had the user download the jar from the game as they needed anyway and before running it we would inject listeners in the jar. Using BCEL or Reflection

例如,我曾经是runescape机器人的开发团队的一部分,他们使用java,所以我们让用户无论如何都需要从游戏中下载jar,在运行它之前我们会在jar中注入监听器。使用BCEL或反射