Thursday, 10 February 2011

java.lang.NoClassDefFoundError when sending async emails in Grails

Issue
Exception while sending emails in production environment.

If you are trying to send emails from your application asynchronously, using the Mail plugin, in the production environment you may see an exception like:
java.lang.NoClassDefFoundError: org/springframework/mock/web/MockHttpServletRequest 
This is because of a bug in the Mail plugin. This plugin uses the MockHttpServletRequest class from the spring framework test jar which is not bundled when you run the 'grails prod war' command.


Resolution

Copy the org.springframework.test-3.0.3.RELEASE.jar from %GRAILS_HOME%\lib into your application's lib folder. By doing this, the plugin will find the MockHttpServletRequest class that it relies on at runtime in production.

No comments:

Post a Comment