9 Replies Latest reply on Sep 23, 2011 3:46 AM by viggo.navarsete

    How to debug embedded JBoss ?




      I am running embedded JBoss AS for unit testing and I would like to know if there is a way to enable debugging.

      I know that I can start JBoss AS with debugging enabled (set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n %JAVA_OPTS%), but I do not know how to do that with the embedded version.
      I would really appreciate any help.

        • 1. Re: How to debug embedded JBoss ?

          JBoss Embedded is running in the same JavaVM as your unit test, so you have to start your unit test in debug mode.


          This all depends on how your actually running it, but;


          Eclipse: use "debug as" instead of "run as" to start the test

          Maven: mvn -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -Xnoagent -Djava.compiler=NONE" test






          1 of 1 people found this helpful
          • 2. Re: How to debug embedded JBoss ?

            Hi Aslak,

            Thanks for your answer.


            I am using Netbeans 6.5 - do you have some suggestion regarding this IDE debug configuration ?

            • 3. Re: How to debug embedded JBoss ?
              • 4. Re: How to debug embedded JBoss ?

                This link, unfortunately, does not help - it's describing NetBeans 4.0 + JUnit, while I am working on NetBeans 6.5 + TestNG.

                I have tried using NetBeans 6.8 + TestNG plugin - no success.

                The thing is I am trying to perform my tests using Ant and before my TestNG runner starts, some files get compiled and then copied to some folders, so right-clicking the TestNG method does not work ...

                • 5. Re: How to debug embedded JBoss ?

                  I've found out how to debug my TestNG test when running on JBoss embedded:added some <jvmarg value="..." /> in my Ant target which started the tests, something like:


                  <target name="test" depends="-buildtest" description="Run the tests">
                       <echo>bootstrap dir: ${bootstrap.dir}</echo>
                       <taskdef resource="testngtasks" classpath="${testng.jar}" />
                       <testng outputdir="${basedir}/test-report">
                            <classpath refid="test.classpath" />
                            <xmlfileset dir="." includes="testng.xml" />
                           <jvmarg value="-Xdebug"/>
                            <jvmarg value="-Xrunjdwp:transport=dt_socket,address=6789,server=y,suspend=y"/>




                  After starting this target, inside the NetBeans output window I see:


                  bootstrap dir: ../../common/builds/../bootstrap
                  Listening for transport dt_socket at address: 6789


                  In this moment I can attach the NetBeans debugger and I can debug my code.

                  The most important config params are the ones in bold red.

                  1 of 1 people found this helpful
                  • 6. Re: How to debug embedded JBoss ?

                    Any updates on this? I would also like to know how to debug a test when running an embedded JBoss container. Description in either Eclipse or Netbeans would be great. "Debug As" doesn't work in Eclipse, it doesn't use the profile:( I've tried to set it as the active profile, but still doesn't work.

                    • 7. Re: How to debug embedded JBoss ?

                      if you activate the profile using m2eclipse, and just run debug-as should work

                      • 8. Re: How to debug embedded JBoss ?

                        I tried activating the profile the way you described Aslak, but this is the output in Eclipse when debuggin the test (Debug As-JUnit Test):


                        Sep 21, 2011 11:10:26 AM org.jboss.arquillian.container.impl.client.container.ContainerRegistryCreator getActivatedConfiguration

                        INFO: Could not read active container configuration: null

                        Boot Log available in: /tmp

                        log4j:WARN No appenders could be found for logger (org.jboss.bootstrap.impl.base.server.AbstractServer).

                        log4j:WARN Please initialize the log4j system properly.

                        • 9. Re: How to debug embedded JBoss ?

                          According to Aslak you need to set JBOSS_HOME for *each test* when debugging in Eclipse.

                          Please go to Debug Configurations, pick the test you want to debug, click on Environment, click New, set JBOSS_HOME as name and the path to your JBoss installation as value. Now you should be able to debug your test from Eclipse:)