Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems running this example #1

Open
thomashoelzl opened this issue May 16, 2015 · 4 comments
Open

Problems running this example #1

thomashoelzl opened this issue May 16, 2015 · 4 comments

Comments

@thomashoelzl
Copy link

Hi Alvarao!

I wanted to try your example from greach2014. I downloaded it. Started it with STS without any problems. I was hoping to be able to authenticate with curl:

C:\Users\atw1t1r5>curl -i -H "Content-Type: application/json" -X POST -d '{"username":"jimi","password":"jimispassword"}' http://localhost:8080/restful-grails-springsecurity-greach2014/api/login
HTTP/1.1 400 Bad Request
Server: Apache-Coyote/1.1
Content-Length: 0
Date: Sat, 16 May 2015 18:51:40 GMT

But I got a 400 Bad Request. I didn't change anything. Did I use the curl command wrong. I would be great if you could give me a hint.

Thanks a lot.

Thomas

@alvarosanchez
Copy link
Owner

I have just typed the same curl request and it works:

$ curl -i -H "Content-Type: application/json" -X POST -d '{"username":"jimi","password":"jimispassword"}' http://localhost:8080/restful-grails-springsecurity-greach2014/api/login
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Cache-Control: no-store
Pragma: no-cache
Set-Cookie: JSESSIONID=4E9C303A2B037C7AE098E7975C4ABD08; Path=/restful-grails-springsecurity-greach2014/; HttpOnly
Content-Type: application/json;charset=UTF-8
Content-Length: 126
Date: Tue, 19 May 2015 08:29:37 GMT

{"username":"jimi","roles":["ROLE_ADMIN","ROLE_USER"],"token_type":"Bearer","access_token":"ds7kbdr4bn0nrtnpntc397rjegcv71rp"}

@norricorp
Copy link

yes, using curl works fine. I downloaded the code and run ex02 and that does work in a browser so I will look for differences in the code and report back.

@norricorp
Copy link

I did find some differences in the code - dumb typos on my part.
But I am left with an error from the server
ERROR org.grails.web.errors.GrailsExceptionResolver - NullPointerException occurred when processing request: [GET] /todos
Stacktrace follows:
java.lang.reflect.InvocationTargetException: null
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: grails.views.ViewRenderException: Error rendering view: BUG! exception in phase 'instruction selection' in source unit 'todo_todo__todo_gson' unexpected NullpointerException

Looking at views/todo/_todo.gson I have the same as your example code. So no idea what is happening.

@norricorp
Copy link

and having restarted app again, it now works. I did change logging but that would not have made a difference. So issue closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants