Run JBoss 7 in debug mode

As you already know JBoss 7.1 is released. It is great, it has still many open bugs, but I like it a lot 🙂

If you want to debug your application, which is running on JBoss 7, then you should run JBoss in debug mode. This is very easy. Open a GNU/Linux terminal and execute these commands:

$> cd /path/to/jboss7/bin
$> export JAVA_OPTS="-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
$> ./standalone.sh -c standalone-full.xml
JAVA_OPTS already set in environment; overriding default settings with values: -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
...
Listening for transport dt_socket at address: 8787
...
22:32:45,730 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss AS 7.1.0.Final "Thunder" started in 2907ms - Started 168 of 244 services (75 services are passive or on-demand)

OK, server started in debug mode. Now, you have to deploy your application to JBoss 7.
You can deploy your application to JBoss 7 using the new CLI tool (which is really cool):

$> cd /path/to/jboss7/bin
$> ./jboss-cli.sh
[disconnected /] connect
[standalone@localhost:9999 /] deploy /path/to/your/app.war

Check that your application is started and the go to next step.
You can connect your Eclipse (I use Indigo) on debug port (8787) of JBoss and debug your application within Eclipse. Follow this Eclipse path using your mouse 🙂

  1. Run -> Debug Configurations… -> Remote Java Application -> Right click -> New
  2. Then on Connect tab, set these Connection Properties:
    1. Host = localhost
    2. Port = 8787
  3. Then select your Project and in Source tab add extra projects or libraries.
  4. Press Apply button
  5. Press Debug button
  6. You are connected!!!
  7. Add a Breakpoint in your code
  8. Trigger your application to reach a Breakpoint
  9. Voila 🙂
Eclipse debug application

Eclipse debug application

Happy hacking 🙂

Regards,
Adrianos Dadis.

Democracy Requires Free Software

Advertisements

About Adrianos Dadis

Building Big Data & Streaming processing solutions in telcos business domain. Interested in distributed systems and enterprise integration.
This entry was posted in Java, Java EE, JBoss, Software Development and tagged , , , . Bookmark the permalink.

7 Responses to Run JBoss 7 in debug mode

  1. Chris Smith says:

    Hi Adrianos,

    I ran across your blog while looking for content for DZone’s Javalobby (java.dzone.com) and was wondering if you would be interested in having some of your recent posts republished on our site. If so, please send me an email so I can provide some more information.

    Thanks,

    Chris Smith

  2. Vaclav says:

    Thanks for this post:)

  3. Pingback: JavaPins

  4. Anonymous says:

    Yes it does have many bugs … so what about debugging the Application Server itself ! ?

    • Adrianos Dadis says:

      This kind of dive (into the heart of jboss code) was my first deep dive in the world/code of a big enterprise software. I believe it helped me a lot to become a better software engineer and also teach me to write code with imagination. The first dive in jboss code was many years ago and I really appreciate these guys. I believe they open a door to java proprietary software and I really thanks these guys.
      I know that JBoss 7 still has many bugs, but I know that guys there are working on them very hard.
      Your proposition may be one of the best exercises to become a better engineer.

  5. Anonymous says:

    Thanks for the post but it does not work on Jboss 7.1.1.Final under Mac OSX 10.8.x with Java 7

    • Adrianos Dadis says:

      I have already used this option on JBoss 7.1.1.Final with Java 7 and it works.

      I do not own a Mac, but this should not be related.
      Check out the final options that your java process run.

Post your thought

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s