Spring Data Graph - Neo4j Support 1.0.0.M2 Released

Releases | Thomas Risberg | January 31, 2011 | ...

Dear Spring Community,

I am pleased to announce that the second milestone release of the Spring Data Graph 1.0 project with Neo4j support is now available! The primary goal of the Spring Data project is to make it easier to build Spring-powered applications that use new data access technologies such as non-relational databases, map-reduce frameworks, and cloud based data services. The Graph Neo4j module provides integration with the Neo4j graph database.

Downloads | JavaDocs | Reference Documentation | Changelog

To learn more about the project, visit the Spring Neo4j Homepage.

The features in…

SpringSource Tool Suite 2.6.0.M1 Released

Releases | Christian Dupuis | January 28, 2011 | ...

Dear Spring Community,

We're pleased to announce that we just released the first milestone build for the next release of the SpringSource Tool Suite (STS).

Some highlights from this milestone build:

  • Content-Assist and Quickfixes for @Autowired and @Qualifer
  • Content-Assist in @RequestMapping for path variables
  • Updated Spring Project Wizard
  • RequestMappings from ITDs now in Spring Explorer and RequestMapping-View
  • Improved content assist performance for Groovy
  • Improved syntax highlighting for Groovy
More details on new features and bug fixes can be found in the 2.6.0.M1 New and Noteworthy document. Detailed installation instructions are also available.

As always downloads are available from the STS download page, check "Other Downloads".

Green Beans: Getting Started with Enterprise Messaging and Spring

Engineering | Josh Long | January 26, 2011 | ...

In this post, we will introduce the core concepts of messaging, as well as the rich support for various types of messaging that the Spring framework and its sister projects provide.

What is Messaging? To best explain this, I'll paraphrase the example offered by the groundbreaking Enterprise Integration Patterns book by Gregor Hohpe and Bobby Woolf (Addison Wesley, 2004). When you make a telephone call, you attempt to relay information to another party. This only works if the second party is available when you place the phone call. Because it is not always possible to answer phone calls, we use a voice-mail boxes to queue the messages. Callers leave messages in the voice-mail box and the callee is then free to retrieve the message (or, indeed, many messages) at a later point, asynchronously.

In that example, a voice-mail box sits in the middle of the two parties. It stores the message and then delivers it when the callee – the recipient – retrieves it. In the world of enterprise messaging, things work very much the same: a party sends a message to a messaging broker (also known as messaging-oriented middle-ware – MOM) and another party – when that party can – takes delivery of, or explicitly queries for, any messages from the message broker.

Here is where the analogy stops being useful. Message brokers, in contrast to voice-mail boxes, have a lot of options. Message brokers are ideally positioned to provide extra services, like routing, and to make guarantees about message delivery. Message brokers can be optimized for different use cases, for example, you can trade speed for durability. Message brokers may persist messages to an external store to ensure durability, though this is typically a configuration that can be toggled in the name of speed.

In the voice-mail box example, a message was sent by one party and then delivered to another – the communication was point-to-point. Message brokers support this, as well as another type of communication called publish-subscribe, where messages are delivered to multiple clients.

A common use of message brokers is to solve integration problems between two different systems. Data sent to a message broker is usually of a format common to both the sender and recipient of the message. The only thing that two systems need to agree on to use a message broker is the data contract. Messages typically have a message body, in which the contents of the message itself are stored, and message headers, which are key / value pairs that provide meta-data about the body of the message that can be used to aid consumers of the messages in processing the message. Message headers can be anything you like, but they typically relate to the message itself, or to the processor of the message.

Java Message Service

The Java Message Service (JMS) API specifies client interfaces for interacting with message brokers. Each message broker provides its own implementation of the API, very much like JDBC drivers do for the JDBC API. This implies that JMS clients should generally use the same version of the client as the server. There are many, many fine JMS broker implementations to choose from. One reason for this is that messaging ihas always been an important part of application development, and continues to be even more so today. JMS has been a part of the J2EE (now Java EE) specifications since 1.1. The JMS specification has been at version 1.1 for most of the last decade.

In JMS, clients use a javax.jms.ConnectionFactory to create a javax.jms.Connection. The Connection can then be used to create a javax.jms.Session. The Session represents the client interaction with the broker and allows for sending and receiving messages as well as other less obvious operations.

