Book | JIRA | Confluence | Forum

20040826 Thursday August 26, 2004

Setup MyUsers in Eclipse Category: Spring Live

This is a short tutorial of how to setup the MyUsers sample app from Spring Live in Eclipse. This tutorial is based on the code that's created in Chapter 2, which is available as a free download (PDF). The code that's created in this chapter is also available for download. I'm using Suse 9.1, Eclipse 3.0 and JDK 1.4.2 to write this tutorial. I'm assuming you already have Eclipse 3.0, JDK 1.4.2 and Tomcat 5.0.x installed (I'm using 5.0.27)

1. To make Eclipse easier to work with, the first thing you might like is some good plugins. I've put together a package of the ones I use for web development [Download · Release Notes]. The main useful plugin in this package is the Tomcat Plugin. It's not necessary, just nice to have for debugging in Eclipse. Also, I highly recommend installing the Spring IDE Plugin - it's very nice for working with Spring.

2. At this point, I'm assuming you have the "myusers" directory in your desired source directory (I prefer c:\Source on Windows and ~/dev/ on *nix). Open Eclipse (either with an existing or a new workspace) and to go File → New..., select Java Project and click Next >. Enter "myusers" for the project name and the pathname to its source directory. Click the Finish button. Eclipse will load and build the project. At this point you'll probably have a couple issues complaining that it can't build your project due to an ''Unbound classpath variable''. You'll correct this in the next step.

3. To fix the fact that TOMCAT_HOME is unrecognized, we need to set this as a classpath variable. Right click on the "myusers" project and select its "Java Build Path". Click on the Library tab, scroll down to the TOMCAT_HOME setting towards the bottom and click the Edit button. Click the Variable button on the "Edit Variable Entry" popup and add a new TOMCAT_HOME variable that points to your installation.

TIP: In order to clean up the project view in Eclipse, you can hide the files you don't need. First of all, make sure you're in the Java Perspective (Window → Open Perspective). Then click the little (down) arrow in the top right corner of the Package Explorer pane. Select Filters, check the "Name Filter Patterns" and type "*.jar" (no quotes) in the text field. Then in the list of elements, scroll down and check Referenced Libraries. Click OK to continue.

Another useful Eclipse trick is to use abbreviated package names. You probably won't need it on this project, but its nice on projects where you're inflicted with Go to Window → Preferences → Java → Appearance. Check the "Compress all package names" checkbox and type "1." (no quotes) in the text field.

4. That's it! You should be able to run any of the JUnit tests in Eclipse by right-clicking on them and going to Run → JUnit Test.

To manage deployment of the MyUsers application and running the Ant targets, you have to complete a few more steps:

1. Enable the Ant View. Go to Window → Show View → Ant. Click on the first left-most icon at the top of this pane - labeled "Add Buildfiles". Select the build.xml file from "myusers" and click OK. At this point, there will be an error claiming that the "...RemoveTask" cannot be found.

2. Add "tomcat.home" as an Ant property. The reason for this error is because ${env.CATALINA_HOME} is used in the build file, and (for some reason) Ant doesn't recognize it. Go to Window → Preferences → Ant → Runtime. Click the Properties tab and add a "tomcat.home" global property that points to the appropriate location. While we're in here, let's add junit.jar to the classpath since it'll be needed by Ant to run the tests. Click the Classpath tab, click Global Entries and the Add JARs button. Navigate to web/WEB-INF/lib and select junit.jar. Click OK twice to return to the workbench. Right-click the build file in the Ant View and select Refresh Buildfiles.

3. Test 'er out. You should now be able to double-click on the "test" target (in the Ant View) and get all the tests to pass.

4. Setup Tomcat Plugin. To do this, go to Window → Preferences → Tomcat. Select "Version 5.x" and set Tomcat home to where you installed Tomcat. Click OK. You should now be able to stop/start/restart Tomcat using the little icons on the menu bar or via the Tomcat menu.

5. That's it! Run the "deploy" target and start Tomcat, then navigate to http://localhost:8080/myusers to see MyUsers running in your browser.

Comments or question on this tutorial? Post them here. For your convenience, any questions relating to Spring Live can be easily asked on the Spring Live Support Forum. (2004-08-26 16:49:12.0) Permalink

20040824 Tuesday August 24, 2004

JIRA will be up soon Category: Spring Live

As mentioned by James and Bruce, SourceBeat will soon be using JIRA to track book-related issues. I downloaded and installed it last night and it was damn easy to setup - nice work guys! Now we're just waiting for SourceBeat's ISP to setup a sub-domain and then I'll install it over there. Once that's up and running (hopefully tomorrow), I'd be great if all the folks that have reported issues can enter them. Sure, I could do it for you - but then you'd have no record of when it was fixed and such. Besides, if you do it - that'll free up more of my time to get Chapters 8 and 9 done. ;-) I'll try to make sure all the bugs that were sent to me are entered and fixed before 1.0.

Progress on Chapter 8 is moving along. I've got almost 10 pages done and I'm through the database layer section. Tonight I'm going to be working on the service layer with jMock and EasyMock and then tomorrow hit up testing Controllers and Views. I'm going to take some advise from readers and only cover Spring Mocks in the Controllers section. You guys don't care about StrutsTestCase or MockObjects (for servlets) do you? Besides, StrutsTestCase is covered in Chapter 2 and used extensively in AppFuse (if you want more examples). In their place, I might add together a quick example using Cactus. (2004-08-24 23:31:34.0) Permalink Comments [3]

20040820 Friday August 20, 2004

Spring documentation in Japanese Category: Spring Live

Looking for Spring documentation in Japenese? Then look no further than It seems to be just tutorials so far, but I'm sure it'll grow rapidly. (2004-08-20 12:33:25.0) Permalink Comments [0]

Chapter 7 off to Tech Edit Category: Spring Live

I just e-mailed my final draft of Chapter 7 off to Dion. This chapter walks you through implementing Hibernate, iBATIS, Spring JDBC, JDO and OJB in the MyUsers application. My favorites? Hibernate, iBATIS and Spring JDBC - in that order. I'm tempted to rant about JDO, but I'm bound to get in trouble if I keep ragging on the standards projects that are supposed to make our lives easier. Wink

Phew - almost 5:00 a.m. - I'd better get to bed before Abbie wakes up! (2004-08-20 06:47:10.0) Permalink Comments [3]

20040819 Thursday August 19, 2004

[ANN] Spring 1.1 RC2 Released Category: Spring Live

Download · Release Notes: Summary or Detailed. This is primarily a release to fix issues and add minor enhancements to 1.1 RC1. It also includes the new HTTP Invoker and a VariableResolver for JSF.

The one thing that I really like in this release is the addition of form simplification macros for FreeMarker and Velocity. These won't be covered in Chapter 6 because it's already in copy edit, but as soon as their JSP counterparts are released - I'll make sure and update the chapter. The JSP form input tags are scheduled to be in 1.1 final. (2004-08-19 11:28:40.0) Permalink

20040818 Wednesday August 18, 2004

Chapter 8 Preliminary Outline Category: Spring Live

I started working on Chapter 8 today. Here's the summary of this chapter so far:

This chapter covers test-driven development and creating high-quality, well-tested applications that use Spring. It shows you how to test your components using tools like EasyMock, JMock and DBUnit. For the Controllers, it will demonstrate how to use Cactus for testing in-container, as well as Spring Mocks for out-of-container testing. Lastly, you will see how to use jWebUnit and Canoo's WebTest for testing the web interface.

Below is the preliminary outline - let me know if there's something I'm not including that you'd like to see.

  • Chapter Overview
  • JUnit
  • Testing the Database Layer
    • DBUnit
  • Testing the Service Layer
    • Using Mocks for DAO Objects
      • EasyMock and Example
      • jMock and Example
  • Testing the Web Layer
    • Testing Controllers
      • StrutsTestCase
      • Spring Mocks
      • Mock Objects (?)
    • Testing Views
      • jWebUnit
      • Canoo's WebTest
      • HttpUnit
  • Automated Testing
    • Anthill
    • CruiseControl
    • DamageControl
  • Chapter Summary

Phew - that's a lot more than I originally planned for, but it's also the kind of topics I'd like to see covered in this type of chapter. (2004-08-18 00:46:21.0) Permalink Comments [6]

20040817 Tuesday August 17, 2004

Chapter 7 Delayed Category: Writing

My push to finish up Chapter 7 is about over. I thought by taking the day off today, I could write 30-odd pages and be done with it. Not so. I've worked 25 hours on Spring Live over the last 3 days, and I'm barely halfway through the chapter. The good news is I have about 18 pages of good info and tutorials using Hibernate and iBATIS. Unfortunately, I still have Spring JDBC, JDO and OJB to go. My pace seems to be about one-framework-per-day, so that's how I'm going to attack it. Using this strategy, this chapter should be in tech edit on Friday morning. I'm planning on spending 4 hours per night on Chapter 7 and hopefully a couple hours in the morning on Chapter 8 (testing). Combine all that with a 40-hour week in the next 4 days and it's going to be a tough one.

I remain confident that I can complete 1.0 before Raible 2.0 (due September 3rd) arrives, but I can feel it slipping. It's 3:30 a.m. in Denver. If I want to get a full day in tomorrow, I'd better get at least a few hours of sleep. ;-) (2004-08-17 05:35:53.0) Permalink Comments [4]

