<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Remote Debugging for Eclipse Test Plug-in Running by Tycho
</h3>
<span style="margin-bottom: 10px;">
    modified by <a href="http://community.jboss.org/people/dgolovin">Denis Golovin</a> in <i>JBoss Tools Development</i> - <a href="http://community.jboss.org/docs/DOC-15209">View the full document</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><div> </div><p>When I report issue in bug tracking system about nightly build's JUnit test error I usually get simple answer that it is supposed to be working&#160; because it is working on developer's workstation. After that routine conversation starts and it turns out that tests were running from development environment under Eclipse. Here I usually have to explain again and again that's not the same running tests from development environment and in build.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The right way to make yourself sure your tests will work in most cases without errors in nightly build is to start tests the same way as nightly build does. It was not easy for JBoss Tools tests until we created experimental branch and switched to Maven Tycho project. That means it is fairly easy to run tests now. Basically you need to change current directory and execute maven install goal. If it runs in development environment and in maven your tests are good and in most cases it should be fine in nightly build. Problems begin if it runs in development environment but it doesn't in maven. In this scenario you need to debug tests running in Tycho somehow and fix it. Fortunately it can be done using Java remote debugging support.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>First of all you need to be sure you have built your sources you're going to debug and there is no differences between .java and&#160; .class files. If you're going find problem from previous build just get right tagged version and build it before debugging session.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>There are two options to use remote debugger</p><ol><li>Simple use of -DdebugPort=8001 or what ever port you would like to use</li><li>Add full argLine for remote debugging configuration im pom.xml</li></ol><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h1>Use of debugPort system properties</h1><p>To use this just add -DdebugPort=&lt;portNumber&gt; to your maven command line replacing &lt;portNumber&gt; for desired port and make sure you have the same port configured in your Remote Java Application configuration in Eclipse Debug Configuration dialog as it explained for second option below.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h1>Use full argLine for remote debugging configuration in pom.xml</h1><p>Open pom.xml for your Eclipse Test Plug-in and add Java VM arguments like it shown below (actual port numbers, server names and&#160; other parameters may be different, it depends from your environment)</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag">&lt;build&gt;</span>
<span class="jive-xml-tag">&lt;plugins&gt;</span>
<span class="jive-xml-tag">&lt;plugin&gt;</span>
&#160;&#160;&#160; <span class="jive-xml-tag">&lt;groupid&gt;</span>org.sonatype.tycho<span class="jive-xml-tag">&lt;/groupid&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;artifactid&gt;</span>maven-osgi-test-plugin<span class="jive-xml-tag">&lt;/artifactid&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;version&gt;</span>${tycho-version}<span class="jive-xml-tag">&lt;/version&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;configuration&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;argline&gt;</span>-Xdebug -Xrunjdwp:transport=dt_socket,address=8001,server=y,suspend=y<span class="jive-xml-tag">&lt;/argline&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/configuration&gt;</span>
&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/plugin&gt;</span>
<span class="jive-xml-tag">&lt;/plugins&gt;</span>
<span class="jive-xml-tag">&lt;/build&gt;</span>



</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This snipped configured for remote debugging in OpenJDK 6, if your is different you might need to read <a class="jive-link-anchor-small" href="#r1"><span>[1]</span></a> and configure it right for your JVM version.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Configure java projects with sources you're going to debug in Eclipse and create Remote Java Application configuration in Eclipse Debug Configuration dialog. Fill 'host' and 'port' fields with the same values from pom.xml argLine element. Press Apply button to save your changes and start your test plug-in from terminal like</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">$mvn install
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>It will go through build process and finally you ll see something like</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">[INFO] Expected eclipse log file: /home/eskimo/Projects/jbt-modular/jst/tests/org.jboss.tools.jst.web.kb.test/target/work/data/.metadata/.log
[INFO] Command line:
 /bin/sh -c cd /home/eskimo/Projects/jbt-modular/jst/tests/org.jboss.tools.jst.web.kb.test &amp;&amp; /usr/lib/jvm/java-6-openjdk/jre/bin/java -Dosgi.noShutdown=false -Dosgi.os=linux -Dosgi.ws=gtk -Dosgi.arch=x86 -agentlib:jdwp=transport=dt_socket,address=8001,server=y,suspend=y -jar /home/eskimo/.m2/repository/p2/osgi/bundle/org.eclipse.equinox.launcher/1.0.201.R35x_v20090715/org.eclipse.equinox.launcher-1.0.201.R35x_v20090715.jar -data /home/eskimo/Projects/jbt-modular/jst/tests/org.jboss.tools.jst.web.kb.test/target/work/data -dev file:/home/eskimo/Projects/jbt-modular/jst/tests/org.jboss.tools.jst.web.kb.test/target/dev.properties -install /home/eskimo/Projects/jbt-modular/jst/tests/org.jboss.tools.jst.web.kb.test/target/work -configuration /home/eskimo/Projects/jbt-modular/jst/tests/org.jboss.tools.jst.web.kb.test/target/work/configuration -application org.codehaus.tycho.surefire.osgibooter.uitest -testproperties /home/eskimo/Projects/jbt-modular/jst/tests/org.jboss.tools.jst.web.kb.test/target/surefire.properties
Listening for transport dt_socket at address: 8001



</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>At this point build is waiting for you to attach remote debugger to the process because of using</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">suspend=y
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>in argLine element of your pom.xml file. So you need to return to eclipse and hit 'Debug' button in dialog opened before.</p><p>Build will continue at this point and stop on your break points so you can find out what is wrong with tests during nightly build.</p><p><a class="jive-link-anchor-small" name="r1">[1] </a><a class="jive-link-external-small" href="http://java.sun.com/javase/technologies/core/toolsapis/jpda/#Invocation">Java&#160; Platform Debugger Architecture -&#160; http://java.sun.com/javase/technologies/core/toolsapis/jpda/#Invocation</a></p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Comment by <a href="http://community.jboss.org/docs/DOC-15209">going to Community</a></p>

        <p style="margin: 0;">Create a new document in JBoss Tools Development at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=102&containerType=14&container=2129">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>