The most useful methods on the interface concern the creation of a message producers, and message consumers that send and receive messages to and from a javax.jms.Destination. A Destination maps the JMS concept of an "address" on a message broker. It also maps the concept of where a broker stores messages. In JMS, messages are sent to, stored in, and consumed from the same place, all represented by a javax.jms.Destination instance.

[caption id="attachment_7506" align="alignnone" width="573" caption="Above, blue elements represent producers and consumers. The orange elements represent destinations in the broker where messages are buffered. In JMS, these are either topics or queues."][/caption]

Destination is an interface and has two more specific sub-interfaces, javax.jms.Queue and javax.jms.Topic. A Queue represents a standard queue, which is a point-to-point construct as described before. A Topic provides publish-subscribe messaging and can deliver a single message to multiple recipients.

To send a message to a Destination, you must create a javax.jms.MessageProducer. The MessageProducer can then be used to send javax.jms.Messages.

JMS supports two different mechanisms to receive messages. The first way is to ask for a message, using the javax.jmx.MessageConsumer#receive() method, which returns an individual message from a Destination in a synchronous manner; the method blocks until a message is received, by default. Instead of using a MessageConsumer, clients may install a javax.jms.MessageListener by calling javax.jms.Session#setMessageListener(MessageListener). MessageListener is an interface and has only one method, public void onMessage(javax.jms.Message), which will be called whenever a javax.jms.Message is available for consumption on a Destination. A MessageListener provides asynchronous message processing: as messages arrive, they are processed.

There is quite a bit more to learn in the JMS API, but these classes and concepts will help you most in our discussion of Spring's support for JMS messaging. The first level of support is the org.springframework.jms.core.JmsTemplate, which provides simplifying methods to reduce the things we just discussed to one-liners. The JmsTemplate, requires a javax.jms.ConnectionFactory instance to do its work. JmsTemplate can do a lot of work for you. For example, to send a message, the JmsTemplate establishes a javax.jms.Session, sets up a javax.jms.MessageConsumer or javax.jms.MessageProducer, sets up all the machinery for transactions, and provide you with a reference to the current javax.jms.Session so you can create the message of your choice and send it. With all the error handling and construction logic, that's easily a savings of dozens of lines of code. Once your message has been sent, it destroys or closes most of those objects. This is standard practice in application servers (like a Java EE server) because the ConnectionFactory instances are created by the server, managed by the server, and are pooled. They cache the instances after use. Closing resources in those environments simply returns them to a pool. So, the JmsTemplate does the right thing in the standard case, assuming the ConnectionFactory caches or pools instances.

In a managed environment like an application server, you will typically need to acquire the javax.jms.ConnectionFactory from JNDI. You can use Spring to lookup that reference for you and configure a JmsTemplate. In our examples, we want to operate more loosely, so we will use the standalone ActiveMQ message broker. ActiveMQ is a popular, open-source message broker. To use it, download it, and then run the startup script appropriate to your operating system in the bin folder. In your application, you'll need the client libraries to connect for the corresponding version of ActiveMQ. At the time of this writing, the latest version of ActiveMQ was 5.4.2. If you are using Maven, add the following dependencies to your Maven pom file:


Be sure to either create a Maven property for ${activemq.version} or replace the string manually with the appropriate version. There is an activemq-all dependency out there as well, but it brings down a lot of perhaps unnecessary jars. For our application, the two dependencies above suffice.

Using Spring with JMS

Let's examine the configuration for a basic JMS application. First, let's examine the basic Spring XML configuration:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"

SpringOne 2GX 2010 Tech Talk: What's New in Spring Integration 2.0?

News | Adam Fitzgerald | January 21, 2011 | ...

SpringOne 2GX 2010 Tech Talk: What's new in Spring Integration 2.0
Yet another session from SpringOne 2GX 2010 has been posted by InfoQ. This time it is Mark Fisher and Oleg Zhurakousky who are presenting on What's New in Spring Integration 2.0.

Mark and Oleg use code-centric demos to describe how Spring 3.0 features have been integrated in Spring Integration, what enterprise integration patterns have been implemented and where channel adapters and gateways have been updated. They demonstrate the new STS tooling support for Spring Integration and discuss some of the future features and direction for the project.