20040816 Monday August 16, 2004

Free Wireless Internet Category: Writing

I traveled to my favorite library today to disconnect and get some writing done. I really like this library b/c it's difficult to get online, and I'm more productive when I don't have the web, e-mail, etc. on. They do have computers, but they only allow you on for 15 minutes at a time - another good thing. Today, when I showed up, they had a big sign at the front saying "Free Wireless Internet". Damn. I tried resisting the urge, but obviously I'm not doing too well. Turn Airport Off seems like the best solution. (2004-08-16 12:38:37.0) Permalink

20040815 Sunday August 15, 2004

SourceBeat BBQ Category: Author

Yesterday afternoon, a bunch of the SourceBeat authors, editors and families got together at Matt Filios's house in Castle Rock. A great time was had by all. I've never seen so many kidsin one place having so much fun. Abbie definitely had a good time. Click on the image below to view pictures from the event. To quote James, "From top to bottom, we work with a great group of people". Thanks for hosting Matt - I can't wait for the next one!

(2004-08-15 18:43:23.0) Permalink Comments [0]

ERP 2/Chapter 6 Dilemma Category: Spring Live

Chapter 6 (View Options) is about to be PDF-ed. In the normal SourceBeat cycle, it would be published (along with the rest of the chapters) as ERP-2. However, I'm a bit hesitant about doing this b/c I haven't had the time to effectively manage and fix all the issues with the first 5 chapters. So here's your choices:

  • Release ERP-2 with all 6 chapters. Chapters 1-5 will not be updated to fix issues found by readers.
  • Release ERP-2 as Chapter 6 only. The problem with this is new subscribers might be disappointed if they download the ERP and find it's only one chapter. This might lead to a lot of support from SourceBeat staff. No sweat off my back though. ;-)
  • Don't release ERP-2, or any other ERPs until version 1.0 is done and I have time to fix issues in all chapters.

Of course, I'd prefer #3, but I can understand if you'd rather go with #1. (2004-08-15 12:36:25.0) Permalink Comments [9]

Weblog Archives
Click this photograph for National Geographic's Photo of the Day
Photo of the Day
Spring Logo
+ SourceBeat Weblogs

+ Spring Framework

Spring Live Book
• Raible Designs
• Who is Matt Raible?
Recent Comments
  • [3] JIRA will be up soon
  • [3] Chapter 7 off to Tech Edit
  • [6] Chapter 8 Preliminary Outline
  • [4] Chapter 7 Delayed
  • [9] ERP 2/Chapter 6 Dilemma