Category Archives: Spring Framework

Spring @MVC configuration without XML

XML is no longer hip. Actually, there is nothing as unhip as last year’s hip. That is until it becomes hip again 30 years later in failed irony. Honestly, if you’ve been programming Java EE since the 90s, you know full well how error prone XML config files can be. A glance at an EJB […]

Also posted in Spring MVC | Tagged , | 5 Responses

Eclipse JavaScript Libraries Validation

I use several JavaScript libraries in my web apps. Just one of the many reasons I like Spring MVC over other web frameworks – like JSF – is that you can easily use current web technologies. HTML5? CSS3? jQuery? No problem! Actually there is one problem, but it’s an Eclipse (or Spring STS) problem. When […]

Also posted in Eclipse, jQuery, Spring MVC | Tagged , | Leave a comment

Spring 3, Hibernate JPA, Tomcat transactions

I tried to deploy a webapp that uses Spring 3, JPA with the Hibernate implementation and Tomcat. There are domain classes with a DAO layer which is called from the Service layer. The classes are annotated correctly. All of the unit tests work. Actually the whole webapp works deployed on other web containers : but […]

Also posted in Hibernate, JPA | Tagged , , | Leave a comment

Spring @MVC 3 cascading selects using jQuery

I’d be rich if I had a dollar for each time I heard someone ask “How do I dynamically populate a drop down menu based on the current selection in another drop down?” Actually that is probably the poster child usage of AJAX. You can certainly use raw AJAX to accomplish this (just ask the […]

Also posted in jQuery, Spring MVC | Tagged , , | 28 Responses

Spring STS 2.6 JPA template project

Here are a few tips on using the JPA project template included in the Eclipse based SpringSource Tool Suite (STS) (currently at version 2.6) which is a free download from SpringSource. Createe a JPA “utility” project (New->Spring Template Project then choose Simple Spring JPA Utility Project). This generates a lot more than just an empty […]

Also posted in Hibernate, JPA | Leave a comment

Spring MVC 3 Showcase

SpringSource member Keith Donald has announced that he is providing simple demos of new additions to Spring MVC version 3. This is a Maven project containing all the demos. The samples Subversion repository is: so you can grab the source like this:

There is also a screencast you can watch.

Also posted in Spring MVC | Tagged , | Leave a comment

jetty maven version 7 beta woes

So I gave the beta of the jetty maven plugin a try. What I had was this:

I changed it to this which is the most current available version in the repos:

N.B. for maximum cognitive dissonance the jetty guys thought it would be a good idea to swap some words in the […]

Also posted in Maven | Tagged , , | 1 Response

Spring, BasicDataSource and OpenJPA

So you want to use Spring with commons BasicDataSource and OpenJPA? There is an interesting gotcha. Let’s start with just the DriverManager DataSource for comparison. In your spring context you define the datasource like this:

Then your EntityManager Factory:

Here META-INF/persistence.xml is almost empty because all the properties are specified here in Spring. […]

Also posted in JPA | Tagged , , , | 1 Response

Spring Test Framework CoC suggestion

Let’s say you’re using JUnit 4 and the Spring Testing classes (the 2.5+ versions) for your unit tests. You can specify parameters as shown in the TransactionConfiguration annotation as shown in this example. But you can also get away with leaving them out in a nod to the uberhip Convention Over Configuration gods as shown […]

Also posted in Testing | Tagged , , | 1 Response

Maven profiles : filtering for hsqldb and MySQL

Many developers like to use a lightweight embedded database such as Hsqldb or Derby in their development environment. But usually the application is deployed using another database such as MySQL – or Oracle, DB2 etc. Maven profiles are a way to segregate resources for each environment and to switch easily between them. The Spring Framework […]

Also posted in Maven | Tagged | Leave a comment