Archive for the ‘Spring’ Category

Spring Integration Presentation with Mark Fisher

Monday, July 21st, 2008

I had a chance to attend Mark Fisher's presentations a couple of times before at NEJUG. This time around, it was a local Java Meetup group in Cambridge. He's a very humble and knowledgeable guy about a lot of things, from Spring to Hibernate to Seam, to Scala & MDA! With ...

Generating Excel Formulas with Spring MVC and POI

Thursday, May 15th, 2008

I figured I'd lay this out there. It's not awesome code, just quick and dirty. But it works. [java] @Override protected void buildExcelDocument(Map model, HSSFWorkbook workbook, HttpServletRequest req, HttpServletResponse resp) throws Exception { //CREATE THE SHEET String periodDate = (String)model.get(PAYROLL_PERIOD_KEY); HSSFSheet sheet = workbook.createSheet(periodDate); sheet.setDefaultColumnWidth((short) 12); ...

Limitations of AbstractTransactionalDataSourceSpringContextTests

Tuesday, May 13th, 2008

This has apparently gotten a fair amount of attention over the last year or so, but I never encountered it until today- call me lucky. Here's the situation, you're using Spring MVC and you have a controller that extends another controller (A->B). Your unit test extends AbstractTransactionalDataSourceSpringContextTests, and makes use of ...

HSQLDB Integration Into Spring Security

Friday, May 2nd, 2008

Adding a database back end to Spring Security seems deceptively simple. And to be fair, there are several ways to do it. The way I had in mind looked like a shortcut. In my application there is basically one table for all users. It contains the values I need for username, ...

Spring Security -> Replacing Acegi

Thursday, May 1st, 2008

Astute readers of my last Acegi article will note that Acegi has been assimilated into the Spring project, and is now called Spring Security. This next example is how I was able to get Spring Security running on my webapp. I decided early on that I did not want to mess ...

Configuring Applications with Spring

Monday, April 28th, 2008

Carbon Five Community has a really nice article on different ways of implementing/overriding properties files in Spring. In a real-world application, we not only need to collect settings, but also override them in different environments. Many of our applications are deployed in 4 or more environments (developer machine, build server, staging ...

Acegi 1.0.8 Example (Life Without the SecurityEnforcementFilter)

Monday, April 28th, 2008

Note; This was my first day of adding Acegi to an existing webapp. You can find a lot of Acegi security framework examples on the web these days. Unfortunately, nearly all of the examples use Acegi use the pre 1.0 version, which is before someone removed the SecurityEnforcementFilter.. The official description ...

Step by Step Tutorials - DWR with Spring, Ajax - Dynamic drop down lists

Wednesday, November 7th, 2007

Scenario: A simple jsp page with a standard drop down box. A Selection criteria (could be another drop down box and a couple of check boxes) to change the values in these drop down box dynamically, without submitting the page. What you will learn: Configure dwr.xml with spring beans Configure application contexts for ...

Example code, sending emails using Spring SimpleMailMessage, MimeMessagePreparator and Velocity Templates

Monday, November 5th, 2007

When I first wrote my custom Email utlity 4 years back using JavaMail, it spread well over hundred lines of code. Looking at Spring's out of the box functionality for sending Emails with attachements & velocity templates makes you wanna feel sorry for your old code. The reference doc by ...

Adding a default error page in your webapp using SimpleMappingExceptionResolver

Thursday, June 14th, 2007

The next time you thought of writing a detailed exception handling logic for your webapp but continued to show java.lang.NullPointerException to the end users on the webpage. The following simple snippet of code would save you some harassmment from your manager more often than you think. Add this in your xxx-servlet.xml ...

Spring Hibernate Annotation Criteria Query Example

Tuesday, May 29th, 2007

I've written the start of another data load updating framework. This time I'm using Spring, Hibernate, and Hibernate Annotations. It took a little tweaking to get this to work, and so I've decided to add my example in the hopes that this will help others get started quickly. This is a ...

Configuration Properties, LOVs, static data using Spring Config

Tuesday, May 8th, 2007

If you have a small project, often you would have webpages which load a bunch of dropdown values or static data; like a List of Values (LOVs) which have a code and description. Most probably you would be configuring these in a database and access via dao or even sophisticated ...

Debugging Spring MVC Startup Errors In Tomcat

Sunday, April 29th, 2007

I've been getting startup errors trying to deploy this spring MVC application: SEVERE: Error listenerStart I can't find the error in the logs since this is a container start up error. Here's what I did: Prequisite: attach the spring src Put a breakpoint in the ContextLoaderListener: in the spring jar on the build path, find ...

Testing JdbcTemplates with HSQLDB

Monday, April 9th, 2007

I'm writing an application that's going to perform some serious data munging with a database. The schema has been defined (mostly) but there's no data I can use to test. For a short period of time I added my own data to the dev db server, but I found that ...

Spring JDBCTemplate Example

Wednesday, March 14th, 2007

At my latest client engagement I've become the king of batch applications. Small, stand-alone applications run via a scheduler or a set of shell scripts that perform a heavy amount of data-munging. The problem with being assigned batch applications is that they're never allocated much time in the project plan; ...