Showing posts with label debug. Show all posts
Showing posts with label debug. Show all posts

Tuesday, February 5, 2013

Java Web Start: debugging

Have you ever been in a need to debug JWS application?

One way to do the trick is to adapt environment variable: JAVAWS_VM_ARGS

As I'm running linux and need this in my daily work, I added following to my .bashrc file:
export JAVAWS_VM_ARGS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=9010,server=y,suspend=n -XX:MaxPermSize=128m"

Some notes:
  • suspend=n - this makes sence for me, as I'm not waiting for debugger to connect. To make sure I connect only once I'm interested. And app won't get stuck
  • -XX:MaxPermSize=128m - is not related to debugging but rather to memory, feel free to remove/adapt to your needs

After jws runs, I can connect from eclipse to port configured, in my case: 9010 (use the one that fits your environment) and remotely debug the app.

That's it. Easy, right?

There are however also some disadvatages of my simple solution.
Major one is that I can have only one JWS instance running at time. As there is a port conflict (same ons is in use for every one), but I can live with that.

Monday, February 4, 2013

Maven: debugging

If you've ever been in the situation that you'd need to debug maven build, these are the options that could help.

Debugging maven run

If you need to debug maven plugins run itself use instead of standard:
mvn <your sfuff>
the debug one:
mvnDebug <your sfuff>
It should tell you it's waiting for connection, in a way like this:
Preparing to Execute Maven in Debug Mode
Listening for transport dt_socket at address: 8000
Afterwards use your preffered way to connect to socket 8000 via remote debugger. (For eclipse steps can be found here, or googled)

Debugging test execution

If you need to debug maven-surefire-plugin run use following:
mvn -Dmaven.surefire.debug test
It would wait for connection, in a way like this:
Listening for transport dt_socket at address: 5005
Afterwards use your preffered way to connect to socket 5005 via remote debugger. (For eclipse steps can be found here, or googled)
Easy, isn't it?

Saturday, February 11, 2012

maven web app development

I came to point where I needed to build simple java based web application that would have as short as possible deployment time.

OK this is the way I had to follow, hope it can help to make your path simple :)

1. The first decision I made was to go for embedded web server => Jetty can do the job.

2. Maven and jetty are friends => can be run using: jetty:run
config details can be found on:
http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin

Where the benefit is that you won't even need to build war (save quite some time during deployment), to have your web app up and running.

3. But I needed to debug when launching from eclipse (using m2e plugin).
Tried a solution with m2e having: MAVEN_OPTS set + remote app debug, as suggested:
http://docs.codehaus.org/display/JETTY/Debugging+with+the+Maven+Jetty+Plugin+inside+Eclipse

this however didn't work for m2e, seems I'm not the only person with this problem, see: http://comments.gmane.org/gmane.comp.ide.eclipse.plugins.m2eclipse.user/7565


4. So I tried: m2e-webby integration:
https://docs.sonatype.org/display/M2ECLIPSE/Integration+with+Maven+WAR+Plugin
and it works great!
It even reads my pom.xml jetty relevant config.

Feel free to spread your experiences in comments section with java web apps development and what is your perfect setup.