Using Spring Data JPA To Reduce Data Access Coding

Introduction

On March 24, 2011, springsource released milestone 2 of the Spring Data JPA library. Per the Spring Data project website, Spring Data JPA:

Simplifies the development of creating a JPA-based data access layer and provides 'cross-store' persistence functionality for JPA managed entites [sic].

Since I recently started using JPA 2 in my Spring applications, I decided to learn more about Spring Data JPA. To assist my learning, I took an example project that uses Struts 2, Spring 3, JPA 2 (with Hibernate 3.5 as the JPA provider) and modified it to use Spring Data JPA. This blog article is about what I had to modify so the project could use Spring Data JPA and what I could then get rid of.

[More]

Spring 3.1 Cache Implementation With Cacheable and CacheEvict Annotations

Introduction

One of the new features in Spring 3.1 is cache abstraction that allows developers to easily cache method results. This blog article provides a simple Maven Java project that demonstrates how to use the new cache annotations.

[More]

Contexts and Dependency Injection With Maven and Tomcat 7

Introduction

As I worked my way through the Contexts and Dependency Injection (CDI) part of the Java EE 6 tutorial I wanted to learn how to use CDI with Tomcat 7 and Maven. The examples that come with the Java EE 6 tutorial provided by Oracle are NetBeans projects and use the GlassFish 3 server (which has built in support for CDI). Since my development environment is Maven and Tomcat, I wanted to translate the CDI examples in the Java EE 6 tutorial to my environment. Just like with my work on converting the JSF 2 example to Maven and Tomcat, converting the CDI example meant a ride on the JSF 2 - Tomcat 7 pain train.

[More]

JSF 2, Maven, and Tomcat 7

Introduction

As I worked my way through the Java EE 6 tutorial I needed to learn how to use JSF 2 with Tomcat 7 and Maven. The examples that come with the Java EE 6 tutorial provided by Oracle are NetBeans projects and use the GlassFish 3 server (which has built in support for JSF 2). Since my development environment is Maven and Tomcat, I wanted to translate the JSF 2 examples in the Java EE 6 tutorial to my environment. This work went pretty smoothly except for one big GOTHCA caused by a little advertised bug in the latest version of Oracle's reference implementation of JSF 2.

[More]

Struts 2 Security Vulnerability - Dynamic Method Invocation

Introduction

The Struts 2 web application framework has a long-standing security vulnerability that may not be well known to new Struts 2 developers. By default the framework enables a technique called dynamic method invocation. This technique allows a developer to specify in a Struts 2 action url what method should be called in the Action class. The security problem is that any user of the Struts 2 web application can also use dynamic method invocation to call a public method that is in the Action class. The purpose of this article is to explain the vulnerability and how to fix it. Note this problem occurs through the Struts 2.2.1.1 release, which is the latest release as of February 2011.

[More]

Maven, Servlet 3.0, and Tomcat 7

Introduction

With the release of Tomcat 7, Java web application developers have an alternative to GlassFish 3 for testing and running web applications that use the new Servlet 3.0 specification that is part of Jave EE 6. Oracle provides a good online tutorial for learning about Java EE 6 and Servlet 3.0. However, the tutorial's example applications are geared toward either using NetBeans or Ant and the GlassFish 3 server. Since I use Maven and Tomcat, I wanted to try out the Servlet 3.0 example application in Tomcat 7. This article provides a Maven version of the mood example application that is part of the Servlet 3 tutorial. The "mavenized" version of the tutorial's mood project can be easily packaged and deployed to the Tomcat 7 Servlet/JSP container.

[More]

Tutorials On Shiro-A Java Security Framework-Updated

I updated the tutorials I wrote about Shiro (http://shiro.apache.org, formerly known as JSecurity and Ki) to use the latest version of the library. Shiro is a "Java security framework that performs authentication, authorization, cryptography, and session management". Shiro became a Top Level Apache project in September 2010 and version 1.1.0 of the library was released in November 2010.

In 2009, when I wrote the tutorials, Shiro was known as JSecurity and was on version 0.9. With the move to the new name and to Apache, the package structure of the library changed. I wanted to update my tutorials so that users trying to learn Shiro would have a better reference.

Shiro is licensed under the Apache Software License, Version 2.0

You can view the tutorials on Shiro (version 1.1.0) starting here.

Recommended Way To Structure A Spring 3, JPA 2, and Maven Web Application

Introduction

I've created an example application that uses Struts 2, Spring 3, JPA 2, Hibernate 3.5, and Maven. I need some advice from Java web application developers who are using Spring 3, JPA 2, and Maven. The programming team I'm part of is moving to JPA. We plan to use Hibernate as the JPA provider but we want to keep the dependency on Hibernate to a minimum. To reduce our direct dependency on Hibernate we are using the Spring - JPA configuration described in chapter 4 of Spring Persistence with Hibernate and in section 13.5 of the Spring 3 documentation (see references below). I've run into an issue with configuring my applications to follow this structure and I'd appreciate any advice from Java developers more experienced with Spring, JPA, and Maven.

[More]

Using BlazeDS Version 4 To Integrate A Flex Application With A Java Backend Built With Flash Builder

Introduction

Adobe and SpringSource are working together to make it easier for Java developers to use Java and Spring on the backend and Flex-Adobe's rich internet application framework [refer 2]--on the frontend.  Adobe has an open source project called BlazeDS [refer 8] that provides the plumbing to enable a Flex application to communicate data with a Java application running on a server.  The new version of the Flex IDE--Flash Builder 4 [refer 3]--provides extensive data wizards that can auto detect the services a Java application is exposing to a remote application such as the Flex client.  SpringSource has created a Spring Flex module [refers 1 and 6] that enables Java developers to use Spring to set up the BlazeDS plumbing on the server side and to use XML or annotations to mark which classes and methods should be available to be called by the Flex application.

[More]

Java Persistence Architecture 2.0 - Using The New TypedQuery Interface

Introduction

This is a continuation of articles on new features of JPA 2.0, which I'm studying because my programming team may adopt it as our standard for ORM. Another new feature provided by JPA 2.0 is TypedQuery. A TypedQuery is a JPA query that returns a specific type of Object. TypedQuery eliminates the need to cast the query result to a specific type or having to add a SuppressWarnings annotation to eliminate compiler warnings about unchecked conversions. TypedQuery is also used with the new JPA 2.0 CriteriaBuilder. Since some of the newer books and articles on JPA still only show the Query interface and don't mention the TypedQuery interface I thought a blog article and example application might be useful to others who are learning JPA 2.0.

[More]

More Entries

BlogCFC was created by Raymond Camden. This blog is running version 5.9.1.002. Contact Blog Owner