Tuesday, November 23, 2010

GrailsExceptionResolver null pointer exception

This is the message I got after I hit a button in the gsp with an action="waiver".

23.11.10 09:36:35.054] ERROR errors.GrailsExceptionResolver - null
java.lang.NullPointerException
at java.lang.Thread.run(Thread.java:619)

I had a hard time to figure out this problem. The associated controller had an action:

def waiver = {
}

and the waver.gsp exists.

Now why did the exception happen? The reason was, because the controller has a method called getWaiver().

Friday, November 19, 2010

Log4J problem after deployment to Tomcat

The problem not happens on STS with Jetty.

By mistype a log statement, instead of:
log.debug("....")
typed
Log.debug("...."), oops that's wrong!!
this was the cause for an exception on the tomcat server:

org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: org.mortbay.log.Log
org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet.doDispatch(GrailsDispatcherServlet.java:318)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70)
org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:293)
org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:269)
org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:261)
org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter.doFilterInternal(UrlMappingsFilter.java:181)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.obtainContent(GrailsPageFilter.java:171)
org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.doFilter(GrailsPageFilter.java:110)
org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:65)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
root cause
java.lang.NoClassDefFoundError: org.mortbay.log.Log
SocService$_save_closure1.class$(SocService.groovy)
SocService$_save_closure1.$get$$class$org$mortbay$log$Log(SocService.groovy)
SocService$_save_closure1.doCall(SocService.groovy:86)
SocService.save(SocService.groovy:44)
SocService$$FastClassByCGLIB$$830c874e.invoke()
net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
SocService$$EnhancerByCGLIB$$277a9fbf.save()
SocService$save.call(Unknown Source)
DocumentEditController$_closure2_closure33_closure117.doCall(DocumentEditController.groovy:997)


Config.groovy entries:
// log4j configuration
log4j = {
appenders {
console name: 'stdout', layout: pattern(conversionPattern:'%d{[dd.MM.yy HH:mm:ss.SSS]} %-5p %c{2} %x - %m%n')
rollingFile name: 'file', layout: pattern(conversionPattern:'%d{[dd.MM.yy HH:mm:ss.SSS]} %-5p %c{2} %x - %m%n'), file: 'fab.log'
}
root {
error()
additivity = true
}

error 'org.codehaus.groovy.grails.web.servlet', // controllers
'org.codehaus.groovy.grails.web.pages', // GSP
'org.codehaus.groovy.grails.web.sitemesh', // layouts
'org.codehaus.groovy.grails."web.mapping.filter', // URL mapping
'org.codehaus.groovy.grails."web.mapping', // URL mapping
'org.codehaus.groovy.grails.commons', // core / classloading
'org.codehaus.groovy.grails.plugins', // plugins
'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
'org.springframework',
'org.hibernate'

debug file:['grails.app']
'org.hibernate'
//stdout:'grails.app'

warn 'org.mortbay.log'

}