|
Hi all,
I'm following Jeff's video tutorial "Build Twitter in 90 Minutes". I have done step creating Status controller with this code:
package org.grails.twitter
import org.grails.twitter.auth.Person
class StatusController {
def springSecurityService
def index = {
def messages = currentUserTimeline()
[messages:messages]
}
def updateStatus = {
def status = new Status(message: params.message)
status.author = lookupPerson()
status.save()
def messages = currentUserTimeline()
System.out.println(messages)
render(template: 'messages', collection: messages, var:'message')
}
private currentUserTimeline() {
def messages = Status.withCriteria {
or {
author {
eq('username',springSecurityService.principal.username)
}
}
maxResults(10)
order('dateCreated', 'desc')
}
messages
}
private lookupPerson() {
Person.get(springSecurityService.principal.id)
}
}
Which it's returns error, here's full stacktrace:
[org.grails.twitter.Status : 9, org.grails.twitter.Status : 8, org.grails.twitter.Status : 7, org.grails.twitter.Status : 6, org.grails.twitter.Status : 5, org.grails.twitter.Status : 4, org.grails.twitter.Status : 3, org.grails.twitter.Status : 2, org.grails.twitter.Status : 1]
| Error 2012-07-06 13:30:23,440 [http-bio-8080-exec-4] ERROR errors.GrailsExceptionResolver - NullPointerException occurred when processing request: [POST] /sftwitter/status/updateStatus - parameters:
message: Test
Update Status: Update Status
Cannot get property 'author' on null object. Stacktrace follows:
Message: Cannot get property 'author' on null object
Line | Method
->> 15 | doCall in C__Users_Didin_Documents_NetBeansProjects_sftwitter_grails_app_views_status__messages_gsp$_run_closure1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 20 | doCall in org.grails.twitter.StatusController$_closure2$$ENcMr9A6
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
Tell me where's the problem? I'm using Grails 2.0.4 and Spring security core 1.2.7.3 Thanks, Didin |
|
This post has NOT been accepted by the mailing list yet.
Jeff's tutorial dates from 2010. So if you start with grails 1.3.5 and use spring-security 1.0.1 you MIGHT get somewhere.
I too am a relative newcommer to Grails but the one thing I have learned is that *none* of the examples that were created for grails 1.x.x work when you try to "do" them using Grails 2.x.x. There are just too many small changes that you have to know how about. OK - to be accurate I suppose I should say - I have discovered that I do not posses the skills to enable me to convert Grails 1.x.x examples to Grails 2.x.x Of course - if any other reader knows *any* examples that they have converted From Grails 1.x.x to 2.x.x then I guess we would both love to know where they can be found (EVEN IF we have to do the conversion again ourselves). Honestly that would be wonderful. Good luck |
| Powered by Nabble | Edit this page |
