This is a rather strange problem, and I have been on it for a while, so I'm going crazy.
I have a controller that extends another controller, so I can have several controllers inheriting the method, and they go something like this:
class EventController extends EventAwareController { def springSecurityService def edit = { // this line prints out principal id println springSecurityService.principal.id def eventInstance = getAuthorizedEventById(params.id) if (!eventInstance) { flash.message = "${message(code: 'event.not.found.message')}" redirect(action: "list", controller: "event") return false } } class EventAwareController { def eventService def springSecurityService def getAuthorizedEventById(def eventId) { def event if (eventId) { // this springSecurityService is null and throws an error event = eventService.findAuthorizedEvent(eventId, springSecurityService.principal.id) if (event) { session.eventId = eventId } } return event } }
EventAwareController throws:
java.lang.NullPointerException: cannot get property 'main' on null object in com.ticketbranch.EventAwareController.getAuthorizedEventById (EventAwareController.groovy: 14)
but my prinln operator in EventController prints the main id without any problems?!? So, is SpringSecurityService introduced as null in the EventAwareController?
Any ideas? offers? Thanks.
Micor source share