JBoss EAP 6 configure single server for remote debugging in domain mode

此生再无相见时 提交于 2020-01-23 10:50:08

问题


I have Domain controller, one Host controller and one server running in the same machine.

I'm using IDEA to connect to the remote server for debugging but it's not stopping on break points even though it's running the code (i've verified with system outs).

I've enabled HOST_CONTROLLER_JAVA_OPTS and PROCESS_CONTROLLER_JAVA_OPTS for remote debugging in $JBOSS_HOME/bin/domain.conf:

# Sample JPDA settings for remote socket debuging.
PROCESS_CONTROLLER_JAVA_OPTS="$PROCESS_CONTROLLER_JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8788,server=y,suspend=n"
HOST_CONTROLLER_JAVA_OPTS="$HOST_CONTROLLER_JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"

When i start JBoss server i can see from netstat that it's properly listening to ports 8787 and 8788. If i list the processes running in the system i can see one for Domain controller, one for Host controller and one for the server (server1). Domain and Host controllers have the debug options specified in their launch properties but they're missing for server1.

I've been looking at the various XML, .conf and .sh files for a while now but i can't figure out how i could specify server1 to use the remote debugging options. Is there a way to remotely debug a single server in domain mode?


回答1:


JHollanti maybe you are missing some compiler flags (like "lines,vars,source") to allow remote debugging.

For example, is you are using Ant you need to add this lines to your javac:

<!-- Javac lines, vars, source compiler flags -->
<javac srcdir="..." destdir="..." classpathref="..." debug="true" debuglevel="lines,vars,source" />

Then in your execution script you jave to add:

<!-- debug configurations: modify the port you want-->
<jvmarg value="-Xdebug"/>
<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=4060"/>

On the other hand, if you are using Maven same flags can be added in the , like this:

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>2.0.2</version>
      <configuration>
        <!-- Necessary in order for the debug levels to be considered-->
        <debug>true</debug>
        <debugLevel>lines,vars,source</debugLevel>
      </configuration>
    </plugin>
  </plugins>
</build>

In case of using Jetty, same as before... you need to have the following variable:

export MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n"

On the other hand, what you can check is setting the suspend flag in yes, it is "suspend=y". This won't start your app unless you connect a debugger.

Here you can check specific info about jboss:

http://webdev.apl.jhu.edu/~jcs/ejava-javaee/coursedocs/605-784-site/docs/content/html/devenv-jboss-setup.html#enable-jboss-debug

Hope to help




回答2:


Hey I don't have a solution to this however I was able to set the port for server one along with host and process controllers as well. How I did it : I added the "-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n" to the JVM arguments on the jboss admin console. Steps: 1) Login to admin console of jboss => localhost:9990/console 2) go to servers => select server 1 in the table. 3) Then add the debug string into JVM arguments text box.

Once you restart your server you'll see now the server one is listening on this port. However problem came when I tried to run my eclipse in debug mode. Though on the sever I could see the connection was established through netstat however eclipse is not able to communicate to server 1 and it times out. Important thing to be noticed is I'm able to run eclipse in debug mode if I do what you did in domain.conf file and use those ports; however then the control never comes to my breakpoint in eclipse.




回答3:


You can enable remote debugging by adding jvm-options in $JBOSS_HOME$\domain\configuration\hosts.xml

Add the following configuration under <servers> -> <server> -> <jvm>

<jvm-options>
   <option value="-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"/>
</jvm-options>

your server configuration in hosts.xml should look something similar to this

<servers>
    <server name="Server1" group="Group1" auto-start="true">
        <jvm name="Server1_JVM" debug-enabled="false">
            <heap size="2048m" max-size="4096m"/>
            <jvm-options>
                <option value="-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"/>
            </jvm-options>
        </jvm>
        <socket-bindings socket-binding-group="full-ha-sockets" port-offset="100"/>
    </server>
</servers>

Hope this helps!



来源:https://stackoverflow.com/questions/19888666/jboss-eap-6-configure-single-server-for-remote-debugging-in-domain-mode

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