I ran into an issue while running Grails 1.2.1 and Shiro for security. I'm
not sure if I'm doing something wrong, or if this is a bug, but it seems
like a bug. Please advise if and where I should report this.

1) grails create-app newapp
2) cd newapp
3) grails install-plugin shiro
4) grails quick-start

5) Create a controller called ErrorsController.groovy

class ErrorsController {
  def serverError = {
    render(view:"error")
  }
        
  def notFound = {
    render(view:'notFound')
  }
}

[Note: The error view already exists from when you generated the app, but
the notFound one doesn't. You can create the notFound view, but it won't
make a difference. ]

6) Change grails-app/conf/UrlMappings.groovy and add the following 404
definition - 

class UrlMappings {
  static mappings = {
    "/$controller/$action?/$id?"{
      constraints {
        // apply constraints here
      }
    }
    "/"(view:"/index")
    "500"(view:'/error')          
    "404"(controller:"errors", action:"notFound")
  }
}

7) grails run-app
8) Go to

http://localhost:8080/newapp/asdf  

and you'll get the following Stack Trace:

java.lang.IllegalStateException: No SecurityManager accessible to the
calling code, either bound to the org.apache.shiro.util.ThreadContext or as
a vm static singleton.  This is an invalid application configuration.
        at
org.apache.shiro.SecurityUtils.getSecurityManager(SecurityUtils.java:115)
        at org.apache.shiro.SecurityUtils.getSubject(SecurityUtils.java:57)
        at ShiroGrailsPlugin.accessControlMethod(ShiroGrailsPlugin.groovy:414)
        at ShiroGrailsPlugin.accessControlMethod(ShiroGrailsPlugin.groovy)
        at
ShiroGrailsPlugin$_closure3_closure19.doCall(ShiroGrailsPlugin.groovy:228)
        at
SecurityFilters$_closure1_closure2_closure3.doCall(SecurityFilters.groovy:12)
        at
SecurityFilters$_closure1_closure2_closure3.doCall(SecurityFilters.groovy)
        at java.lang.Thread.run(Thread.java:619)

9) Now if you want to see things get nasty, add the following 500 definition
to you UrlMappings.groovy and watch the console:

class UrlMappings {
  static mappings = {
    "/$controller/$action?/$id?"{
      constraints {
        // apply constraints here
      }
    }
    "/"(view:"/index")
    "500"(controller:"errors", action:"serverError")  
    "404"(controller:"errors", action:"notFound")
  }
}

-- 
View this message in context: 
http://n2.nabble.com/Issue-with-Grails-Shiro-tp4568683p4568683.html
Sent from the Shiro User mailing list archive at Nabble.com.

Reply via email to