Overcome i18n empty string error message

The problem:
If you are using an i18n supported system like spring (java), there might be a scenario where your application might call an empty string.
This might occur when you invoke the i18n with a null or an empty string (i.e. the i18n key was not set correctly and the jsp i18n tag could not find it).
Then, when trying to translate the message using your i18n messages.properties file, the server might throw an exception.

That exception might be disruptive in a production environment.
In order to throw a silent exception, I took the approach of null vs. empty object handling.
(i.e. prefer returning an empty object rater than null, when an error occurs).

The solution:
To avoid this exception, you can add an entry for an empty string to your i18n messages.properties like so:

conf.btn.submit = SUBMIT
conf.status.none = NONE
conf.status.deleted = DELETED
conf.status.inactive = INACTIVE
= i18n empty string error
conf.status.active = ACTIVE
conf.status.incomplete = INCOMPLETE
conf.status.pending = PENDING
conf.status.approved = APPROVED
conf.status.rejected = REJECTED

Ofcourse, you might want to use some other text than "error" according to the specific need of your application. Displaying "Error" is a way of floating up the problem without displaying the user/QA a blank screen.

This technique could also be used in development to focus on business logic development, however, I would recommend DELETING this empty i18n key during the last test days, before going to production, to minimize such exceptions.

Configuring envers with maven

Configuring envers with maven, hibernate and spring on eclipse.

  1. In eclipse
  2. find pom.xml
  3. click on the pom.xml tab to see the actual xml code
  4. Add the JBoss Repository according to: https://community.jboss.org/wiki/MavenGettingStarted-Developers
  5. Go to the Dependencies tab on the pom.xml
  6. click Add...
  7. Start writing "envers" in "Enter groupId..." field
  8. "org.hibernate hibernate-envers" should appear in the results, instead of the latest version, enter your hibernate version, or "${org.hibernate.version}" to copy it dynamically.
  9. save pom.xml

You now have envers configured, just add @Audited above the classes/properties you want to audit.