Upgrading AppFuse to Spring 2.5
Last night, I spent a few minutes upgrading AppFuse to Spring 2.5 RC1. According to InfoQ, Spring 2.5 is a drop-in upgrade for Spring 2.0. However, if you're using Maven, it's not quite that easy. The good news is it is easy, you just need to change your pom.xml a bit. The steps I used to upgrade AppFuse are listed below:
- Add a repository for Spring's milestone releases:
<repository> <id>spring-milestone</id> <url>http://s3.amazonaws.com/maven.springframework.org/milestone</url> </repository>
- Change artifactId of "spring-mock" to be "spring-test".
- Change version to be 2.5-rc1.
At this point, if you're using "spring" as your artifactId (instead of the smaller fine-grained dependencies), you'll likely get the following error in a Spring MVC application:
java.lang.NoClassDefFoundError: org/springframework/web/servlet/handler/AbstractUrlHandlerMapping
This happens because Spring MVC is no longer included in the uber spring.jar. You'll need to add a dependency on "spring-webmvc" to solve this problem. Unfortunately, this JAR is dependent on the fine-grained modules, so you may have to modify your pom.xml to depend on the fine-grained modules - or exclude them all from spring-webmvc.
The good news is Spring has excluded all the invalid commons-logging dependencies for you so you don't have to anymore.
After getting all the dependencies straightened out - I ran the integration tests:
org.springframework.beans.NotReadablePropertyException: Invalid property 'fileUpload' of bean class [org.appfuse.webapp.controller.FileUpload]: Bean property 'fileUpload' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
Looking at uploadForm.jsp, I'm guessing the problem happens because of the following code:
<spring:bind path="fileUpload.file"> <input type="file" name="file" id="file" class="file medium" value="<c:out value="${status.value}"/>"/> </spring:bind>
Confirmed - changing the "path" attribute to "file" fixes the problem. I also found out that setting the "value" on an <input type="file"> doesn't work, so wrapping the field with <spring:bind> doesn't make a whole lot of sense anyway.
To conclude, it doesn't look like the first release candidate of Spring 2.5 is exactly a drop-in upgrade for Spring 2.0, but it's pretty darn close. I'm sure by the time it's released, it will be. I'd encourage you to try 2.5 in your Spring-dependent projects to see if you find any issues.
Update: I was successfully able to migrate AppFuse from using the uber JAR to fine-grained JARs. However, I ran into a couple issues in the process. The first is that even though I'm including spring-aop in the appfuse-service module, it's not pulled in for the web frameworks (which depend on appfuse-service). Explicitly declaring spring-aop as a dependency for the appfuse-web module fixes this. Secondly, I had to modify my Acegi Security exclusions so it wouldn't include dependencies that no longer exist in 2.5.
<dependency> <groupId>org.acegisecurity</groupId> <artifactId>acegi-security-tiger</artifactId> <version>${acegi.version}</version> <exclusions> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-dao</artifactId> </exclusion> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> </exclusion> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-remoting</artifactId> </exclusion> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-support</artifactId> </exclusion> </exclusions> </dependency>
Thanks for this blog entry!!
I followed your advice to migrate my Tudu Lists application : http://tudu.svn.sourceforge.net/viewvc/tudu/trunk/tudu2/pom.xml?r1=556&r2=555&pathrev=556
I indeed had some trouble with the JARs files, as some were renamed : http://tudu.svn.sourceforge.net/viewvc/tudu/trunk/tudu2/tudu-core/pom.xml?r1=556&r2=555&pathrev=556
And, surprisingly, I add a small issue with a test case : http://tudu.svn.sourceforge.net/viewvc/tudu/trunk/tudu2/tudu-core/src/test/java/tudu/integration/IntegrationTest.java?r1=556&r2=555&pathrev=556
But the upgrade to Spring 2.5-rc1 is indeed mostly painless.
Posted by Julien Dubois on November 07, 2007 at 06:36 PM MST #
Posted by Marek on November 11, 2007 at 07:52 AM MST #
Posted by Matt Raible on November 11, 2007 at 05:42 PM MST #