<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JavaPulse &#187; debugging</title>
	<atom:link href="http://javapulse.net/tag/debugging/feed/" rel="self" type="application/rss+xml" />
	<link>http://javapulse.net</link>
	<description>a finger on the pulse of the freelance Java&#0153; market in the Netherlands</description>
	<lastBuildDate>Sat, 19 Jun 2010 11:00:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Axis 1.4 dependency conflicts in Maven</title>
		<link>http://javapulse.net/2007/09/22/axis-14-dependency-conflicts-in-maven/</link>
		<comments>http://javapulse.net/2007/09/22/axis-14-dependency-conflicts-in-maven/#comments</comments>
		<pubDate>Sat, 22 Sep 2007 23:27:54 +0000</pubDate>
		<dc:creator>Clara Ko</dc:creator>
				<category><![CDATA[axis]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://javapulse.net/2007/09/22/axis-14-dependency-conflicts-in-maven/</guid>
		<description><![CDATA[Awhile back, I was converting an existing project from an Ant build to a Maven build. The project used Axis to send some soap messages. With the Ant build as a reference, I added the appropriate dependencies. But with the Maven build, the Axis call invoke method returned null without throwing an exception. Properly designed [...]]]></description>
			<content:encoded><![CDATA[<p>Awhile back, I was converting an existing project from an Ant build to a Maven build. The project used Axis to send some soap messages. With the Ant build as a reference, I added the appropriate dependencies. But with the Maven build, the Axis call invoke method returned null without throwing an exception. Properly designed software would normally throw a useful exception. And I expect Axis would do so, since it is used so often. I was not able to find anything on the internet that described this problem. And even downloading Axis and debugging through it didn&#8217;t reveal what was happening.</p>
<p>Finally, I noticed that the Maven build (maven-dependency-plugin:copy-dependencies) added more external jars in the classpath than was previously in the Ant build. It contained gnujaxp which was added transitively by jfreechart, also used by the application. By excluding gnujaxp, the Axis call finally worked as expected. I guess the moral of the story is: when getting completely unexpected behavior, there is a good chance that it is dependency conflicts. Looking carefully at the Maven copied dependencies could reveal any unnecessary dependencies. It would be useful to know which part of the code uses which dependencies. In any case, I wonder how many implementation of jaxp are out there.</p>
]]></content:encoded>
			<wfw:commentRss>http://javapulse.net/2007/09/22/axis-14-dependency-conflicts-in-maven/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jConsole &#8211; Application Memory Monitoring in Java 1.5</title>
		<link>http://javapulse.net/2007/09/03/jconsole-application-memory-monitoring-in-java-15/</link>
		<comments>http://javapulse.net/2007/09/03/jconsole-application-memory-monitoring-in-java-15/#comments</comments>
		<pubDate>Mon, 03 Sep 2007 12:05:08 +0000</pubDate>
		<dc:creator>Clara Ko</dc:creator>
				<category><![CDATA[debugging]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://javapulse.net/2007/09/03/jconsole-application-memory-monitoring-in-java-15/</guid>
		<description><![CDATA[Java 1.5 &#8211; Application Memory Monitoring Made Easy
]]></description>
			<content:encoded><![CDATA[<li><a href="http://rgarg.blogspot.com/2007/09/java-15-application-memory-monitoring.html">Java 1.5 &#8211; Application Memory Monitoring Made Easy</a><br />
]]></content:encoded>
			<wfw:commentRss>http://javapulse.net/2007/09/03/jconsole-application-memory-monitoring-in-java-15/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Profiling</title>
		<link>http://javapulse.net/2007/03/28/java-profiling/</link>
		<comments>http://javapulse.net/2007/03/28/java-profiling/#comments</comments>
		<pubDate>Wed, 28 Mar 2007 08:22:37 +0000</pubDate>
		<dc:creator>Clara Ko</dc:creator>
				<category><![CDATA[debugging]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://javapulse.net/?p=71</guid>
		<description><![CDATA[A while back, I was tracking a memory leak in an application and was able to track it down using a trial version of JProbe Memory. Because I was dealing with a monstrous piece of old code, the massive amount of data produced (i.e. the amount of time spent in each method over a set [...]]]></description>
			<content:encoded><![CDATA[<p>A while back, I was tracking a memory leak in an application and was able to track it down using a trial version of <a href="http://www.quest.com/jprobe/">JProbe Memory</a>. Because I was dealing with a monstrous piece of old code, the massive amount of data produced (i.e. the amount of time spent in each method over a set timespan, where you have to go deep into a tree) was not really helpful to see where the leak was. Instead, I continuously cut the application down by taking out pieces of code until the realtime line graph of the memory usage no longer showed an increase in memory. So, the profiler was a helpful tool in the diagnosis of the problem, but it&#8217;s really good old-fashion deduction that did it.</p>
<p>Since I fixed that memory leak, I haven&#8217;t had a chance to look into profilers and am just lately wondering about to do some performance profiling. The realtime graphs in JProbe has an advantage over cheaper options (no pricing on the website, since it&#8217;s really for big companies who care to profile).</p>
<p>What is your experience with profilers?</p>
]]></content:encoded>
			<wfw:commentRss>http://javapulse.net/2007/03/28/java-profiling/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Test Development with TestNG and Maven</title>
		<link>http://javapulse.net/2007/03/11/test-development-with-testng-and-maven/</link>
		<comments>http://javapulse.net/2007/03/11/test-development-with-testng-and-maven/#comments</comments>
		<pubDate>Sun, 11 Mar 2007 09:15:08 +0000</pubDate>
		<dc:creator>Clara Ko</dc:creator>
				<category><![CDATA[debugging]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://javapulse.net/?p=67</guid>
		<description><![CDATA[Update following the discussion in the comments:
The reason for not running/debugging my tests from within Netbeans is because the Netbeans TestNG plugin is not up-to-date. I&#8217;m using TestNG 5.5 while the plugin is written for 4.6 or something like that. I&#8217;m sure that if I&#8217;m using either Eclipse with TestNG or JUnit with Netbeans, the [...]]]></description>
			<content:encoded><![CDATA[<p>Update following the <a href="http://javapulse.net/?p=67#comments">discussion</a> in the comments:<br />
The reason for not running/debugging my tests from within Netbeans is because the Netbeans TestNG plugin is not up-to-date. I&#8217;m using TestNG 5.5 while the plugin is written for 4.6 or something like that. I&#8217;m sure that if I&#8217;m using either Eclipse with TestNG or JUnit with Netbeans, the plugins might be more up-to-date. But, the solution below works for me for now.</p>
<hr/>
<p>As part of a huge refactoring effort, I&#8217;m working with the TestNG, Maven, Netbeans. Not surprisingly, everything has not been a breeze. So I put together these steps to set up test development using TestNG and Maven, and debugging with any IDE. In fact, TestNG can be easily replaced by JUnit here. It&#8217;s more about getting around the <a href="http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html">Maven build life cycle</a> during test development.</p>
<p><b>1) Skipping the Maven test phase until test development is complete</b></p>
<p>The first problem I encountered was that the jars get created at the install phase near the end of the Maven build life cycle, which means that if the tests fail, the jar never gets created. Apparently, this is not meant for test development. The solution is to turn off the test phase by setting skip to true in the configuration of the surefire plugin, until all tests pass and can be used for automated testing.<br />
            &lt;plugin&gt;<br />
                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;<br />
                &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;<br />
                &lt;configuration&gt;<br />
                    <b>&lt;skip&gt;true&lt;/skip&gt;</b><br />
                    &lt;suiteXmlFiles&gt;<br />
                        &lt;suiteXmlFile&gt;src/test/config/testng.xml&lt;/suiteXmlFile&gt;<br />
                    &lt;/suiteXmlFiles&gt;<br />
                &lt;/configuration&gt;<br />
            &lt;/plugin&gt;</p>
<p><b><a name="copy">2) Copying all dependencies to target/lib</a></b></p>
<p>This is usually done for any jar that is an executable (contains a main method), so that you can reference the dependencies easily from within the jar manifest.</p>
<p>            &lt;plugin&gt;<br />
                &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;<br />
                &lt;artifactId&gt;dependency-maven-plugin&lt;/artifactId&gt;<br />
                &lt;executions&gt;<br />
                    &lt;execution&gt;<br />
                        &lt;id&gt;copy-dependencies&lt;/id&gt;<br />
                        &lt;phase&gt;package&lt;/phase&gt;<br />
                        &lt;goals&gt;<br />
                            &lt;goal&gt;copy-dependencies&lt;/goal&gt;<br />
                        &lt;/goals&gt;<br />
                        &lt;configuration&gt;<br />
                            &lt;outputDirectory&gt;${project.build.directory}/lib&lt;/outputDirectory&gt;<br />
                            &lt;overWriteReleases&gt;false&lt;/overWriteReleases&gt;<br />
                            &lt;overWriteSnapshots&gt;true&lt;/overWriteSnapshots&gt;<br />
                        &lt;/configuration&gt;<br />
                    &lt;/execution&gt;<br />
                &lt;/executions&gt;<br />
            &lt;/plugin&gt;</p>
<p><b><a name="manifest">3) Referencing dependencies in the jar manifest</a></b></p>
<p>The following creates a manifest in the jar with references to all the dependencies previously copied to lib. Note that the classPrefix is lib.</p>
<p>            &lt;plugin&gt;<br />
                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;<br />
                &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;<br />
                &lt;configuration&gt;<br />
                    &lt;jarName&gt;myapp&lt;/jarName&gt;<br />
                    &lt;archive&gt;<br />
                        &lt;manifest&gt;<br />
                            &lt;mainClass&gt;com.mycompany.MyApp&lt;/mainClass&gt;<br />
                            &lt;addClasspath&gt;true&lt;/addClasspath&gt;<br />
                            &lt;classpathPrefix&gt;lib&lt;/classpathPrefix&gt;<br />
                        &lt;/manifest&gt;<br />
                    &lt;/archive&gt;<br />
                &lt;/configuration&gt;<br />
            &lt;/plugin&gt;</p>
<p><b>4) Packaging the tests</b></p>
<p>Next, I add a Maven goal to produce a jar of the test sources.</p>
<p>  mvn clean install <b>jar:test-jar</b></p>
<p>This produces a jar (myapp-tests.jar) in your target directory next to your normal jar (myapp.jar)</p>
<p><b>5) Running the tests with TestNG</b></p>
<p>Then, I run the tests on the command line using TestNG instead of via Maven.</p>
<p>java -cp ./target/myapp.jar;./target/myapp-tests.jar; org.testng.TestNG ./src/test/config/testng.xml</p>
<p>I put the testng.xml in the config directory instead of resources because it is a runtime configuration and does not need to be part of the jar. Everything in the resources directory gets added to the jar.</p>
<p><b>6) Debugging the tests</b><br />
Debugging the tests is simple.</p>
<p>java <b>-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,address=8888</b> -cp ./target/myapp.jar;./target/myapp-tests.jar; org.testng.TestNG ./src/test/config/testng.xml</p>
<p>From your IDE, attach your debugger to port 8888 using a SocketAttach to attach to an external program.</p>
]]></content:encoded>
			<wfw:commentRss>http://javapulse.net/2007/03/11/test-development-with-testng-and-maven/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Current Class and Method</title>
		<link>http://javapulse.net/2007/03/01/current-class-and-method/</link>
		<comments>http://javapulse.net/2007/03/01/current-class-and-method/#comments</comments>
		<pubDate>Thu, 01 Mar 2007 14:28:41 +0000</pubDate>
		<dc:creator>Clara Ko</dc:creator>
				<category><![CDATA[debugging]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://javapulse.net/?p=68</guid>
		<description><![CDATA[Current class is easy:

  String currentClass() {
    return this.getClass().getSimpleName();
  }

Current method:

  String currentMethod() {
    return Thread.currentThread().getStackTrace()[3].getMethodName();
  }

The number in the stack trace changes depending on how far down you bury this call.
Really handy for unit testing or debug logging (remember to wrap debug logging with [...]]]></description>
			<content:encoded><![CDATA[<p>Current class is easy:<br />
<code><br />
  String currentClass() {<br />
    return this.getClass().getSimpleName();<br />
  }<br />
</code></p>
<p>Current method:<br />
<code><br />
  String currentMethod() {<br />
    return Thread.currentThread().getStackTrace()[3].getMethodName();<br />
  }<br />
</code><br />
The number in the stack trace changes depending on how far down you bury this call.<br />
Really handy for unit testing or debug logging (remember to wrap debug logging with logger.isDebug()).</p>
]]></content:encoded>
			<wfw:commentRss>http://javapulse.net/2007/03/01/current-class-and-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
