Matt RaibleMatt Raible is a Java Champion and Developer Advocate at Okta. developer.okta.com

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

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>

Posted in Java at Nov 07 2007, 08:27:20 AM MST 3 Comments
Comments:

Hi Matt,

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 12:36 PM MST #

Matt, You should've had the Cadillac for the first seventeen years of your life. And move to the cabin nowadays. Don't get your priorities mixed up. Wrt your fondness to frameworks. Why are we still asking the same question which framework to use. It has been almost half a decade since you had your framework-showdown talks... Are you asking the wrong question about trying to find out which framework to use? Does framework even matter at all?

Posted by Marek on November 11, 2007 at 01:52 AM MST #

Marek - I'd love to move to the cabin. However, since Julie and I aren't together anymore and we need to share time with the kids - that's not really possible. As for web frameworks - I've only been doing that for 3 years. What are the right questions? Why doesn't a framework matter anymore? You still need one - you're not about to write your application with just servlets and JSPs. I do believe that web frameworks may not be the way of the future, but I still think there's going to be a need for them when folks are developing websites (moreso than true web applications). For example, LinkedIn is more of a website than a web application, so it makes perfect sense for them to continue to use a web framework.

Posted by Matt Raible on November 11, 2007 at 11:42 AM MST #

Post a Comment:
  • HTML Syntax: Allowed