This presentation is a great way to get introduced to Spring Integration 2.0. The GA release of 2.0 followed less than one month after this talk so all the topics covered are up to date with the current release. Again many thanks to InfoQ for covering SpringOne 2GX 2010.

This week in Spring: January 18th, 2011

Engineering | Josh Long | January 18, 2011 | ...

Another fantastic week for the Spring community at large. In addition to the exciting announcement of the stable release of Tomcat 7, there were numerous great posts from the community.

  1. Continuing the back-to-basics "Green Beans" series, we've just published a post on using Spring and Maven together.
  2. The Tomcat Expert community has announced the first stable build of Tomcat 7. We know Tomcat is the favorite place for Spring developers to run their applications, so be sure to check out the latest features.
  3. Nicholas Sankel has written up a blog on using Spring Roo with the Vaadin UI framework.
  4. The Tomcat Expert community has provided a list of the top 10 articles from 2010.
  5. Tomasz Nurkiewicz has written a fantastic blog exploring how you can completely strip out XML using the Spring framework.
  6. Sivaprasadreddy Katamreddy has written up an introduction to Spring AOP that progresses from problematic code all the way to the improved code using Spring AOP.
  7. A gentleman named (from what I can tell) Warlock has blogged on Spring MVC's annotation-based session-handling support.
  8. Sal Peace has written up a fantastic introduction to using Spring MVC 3.0's portlet support with WebSphere 7.
  9. Viral Patel has written up a tutorial on saving and retrieving BLOB object data in Spring 3 MVC and Hibernate
  10. Jorram Barrez (from the Activiti project) has posted on using Spring to connect an Activiti BPMN 2.0 business process to EJB business services.

Green Beans: Getting Started with Maven and Spring

Engineering | Josh Long | January 17, 2011 | ...

Apache Maven is a popular open source tool that offers a convention-over-configuration approach to project build management. Indeed the Eclipse Community Surveys show Maven increased its adoption from 8% in 2009 to 28% in 2010, underscoring its usefulness in a wide range of project settings. Even though you can use Spring without using Maven, there are many reasons to recommend its use to Spring developers. In this post I'll show you how to get started using Maven, and how to use it successfully with Spring libraries, repositories and tooling like SpringSource Tool Suite and Spring Roo.

Maven handles project builds. Maven can provide a lot of power and sophistication with relative ease if your project follows Maven's conventions. It is declarative; you describe what you want done, not how you want it done. This approach will seem different if you've come from venerable build tools like Make, or Ant.

You declare your project's dependencies in the Maven project configuration. These dependencies are then resolved on your behalf and downloaded for you. This is similar to the package system found in many different operating systems. Suppose you're using OS X's fink or ports command line tools. To update an operating system's a functionality, a user selects a package (say, the latest security patches, or a new version of the glib library) to install in an administration client and then instruct the client to downloaded and install it from well-known servers, referred to as package repositories. When the package is downloaded, the package manager consults the package's manifest which enumerates all the libraries (found in other packages) that the package depends on - its transitive dependencies. Those too are downloaded.

There are several ways to install Maven If you haven't already got it installed. Download it from the Apache web site. Choose a more recent version. Currently, many people are using Maven 2.21, or the recently released Maven 3. Download the version you'd like to use and then unzip it to a directory of your choice. Alternatively, several operating systems provide Maven 2 builds (and soon, Maven 3 builds) in the package system. For example, on Ubuntu, you can run sudo apt-get install maven2 . If you're using the SpringSource Tool Suite (available here for download for free), then you don't need to worry, Maven's already downloaded and included in your STS installation folder. Regardless of how you get the Maven binaries on your system, ensure that the binary is on your operating system's search path. Usually, this is just a matter of adding the Maven installation's bin folder to your operating system's PATH variable. It's also a good practice to create a system variable for the Maven installation itself, called MAVEN_HOME. On a Unix (including OS X) or Linux machine, this setup looks about the same. On my machine (an Ubuntu Linux machine), it looks like this:

export MAVEN_HOME=/home/jlong/bin/springsource/maven-2.2.1.RELEASE 

To test it, open up a new shell and issue the following command:

mvn --version

You should see some output confirming the command presence on your system, like this:

