Search code examples
grails

grails error: The requested resource is not available


Can you tell me why I would get an HTTP Status 404 resource not available error when adding a new action to my controller in the following trivial way:

  • First, I added a statement, println "in list action", to the list action which Grails generated, to make sure I'm seeing the file updates made to the controller. This println then comes out on the console.
  • I added a new action "abc" in the controller, directly copying its code from the index action, i.e. making it simply redirect to the list action.

When I enter the browser address: http://localhost:8080/myApp/user/abc it returns resource not available. Re-starting grails did not help. If I enter http://localhost:8080/myApp/user/index, it works as expected.

Thanks


Solution

  • Lesson Learned: If you get this behavior, make sure you don't have incorrect code syntax in another action.


    I resolved this strange situation (to an extent anyway!). It turns out I was missing a closing brace in my top/first action, but had an extra closing brace in my second action. Don't know how this could have compiled, but apparently it did, as when I added sample new test actions further down, they worked eventually (which seemed strange). When I fixed the parenthesis issue, the second action worked then also

    Note, I am doing current Grails examples without using a full blown IDE, so perhaps the IDE would have caught this error.