History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: GRAILS-572
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Graeme Rocher
Reporter: Marc Palmer
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Grails

Changing service results in HTTP ERROR: 500 java.lang.NullPointerException: Cannot get property: fullName on null object

Created: 08/Jan/07 11:41 AM   Updated: 30/Jan/07 02:06 PM
Component/s: None
Affects Version/s: 0.4
Fix Version/s: 0.4

Time Tracking:
Not Specified


 Description  « Hide
I have a service storing navigation data. This data is static even though it's a service (due to other workarounds).

If I change the data (in NavigationService), usually grails will fail to reload the non-transactional service and return:

HTTP ERROR: 500

java.lang.NullPointerException: Cannot get property: fullName on null object

The controller:

class ContentController extends BaseController {

	def beforeInterceptor = checkVisitor
	def afterInterceptor = NavigationService.initDefaultModelVariables
	
	def view = { 
		
		render( view: params.id)
	}
	
}

The initDefaultModelVariables closure puts some of the static data into the model:

// Move this to core and look for a service/bean that exposes the menu?
static initDefaultModelVariables = { model -> model['menuStructure'] = menuStructure model['menuByUrl'] = menuByUrl model['menuByName'] = menuByName }



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Marc Palmer - 09/Jan/07 04:03 PM
This fails, even if services inject, because of a deliberate typo:
import org.springframework.mail.MailException
import org.springframework.mail.MailSender
import org.springframework.mail.SimpleMailMessage

class MailService {
	
	static boolean transactional = false
	
	MailSender mailSender
	SimpleMailMessage mailMessage // a "prototype" email instance

	/**
	 * Send a list of emails
	 *
	 * @param mail an object with to, text and subject (from is in resources.xml)
	 */
	def sendEmail(mail) {
        // Create a thread safe "sandbox" of the message
        SimpleMailMessage message = new SimpleMailMessage(defaultMailMessage)
        message.to = mail.to
        message.text = mail.text
        message.subject = mail.subject

	    try {
	        mailSender.send(message)
	    } catch (MailException ex) {
	        println "Failed to send email"
	        ex.printStackTrace()
	    }
	}
}

If you correct the typo (change decl of mailMessage to defaultMailMessage) and reload, you get the 500 error