3 Replies Latest reply on Oct 18, 2005 1:59 PM by mculpepper

    JBoss Eclipse incremental debugging

    dandrasin

      I'm using JBoss Eclipse IDE 1.5M3 (with Seam). I got the booking example working via the method described in http://docs.jboss.com/jbosside/tutorial/build/en/html/
      The server starts up, but i have some issues.

      1. i can't seem to get the debugger (breakpoints) working right. i suspect it's because of how the ant scripts are set up to compile. I've tried using the debug flag but that doesn't do it. Anyone run across this one and have a simple answer?

      2. (and more importantly) Anyone know how i can get out of the dreaded edit/deploy/run cycle? I'd like to be able to simply edit and run my code in place in eclipse like i can for other stuff. sysdeo has something like this for Tomcat (http://www.sysdeo.com/eclipse/tomcatplugin) and their documentation makes it seem like a classloader thing. I checked out the documnetation on the classloader in jboss ( http://docs.jboss.org/jbossas/jboss4guide/r4/html/ch2.chapter.html#d0e1743 ) and it seems like the way to do it would be to get the classes in Eclipse it into the UnifiedLoaderRepository3, but i don't see anygood way to do that through the UIs. Which would mean getting down and dirty with the JBoss plumbing (or at least the JBoss Eclipse IDE plugin plumbing...)

      Anyone got any ideas?

      Dan

        • 1. Re: JBoss Eclipse incremental debugging

          Hi Dan, Thanks for using JBossIDE.. let's address your questions.

          1) I'm not sure why debugging your application wouldn't work as advertised. You say you're using ant scripts to compile, have you tried using Eclipse's auto build system?

          2) Once debug compilation starts working you should only have to edit/package/deploy once, then as long as jboss is running you should be able to change the code and have it dynamically update JBoss' classloaders. One thing to take not of is you'll need to setup the source lookup path of the JBoss instance in the Debug > Debug.. menu. If you need further help with this you should be able to find it in our user forums.

          • 2. Re: JBoss Eclipse incremental debugging
            dandrasin

            Marshall,

            Thanks for the notes. I finally ot #1 to work (it did take a number of different tries, combos of classpaths, and different combos of components. Below is what i did on WindowsXP which might help someone else...)

            On #2, i'm not sure i follow. Are you saying that editing the source in Eclipse and hitting save will cause a recompile that will upate the class file that is loaded in JBoss? Because from my understanding, the class file that is actually used via that class loader comes from one of the

            deployment directories (WEB-INF or whatever). So does Eclipse keep an association between the source file (from the src directory) and the class file and when the recompile hits it swaps i the class file to the right place? In other words, you need the ant script to get it to the right place to begin with but after that Eclipse keeps track and puts the recompiles back where it got

            them? If so - wow! cool!

            -----------------
            Here's how to get JBoss, Eclipse, Seam and the booking example to work together.

            1. Make sure that you have JDK1.5 installed.

            2. Install eclipse into ..\eclipse (i'll call it \eclipse from now on)

            3. Use eclipse's auto update to install the dev version JBoss Eclipse IDE
            Help->Software Updates->Find And Install...
            then use the URL http://download.jboss.org/jbosside/updates/development
            Note: this seems to be the best way to get R1.5M3 installed which seems to me to have the best compatibility as of this writing with Seam, Hibrnate, etc.

            4. Download the JBoss App Server that has been made compatible for Seam (not sure what that really means, but they have a special version to use with Seam so it's probably a good idea to use it).
            Here's where i got it: http://sourceforge.net/project/shownotes.php?release_id=356903

            5. Unzip/Install JBoss AS for Seam in a directory (call it \jbossas )

            6. Download Seam 1.0 Beta I got it from http://sourceforge.net/project/shownotes.php?release_id=357434

            7. Unzip/Install Seam into a directory (call it \seam)

            8. Configure Eclipse to use JDK5.0
            Windows->Preferences->Java->Compiler
            Set the Compiler Compliance level to 5.0.
            With this same dialog still open, go to the Installed JRE section and add an entry for the JDK5.0 and make sure you mark the check box to make it the default jre/jdk

            9. Start eclipse

            10. Add a new Project called "Seam". Choose the JBoos-IDE/J2EE Projects/J2EE 1.4 Project type from the Wizard

            11. Add the seam libraries to the buildpath (the JARs in \seam\lib)
            This is one by selecting the Seam project, right mouse click->Build Path...->Configure Build Path...
            Select the Libraries tab and press the Add External JARs button. Now select the JARs and press ok.

            12. Add the the Seam class files
            Select the Seam project->right mouse button->Import...
            On the next dialog, choose Archive file and from the next file dialog choose the archive file in the \seam directory (mine is called jboss-seam.jar) and press the finish button.

            13. Import the source for the Seam class files
            Select the Seam project->right mouse button->Import...
            On the next dialog, choose File system and press Next. In the next dialog choose the the \seam\src

            directory. In the Into folder section, enter Seam/src. activate the checkbox next to the src folder to select all of the files. Press the Finish button.
            Now select the folder named main. right mouse button->Build Path...->Use as Source Folder

            14. Import the source for the booking example
            Select the Seam project->right mouse button->Import...
            On the next dialog, choose File system and press Next. In the next dialog choose the the \seam\examples\src directory. In the Into folder section, enter Seam/src. activate the checkbox

            next to the src folder to select all of the files. Press the Finish button.
            Now select the folder named src. right mouse button->Build Path...->Use as Source Folder

            Now all the source files should be imported and show no errors.

            15. Reorder build patch
            Choose the the Seam project->right mouse button->Build Path...->Order and Export tab.
            Move the Seam source folders to the top using the up/down buttons.

            16. Set up the Debugger.
            Choose Debug... (from the debugger menu). Select the JBoss 4.0.x configuration and press the New button. On the Home tab, choose "default" as the Server configuration. Select the \jbossas folder as the Home directory. Give the configuration a name - how about "Seam" and press Apply and then Close.

            17. set the build properties of the seam installation
            go to the \seam\build.properties file and set jboss.home to the \jbossas folder

            18. set the build script to add debug information to the class files. Go to \sean\build.xml and change the javac.debug property to true.

            19. build the booking example
            go to the \seam\examples\booking directory an type "ant deploy"
            You'll need to make sure that ant is in your path and you may need to have the JAVA_HOME variable set as well. (Of course you can probably use the ant building in Eclipse to do this also...)
            (you can look at the example docs for more details).

            20. Restart Eclipse. Shouldn't need to do this - but seems needed after changing the compile option in 18.

            Now you can debug away to your hearts content. As a test, put a breakpoint in the booking example org.jboss.seam.example.booking.LoginAction.java (like aroun the "invalid login" message). Start JBoss by choosing the Seam debug option (the one you created). This will start the server. After it's started, you can point the browser at the server - http://localhost:8080/seam-booking/ should
            do it. This will give you the first page. Type in something random into the login window and press "Account Login" - assuming you've put the breakpoint in the invalid login line, this will hit the breakpoint.

            • 3. Re: JBoss Eclipse incremental debugging

              Hey Dan..

              Thanks for the in depth HowTo.. I went ahead and posted this as a Wiki page here:

              http://wiki.jboss.org/wiki/Wiki.jsp?page=UseJBossEclipseIDEToDoJBossSeamsBookingExample

              and linked it from the JBossIDE HowTo Wiki here:

              http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossIDEHowTo

              To answer your debugging question, basically when you start JBoss inside of Eclipse, Eclipse takes control of the JVM's main classloader. The excellent JDT tools are smart enough to know which classes in the classloader are associated with which Java sources (compilation units), and automatically triggers the debugger to hot-reload the classes bytecode when compilation is finished. The whole process is transparent to JBoss because of the inherent "parent-first" delegation model of ClassLoaders. You can read more about this all over the 'net, but that's the basic jist of it =). One thing to keep in mind is that this hot-replacement of code in the VM works really well for incremental changes within method bodies etc, but as soon as you change the structure of a class anyway it requires a re-deploy or a re-start to work correctly (i.e.. adding/removing params from a method, adding removing fields/methods, just about any refactoring operation).