0

I have this app that needs to run with gsp reloading active (don't judge me, I already do it daily myself). The app has recently being ported from 2.2.3 to 2.4.5 and it almost went flawlessly.

Now in the action of a controller, I write:

render(view:red,model:pMap());

Where 'red' is the path of the view and pMap generates the scope.

It all works well except for one thing. When the 'red' path is referencing a missing resource, I would expect it to go 404 as it used to do in the previous version.

What I get instead is a terrifying:

NullPointerException occurred when processing request: [GET] /app/ass
Stacktrace follows:
java.lang.NullPointerException
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Needless to say the action that handles the error detects a 500 instead of a 404.

Any idea of why this could happen? Anything I could to fix this mess?

Thanks in advance

Simone Pezzano
  • 197
  • 2
  • 10

1 Answers1

1

You can check before the render call, if the view file exists, like here. When it doesn't exist you can change the status code to 404, link.

As far as I know it throws an NPE, because a toString() is called in org.codehaus.groovy.grails.web.metaclass.RenderDynamicMethod#renderView on a null map value, because the view doesn't exist.

Community
  • 1
  • 1
user3584190
  • 151
  • 6
  • It doesn't look like. Maybe this site helps a little bit http://grails.github.io/grails-doc/2.4.x/guide/upgradingFrom22.html – user3584190 Jun 29 '15 at 12:06