Skip to content

Author Archives: Priyatam

Spring Security 3 Unit Testing Example with DbUnit

This tutorial extends on the baseline laid by Spring Security Tutorial maven archetype. I’ve modified the spring security config file and will be unit testing a simple ProfileService (CRUD) on a Profile entity (User object). The tests include login/logout and spring services security unit testing. application-security.xml <?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd [...]

Debugging MySQL ERROR1025 – Error on rename of

If you ever executed the following command in mysql: alter table table drop column; and got the following error: 1025 – Error on rename of ‘.\\#sql-880_3c’ to ‘.\\ ’ (errno: 150), Don’t panic. It’s probably because you’re trying to drop a column that’s a foreign key. Execute this command: SHOW ENGINE INNODB STATUS to debug more. [...]

Migrating from Hibernate 3.3.2, JPA 1 to Hibernate 3.5 CR2 and JPA 2

Starting with version 3.5 (currently CR2), Hibernate Annotations 3.x and Hibernate EntityManager projects have been merged into the Hibernate Core codebase as invidual modules. As a surprising addition, Hibernate Envers subproject is added as well (that’s a great thing as you get Auditing, out of box hereafter). So if you’re stuck with Hibernate 3.3.x and [...]

Custom Logout Filter handler in Spring 3

Spring Security provides comprehensive support for adding custom handlers for logout/login. The default logout simply logs the user out and goes to the login page. What if the application needs to determine the user’s role and redirect to a separate screen? For example, for an admin, a custom logout screen. What if the user is [...]

Accessing Drools 5 rules via a restful API using Drools Server and Groovy RestClient

If you haven’t heard about drools, you should have a look at it now. It provides multiple ways to write rules: DSL (drl files), groovy, java, excel spreadsheets or via a web interface (Guvnor). I recommend the book, Drools – JBoss Rules 5.0 by Michael Bali as its the only comprehensive documentation available on drools. [...]

Java PURL (Personalized URL) Generator encoder/decoder example

Have you ever noticed the unscubscribe url pattern when you unsubscribe from an online promotion or retail marketing campaign? It looks something like this: www.somesite.com/unsubscribe/u/NSFAHPF/aW5aaW1pdHk Ideally, you would want the user to click that (personalized) URL and the system should automatically unsubscribe, or perform any simple non-secure operations like registering for a poll. How would [...]

an interesting class loading issue with quartz scheduler timing (NoClassDefFoundError)

My quartz job schedulers had a startDelay of 0 ms and a repeatInterval of 10 mins and 5 mins each. On my local environment (win/mac) and sandbox (unix) the scheduler works just fine. But in our production environment (unix), we were getting spurious java.lang.NoClassDefFoundError: Could not initialize class Foo. Now Foo was one of the [...]

The best 59$, a java developer can ever invest

If you don’t buy this now, you’re either dumb. Or just plainly stupid. For the impatient: it’s a small jar that lets you compile/run/deploy java instantly, like php. I’ts the real HOT DEPLOY that jvm lacks out of the box. No more restarting the server, ever again, even after reconfiguring Spring beans. I used this [...]

JBoss Seam 2.1 Presentation at Java Meetup

Here’s my presentation on JBoss Seam 2.1 from the Boston Java meetup group Introduction To JBoss Seam 2.1 View more presentations from Priyatam M.

Generic Entity Converter for JSF / Spring / JPA

If you’ve come across Seam’s <s:convertEntity> and wondered why isn’t one there for JSF, here you go: Before using this, you should’ve designed your domain model to extend a Base Class (do it, it’s a good practice). In my case, I have BaseIdentityEntity which has an @Id, @Version properties import java.io.Serializable; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; [...]