Integrating Hibernate Validator with WebWork

Published 2 years ago

I’ve been using WebWork for a little side project and the only thing I’ve been missing from my full time work (technology-wise) is Hibernate Validator. WebWork’s visitor validation is fine (see this article for an example of it in use), but I’ve grown to really like having the validation rules right there in the class itself, and how easy it is to create your own validators.

I dug around for someone who had already integrated the two of them, but couldn’t find anything. So the other night I got inspired and took a look at the VisitorFieldValidator to see what it would take to drop in Hibernate’s validator. It wasn’t bad, just one method to touch, so I thought I would share what I came up with in hopes that it will be useful for someone else.

The code, and a little usage information, is available on the wiki

Good riddance JRun, Hello… Tomcat?

Published 2 years, 2 months ago

It’s been a long time coming, but we’ve finally migrated off of JRun! And yes, as unsexy as it is, we’ve moved over to Tomcat. Our application has been running on JRun since Y2K and it has been showing it’s age in recent months. We’ve had lots of issues with the server hanging, and apparent memory/connection leaks. Now some of that is the fault of the application, but we’ve had a very difficult time pinning down the connection leaks.

Well, we started a load testing project early this year and much to our surprise we found that JRun was actually our biggest bottleneck! We did a very quick port to get the app up on Tomcat and suddenly found we could handle 3 times the amount of load as compared to the JRun environment!

So we embarked on a full port of the application to Tomcat. We ran into a few things related to redirects in JSP’s and tag pooling, but otherwise it ported over fairly easily. I will try to go into the details of the tag pooling issue as it was subtle and took a good bit of puzzling over to determine exactly what was going on.

Benefits

So we’ve been in production on most of our servers for at least 2 weeks and here’s what we’ve seen so far:

  1. We’re using the logAbandoned feature in the DBCP connection pool and in the first couple of days we found 4 connection leaks in the code. In the subsequent weeks we haven’t come across any more leaks at all!
  2. Load on the application servers has dropped to 1/3 of levels while running JRun (on average).
  3. JVM memory usage is running about half of what it used to run under JRun.
  4. And finally we’ve picked up a little more than 2% in our “good” response times category (2 seconds or less).

So, while Tomcat may not be the sexiest app server out there it’s doing a good job for us, supports current generations of the J2EE specs, and the price sure is nice ;-) .

Closure

Now, everyone needs closure right? Well today we took care of that for our encounter w/JRun. We held a little bonfire where we burned all of our JRun documentation and packaging. Here are some pictures of our team and our little book burning. I can’t speak for the others, but I sure felt better afterwards!

Getting ready:


The team (Ken, Dave, Scott H, Scott M (Me), Andrew, Ramji) enjoys the burn:


Burn baby, burn!


The &@&! JRun box won’t give it up!


Golfer’s use of Google Maps

Published 2 years, 4 months ago

Getting ready to play some golf tomorrow morning. I’m playing a course I haven’t played in years so I thought I’d look around the web to see if I could find a course map to remind myself how things layed out. I found a site that had a link to Google Maps for the course, and that’s when it hit me. Using the satellite mode on Google Maps is a great way to walk your way around the course. I actually had to back off the closest zoom level as it was actually to tight to see the holes comfortably!

Hmm, wonder what Augusta National looks like… Wouldn’t have surprised me at all if the satellite images for the Augusta National area had somehow been “unavailable” on Google Maps as secretive as that bunch is…

Rails Migrations and Multiple Developers

Published 3 years ago

I’ve been reading a lot lately about the migrations feature of Ruby on Rails. Generally this looks like really cool functionality. However, one thing has been eating at me ever since I had my first glimpse at it:
How does it work in a multi-developer environment?

Now I know this has to have been considered in it’s design, and I’ve seen references to people using it, but I haven’t seen anyone mention how it’s handled.

Here’s the scenario I’m concerned about. The development team comes in one morning and everyone updates from source control. Everyone’s database schema is sitting at version 10.

Developer A sits down and starts working on feature A.1 which requires a new column on the users table. So he generates a migration:

script/generate migration add_user_inactive_date

which spits out:

11_add_user_inactive_date.rb in db/migrate

So far so good…

Developer B sits down and starts working on feature B.1 which requires a new table to be created. So he also generates a migration:

script/generate migration create_asset_history_table

which I assume spits out:

11_create_asset_history_table.rb in db/migrate

Both developers run their scripts again their local development databases, check in their code, and think that all is right with the world, each with their database schema version sitting at version 11, but each without the other’s changes…

So if this is the way it does actually work then we’ve got a problem, or several:

  • Developer A won’t ever get Developer B’s change applied to his database and vise versa.
  • If someone goes and roles back Developer A’s inactive date change (by rolling back to schema version 10) then their asset history page will suddenly stop working as it will drop the newly created table as well.

There are probably more issues, but you get the point. So can anyone out there explain how this is handled in Rails?

The funny thing is the only reason this is relevant to me is that I just implemented a similar solution where I work. We started down a very similar path (before I even knew about Rails Migrations) by adding a new column to our AppVersion table to track the schema update date/version. As we got further into the implementation we realized this wasn’t going to cut it. We wound up with a table that tracks every script that has been applied to the database (we use SQL scripts to apply changes to the schema). This allows us to have an ant task that just looks in the directory where these scripts are stored, check the database and then just load scripts that haven’t yet been applied (ordered by date plus an optional sequence number). Ours isn’t so fancy as to have an automated rollback capability, but we’re just happy to have this process automated at all at this point.

Anyway, it’s not something I’m going to lose sleep over and I don’t actively even use Rails, but it’s just been eating at me so I thought I’d throw it out there.

Contact Form Spam

Published 3 years, 1 month ago

Argh!!!! Just the last 3-4 days I’ve all of a sudden started having a problem. I’ve generally been able to shutdown comment spam with the captcha graphic I’ve been using, but all of a sudden I’ve started getting spam through the contact form plugin I use. The thing is I don’t understand the motivation. The emails are absolute garbage. Here is the content of one of them:

b986f2d783b921b06b5fba93b8c67852

Now how does that benefit anyone? Maybe something is screwed up and this wasn’t the intented contents? I don’t know what’s going on, but I’m ready for it to stop.

Anyone else seeing this?