delta2006
delta2006

Reputation: 423

Grails working with legacy database SQL server

A simple Grails 1.3.7 applications with SQL server 2000. connection OK. create new table OK. however, when trying to access existing tables, see error below. Constraints: cannot change the existing data. Questions: what file is this error line [35] in? Is there any way to allow null object (e.g. NOT to get property 'id' when the object is null)?

Error 500:
Servlet: default
URI: /root0001/person/list
Exception Message: Cannot get property 'id' on null object
Caused by: Error evaluating expression [personInstance.id] on line [35]: Cannot get property 'id' on null object
Class: /person/list
At Line: [35]
Code Snippet:
Stack Trace

org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error evaluating expression [personInstance.id] on line [35]: Cannot get property 'id' on null object

    at person_list$_run_closure2_closure27.doCall(person_list:67)

    at person_list$_run_closure2.doCall(person_list:60)

    at person_list$_run_closure2.doCall(person_list)

    at person_list.run(person_list:76)

    at java.lang.Thread.run(Thread.java:722)

Caused by: java.lang.NullPointerException: Cannot get property 'id' on null object

    at person_list$_run_closure2_closure27_closure34.doCall(person_list:67)

    ... 5 more

Upvotes: 0

Views: 342

Answers (1)

This is likely happening in your list.gsp, in the section that tries to render the personInstance Id. You can use the Groovy safe dereference operator to hack past this, but you may want to investigate why your database is returning a null object for the list view.

Upvotes: 1

Related Questions