Debugging with BlazeDS source code in a project, and a question
March 29th, 2008
Setting up an Eclipse project so that one can debug BlazeDS code is a bit more complex than one might think. I’ve invested more time than I care to admit into understanding this – I’m a Java newbie – and still don’t understand it completely. Here are some notes on what I’ve learned in case you want to do the same thing, and a question.
First of all, the best guide that I’ve found for setting up Java debugging in Eclipse in general is Yakov Fain’s Debugging both Flex and Tomcat Java programs in Eclipse article. The procedure is fairly simple and it worked the first time I tried it. Of course, I’m using Tomcat on Windows so your mileage may vary. We have links to several other articles that take somewhat different approaches in the Debugging section of our Adobe Flex :: With Java page.
Once you’ve got things set up so that you can set breakpoints in your own Java code and step through it you can follow these steps to set up debugging for BlazeDS.
- You’ll find a link for a zip file download of the latest stable release on this page. Download and unzip it, and place it in a location that makes sense within your folder hierarchy.
- In Eclipse go into Window | Preferences | General | Workspace | Linked resources and set up a linked resource (use the New and Folder buttons) that points to the BlazeDS folder. Name it BLAZEDS_HOME.
- Create a Java project for the [Tomcat]/webapps/blazeds/ folder. I assume that you’ve already got that installed. If not, check out this blog post.
- Select the blazeds project in Project Explorer and go into Project | Properties | Java Build Path.
- Select the Libraries tab.
- Note that there are 5 .jar files with names that start with flex-messaging. You’re going to specify a “Source attachment” for one or more of these. The basic idea here is that while the .jar files are what Tomcat normally uses, we’re going to tell Eclipse where the source code that corresponds to these files is located. This will allow Eclipse to open source files for the classes in the .jar files where you can set breakpoints, then step through code.
- You can specify the “Source attachment” for a .jar file by expanding it with its + icon, selecting “Source attachment”, clicking the Edit button, clicking the External Folder button, then browsing to and selecting the appropriate source code folder.
- Here are the folders that correspond to the 5 .jar files:
- flex-messaging-common.jar: [BLAZEDS_HOME]/modules/common/src/java/
- flex-messaging-core.jar: [BLAZEDS_HOME]/modules/core/src/java/
- flex-messaging-opt.jar: [BLAZEDS_HOME]/modules/opt/src/tomcat/ (if you’re using Tomcat – there are other options as well)
- flex-messaging-proxy.jar: [BLAZEDS_HOME]/modules/proxy/src/java/
- flex-messaging-remoting.jar: [BLAZEDS_HOME]/modules/remoting/src/java/
- Which ones should you link to? Well, obviously, it’s not that hard to link to all of them. On the other hand, if you know that you’re probably only going to focus on one of these modules you could search for the class file in the modules folder, identify the desired module, and link to that module only.
- Once you’ve done this you should be able to initiate debugging as described in Yakov’s article.
Now here’s my question:
Both /modules/common/src/ and /modules/core/src/ contain /java15/ as well as /java/ folders. Adobe tech support tells me that “java/ is for Java 1.4 compliant code and java15/ is Java 5 compliant code” but if you look into each folder it appears that /java/ contains most of the classes and /java15/ contains supplemental classes. Is this correct and, if so, shouldn’t we be linking to both /java/ and /java15/ folders in these two modules? (I’m assuming that we’re using a Java 5 compliant JRE.) And if that’s true, how can we do this in Eclipse?
For now I’m ignoring this issue as the /java/ folders seem to have most of the code that I’m interested in, but if you can clarify this please leave a comment.
Thanks,
Douglas