部署&使用IntelliJ 12调试远程Jetty [英] Deploy & Debug remote Jetty with IntelliJ 12
问题描述
我一直在黑客和谷歌搜索一段时间,我发现了几个statck溢出线程,似乎它们是为旧版本的intellij编写的,带有各种应用程序服务器。通常他们会告诉你输入
java -Xdebug -Xrunjdwp:transport = dt_socket,address = 51887,suspend = n,server = y
jboss issue)
编辑:感谢这个谷歌群组帖子我发现如果你没有指定编辑配置> +> jetty> remote,可以连接调试器,而是选择编辑配置> +>远程,但调试和部署是我所追求的只有一半的解决方案。
Jetty 远程
配置需要几个手动步骤,当您使用本地
配置直接从IDEA启动Jetty时,会自动执行这些步骤。 / p>
如果您绝对必须使用远程
配置,请尝试以下步骤:
在IDEA Jetty远程运行配置的服务器
选项卡的远程登台
部分:
- 指定
相同文件系统
类型
和主机
- 指定
< Jetty home> / contexts $ c的路径$ c>
本地路径中的文件夹
字段上下文
部分
(如果Jetty在另一台机器上运行而不是IDEA,则设置会有所不同,但我认为它是在您的情况下相同的机器)
将以下VM参数传递给Jetty进程:
-Dcom.sun.management.jmxremote =
-Dcom.sun.management.jmxremote.port =< JNDI port>
-Dcom.sun.management.jmxremote.authenticate = false
-Dcom.sun.management.jmxremote.ssl = false
-DOPTIONS = jmx
< JNDI port>
值应与<$ c $中指定的值相同c> JNDI端口 IDEA Jetty运行配置字段
将以下配置文件传递给Jetty进程(在命令行中):
-
etc / jetty-jmx.xml
-
etc / jetty.xml
如果你需要调试,你还应该传递到Jetty进程的VM参数取自IDEA Jetty运行配置:启动/连接
选项卡,选择 Debug
列表项在下调试远程服务器JVM ...
以下是使用all启动Jetty进程的示例命令行必需的选项:
java -Xdebug -Xrunjdwp:transport = dt_socket,address = 60208,suspend = n,server = y - DSTOP.PORT = 0 -Dcom.sun。 management.jmxremote = -Dcom.sun.management.jmxremote.port = 1099 -Dcom.sun.management.jmxremote.authenticate = false -Dcom.sun.management.jmxremote.ssl = false -DOPTIONS = jmx -Dfile.encoding = UTF -8 -classpath start.jar etc / jetty-jmx.xml etc / jetty.xml
I've been hacking and googling for a while now, and I've found several statck overflow threads that seemed like they were written for older versions of intellij, with various application servers. Usually they tell you to enter
java -Xdebug -Xrunjdwp:transport=dt_socket,address=51887,suspend=n,server=y
One answer suggests using something like
-agentlib:jdwp:transport=dt_socket,address=51887,suspend=n,server=y
But then I get this:
Error occurred during initialization of VM
Could not find agent library: libjdwp:transport.jnilib (searched /Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/Libraries:/System/Library/Java/Extensions:/Library/Java/Extensions:.)
Then after one or the other of the above they tell you something like "Edit Configurations> jetty > remote and enter localhost, 51887" (the port number varies)
However in 12, the page you land on after you select remote has a plethora of options, and is asking for JNDI ports, not jdwp ports on another tab it actually suggests the jdwp parameters above.
Researching the JNDI port bit, generally yields instructions to add args like this to your command line...
-Dcom.sun.management.jmxremote= \
-Dcom.sun.management.jmxremote.port=1099 \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false\
I've done that too and I can see port 1099 held by java (using lsof) and I can telnet to 1099, so I know the JVM is listening. (We'll try not to worry about the fact that that appears to say, open up a port by which anyone install arbitrary java code over the network to your computer without a password)
However, in Intellij whenever I try to deploy and debug it gives me the following message:
I can see java RMI communications over 1099 when I snoop port 1099 with wireshark (but they are illegible). Evidently, the communications are not satisfactory for Intellij, so I'm wondering if there's something I need to do to Jetty to get it to play nice. Note that changing the Jetty version is not presently an option, so let's not go there :).
I've also tried removing the artifact, disabling make, and trying to just connect the debugger, but it still gives me the same red baloon and error message, so evidently the JNDI (port 1099) part is required.
Does anyone see something I'm doing wrong, or know of something else I should do to get this to work?
(I'm wondering if it is something similar to this: http://youtrack.jetbrains.com/issue/IDEA-65746 jboss issue)
Edit: Thanks to this google groups post I've discovered that it is possible to get the debugger connected if you don't specify Edit Configurations> + > jetty > remote, but instead choose Edit Configurations > + > remote, but debug and deploy is what I'm after so that's only a half solution.
Jetty remote
configuration requires several manual steps which are performed automatically when you start Jetty directly from IDEA using the local
configuration instead.
If you absolutely must use the remote
configuration, try the following steps:
In the Remote staging
section of the Server
tab of the IDEA Jetty remote run configuration:
- specify
Same file system
forType
andHost
- specify path to the
<Jetty home>/contexts
folder in theLocal path
field of thecontexts
section
(settings will differ if you have Jetty running on another machine than IDEA, but I assume it's the same machine in your case)
Pass the following VM parameters to the Jetty process:
-Dcom.sun.management.jmxremote=
-Dcom.sun.management.jmxremote.port=<JNDI port>
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-DOPTIONS=jmx
<JNDI port>
value should be the same as specified in the JNDI port
field of the IDEA Jetty run configuration
Pass the following configuration files to the Jetty process (in the command line):
etc/jetty-jmx.xml
etc/jetty.xml
If you need to debug, you should also pass to Jetty process VM parameters taken from IDEA Jetty run configuration: Startup/Connection
tab, select Debug
list item under the To debug remote server JVM ...
Here is the sample command line to start Jetty process with all the required options:
java -Xdebug -Xrunjdwp:transport=dt_socket,address=60208,suspend=n,server=y -DSTOP.PORT=0 -Dcom.sun.management.jmxremote= -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -DOPTIONS=jmx -Dfile.encoding=UTF-8 -classpath start.jar etc/jetty-jmx.xml etc/jetty.xml
这篇关于部署&使用IntelliJ 12调试远程Jetty的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!