我正在尝试在 Grails 中使用 Oauth2,但无法正常工作。尝试获取接入点时出现 NullPointerException。
所以更多细节:使用Spring Security Oauth2 Provider插件。我在 BootStrap.groovy 中注册了一个客户端(使用 BaseClientDetails),根据教程,客户端可以使用以下 URL 使用 tokenEndpointUrl 设置(默认为 /oauth/token)中给出的 URL 登录:localhost:8080/app/ oauth/token?grant_type=client_credentials&client_id=clientId&client_secret=clientSecret 。
但是 grails.plugin.cache.web.filter.PageFragmentCachingFilter 抛出异常,在下面描述的方法中,由于某种奇怪的原因,controllerClass 为 null。
841 protected Object lookupController(Class<?> controllerClass) { <br>
842 return getBean(controllerClass.getName()); <br>
843 }
并且控制器类为空,因为 grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter 试图从上下文( getContext().getControllerClass() )中获取控制器类,但返回了空。
全栈在这里http://pastebin.com/euramNaS
当我通过常规登录流程时(不是直接使用 URL,而是通过登录表单)。我在同一个地方获取了 LoginController。在调试模式下,我将断点设置为“有问题的”行,并使用 LoginController 手动更改 controllerClass(添加 controllerClass = LoginController.class 来观看)它成功了,我收到了带有令牌的 JSON。
尝试制作空应用程序以清楚地重现问题并重现问题。所以可以找到测试项目http://goo.gl/1gmtT。
任何想法为什么直接访问 url 时无法初始化控制器?