[email protected]:~/Desktop/code$ mvn --version 
Apache Maven 2.2.1 (r801777; 2009-08-06 12:16:01-0700) 
Java version: 1.6.0_22 
Java home: /usr/lib/jvm/java-6-sun- 
Default locale: en_US, platform encoding: UTF-8 
OS name: "linux" version: "2.6.35-22-generic" arch: "amd64" Family: "unix" 
[email protected]:~/Desktop/code$ 

Getting Started With Maven

Maven projects assume a standard directory structure, which looks - at a minimum - like this:

./pom.xml ./src ./src/main ./src/main/java ./src/main/resources ./src/test ./src/test/java ./src/test/resources

At the root of the directory structure is a XML file (always called pom.xml) that Maven expects. The pom.xml (POM is short for Project Object Model) describes the things specific to your project that can't be inferred automatically like dependencies, the name of the project, etc.

Directory Description Directory's Contents (relative to the project root)
src/main/java Contains the Java source code for your project
src/main/resources Contains any classpath-relative resources for your project (like, a Spring application context .xml file)
src/test/java Contains the java source code for your test…

SpringSource Tool Suite 2.5.2 Released

Releases | Christian Dupuis | January 11, 2011 | ...

Dear Spring Community

I'm pleased to announce that we just released SpringSource Tool Suite (STS) 2.5.2.RELEASE.

Some highlights from the new release:

  • Support for Spring Roo 1.1.1.RELEASE
  • Easy creation of new tc Server instances
  • Improved graphical Spring Web Flow editor
  • Agent-based reloading (experimental)
  • A large number of improvements to the Spring and Groovy/Grails tooling
  • Integration of Spring User Agent Analysis (UAA)

More details on new features and bug fixes can be found in the New and Noteworthy document. Detailed installation instructions are also available.

As always downloads are available from the STS Download page. Feel free to stop by the community support forum if you have any question or issue.

Spring Web Services 2.0 Released

Engineering | Arjen Poutsma | January 11, 2011 | ...

After being in the works for almost a year, I'm happy to announce that Spring Web Services 2.0 has been released! In this post, I'd like to go over some of the major new features.

Java 5+ and Spring 3.0 Required

As you are probably aware, we moved the Object XML Mapping (OXM) module from the Spring-WS project into Spring 3.0. As such, it was a bit problematic to use Spring-WS 1.5 (with its own OXM module) with Spring 3.0, due to conflicting classes in the org.springframework.oxm package.

As of version 2.0, we no longer ship the OXM module as part of Spring-WS, but depend on Spring's OXM instead. As a result, Spring Web Services 2.0 requires Spring 3.0 to work. Normally, we tend to be a bit more lenient with regard to version requirements, not necessarily requiring the latest Spring version, but this was the…

What's New In Spring Roo 1.1.1

Engineering | Ben Alex | January 11, 2011 | ...

It's our pleasure to announce the general availability of Spring Roo 1.1.1. This new release incorporates over 250 fixes and enhancements, including many performance and functionality improvements.

As always, SpringSource Tool Suite (STS) 2.5.2 will be released very shortly and incorporate this new version of Spring Roo. You can also download the standalone version of Spring Roo 1.1.1 and get started immediately.

Let's briefly tour some of the more notable enhancements we're added to Roo 1.1.1. If you're upgrading your Roo-based projects, we encourage you to review the version-specific upgrade notes we include in the reference guide. The reference guide is also included in the…

Green Beans: Getting Started with Spring in your Service Tier

Engineering | Josh Long | January 07, 2011 | ...

All applications stem from a domain model. The term "domain model" describes the nouns, or data, in a system that is important to the problem you're trying to solve. The service tier - where business logic lives - manipulates the application data and must ultimately persist it (typically, in a database). The explanation is simple, but in practice building a good service tier can be a daunting task for any developer. This post will introduce developers to the options available in the Spring framework for building a better service tier. It is assumed that the reader has some experience with the…

Get the Spring newsletter

Thank you!

Get ahead

VMware offers training and certification to turbo-charge your progress.

Learn more

Get support

Spring Runtime offers support and binaries for OpenJDK™, Spring, and Apache Tomcat® in one simple subscription.

Learn more

Upcoming events

Check out all the upcoming events in the Spring community.

View all