如何在 JBoss 中使用 Java“热代码替换”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/538261/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 12:47:11  来源:igfitidea点击:

How do I get Java "hot code replacement" working in JBoss?

javadebuggingjboss

提问by Brett

I am running JBoss 4.0.3.SP1_CP04 and connecting to it with Eclipse 3.4.1's debugger, both using JDK 1.6.0_11.

我正在运行 JBoss 4.0.3.SP1_CP04 并使用 Eclipse 3.4.1 的调试器连接到它,两者都使用 JDK 1.6.0_11。

When I make a minor change to a method (e.g. changing a "+ 1" in the logic to a "+ 2") and save it, I immediately receive an error message dialog titled "Hot Code Replace Failed" with the error "Delete method not implemented"

当我对方法进行细微更改(例如将逻辑中的“+ 1”更改为“+ 2”)并保存它时,我立即收到一个标题为“热代码替换失败”的错误消息对话框,并显示错误“删除”方法未实施”

Hot code replace failed dialog http://img6.imageshack.us/img6/531/hotcodereplacefailedkp6.png

热代码替换失败对话框 http://img6.imageshack.us/img6/531/hotcodereplacefailedkp6.png

Can anyone suggest steps for getting this to work?

任何人都可以建议让这个工作的步骤吗?

回答by Chase Seibert

What you want to do is deploy to JBOSS as an exploded WAR. Typically, if an editor does the initial deploy itself, it will then manage copying individual files over as they change.

您想要做的是作为爆炸式 WAR部署到 JBOSS 。通常,如果编辑器自己进行初始部署,那么它将在单个文件更改时管理复制它们。

In IntelliJ, this is easy. I have never done it from Eclipse, but this projectis your best bet.

在 IntelliJ 中,这很容易。我从来没有在 Eclipse 上做过,但这个项目是你最好的选择。

回答by Javamann

I have been using JRebeland it's a life saver as far as modifying code and dynamically updating the app server. Paid for itself the first day. (we have a 7 minute compile/deploy/restart cycle)

我一直在使用JRebel,就修改代码和动态更新应用程序服务器而言,它是一个救星。第一天自己付钱。(我们有 7 分钟的编译/部署/重启周期)

回答by phantom4

  1. Before running debugger in Eclipse insure all projects in your workspace are refreshed (it is required if code was changed outside Eclipse, e.g. after getting changes from version control system using outside tool)
  2. In Java Build Path of Eclipse insure you don't include as a part of some library classes which you are trying to hot swap
  3. Check that Eclipse JRE = JBoss JRE
  4. Check class you are trying to hot swap. Does it have inner classes? I just run into issue when I can't swap class with inner class, while other classes are swapped without issues.
  1. 在 Eclipse 中运行调试器之前,确保刷新工作区中的所有项目(如果代码在 Eclipse 外部发生更改,则需要这样做,例如在使用外部工具从版本控制系统获取更改之后)
  2. 在 Eclipse 的 Java 构建路径中,确保您没有将您尝试热插拔的某些库类包含在其中
  3. 检查 Eclipse JRE = JBoss JRE
  4. 检查您正在尝试热插拔的课程。它有内部类吗?当我无法将类与内部类交换时,我就遇到了问题,而其他类可以毫无问题地交换。

回答by Roman

The reason is that the assembly can be used another compiler that hot swap. For example, if you build project by maven, we used javac. When you try to perform a hot swap etslipse uses built-in compiler jdt compiler(compiler is not taken from installed jdk and can not be changed by regular means.). Binary classes obtained are different and jvm can not replace them.

原因是该程序集可以使用另一个编译器进行热插拔。例如,如果您通过maven构建项目,我们使用javac。当您尝试执行热插拔时,etslipse 使用内置编译器 jdt 编译器(编译器不是从已安装的 jdk 中提取的,不能通过常规方式更改。)。得到的二进制类不同,jvm无法替代。

回答by Ron

What you described should work. What are your jvm args to jboss to enable debugging?

你描述的应该有效。你的 jvm args 是什么 jboss 来启用调试?

Mine are these: -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n

我的是这些: -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n

回答by user513365

I had an issue where hot code replacement itself was not working. We did some changes like making sure that the "build automatically" was checked and unchecking the - "abort build when an build path error occurs". But in my case, HCR itself was not working. I wasnt getting the message as you mentioned. More details are in this link. https://sites.google.com/site/javaerrorsandsolutions/home/hot-code-replacement

我遇到了热代码替换本身不起作用的问题。我们做了一些更改,例如确保选中“自动构建”并取消选中“发生构建路径错误时中止构建”。但就我而言,HCR 本身不起作用。我没有收到你提到的消息。更多细节在这个链接中。 https://sites.google.com/site/javaerrorsandsolutions/home/hot-code-replacement