grails / grails-spring-security-core

Grails Spring Security Core Plugin
Apache License 2.0
260 stars 223 forks source link

Grails 3.0.7 - web-api profile startup errors #379

Closed jeffwils closed 6 years ago

jeffwils commented 9 years ago

Grails 3.0.7 Groovy 2.4.4 JDK 1.8.0_45 spring-security-core repo - http://dl.bintray.com/grails/plugins spring-security-core plugin - org.grails.plugins:spring-security-core:3.0.0.M1

When creating a new grails app with the web-api profile, then adding the spring security core plugin, starting the application produced the following error

Configuring Spring Security Core ...
... finished configuring Spring Security Core

ERROR grails.boot.GrailsApp - Application startup failed
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grails.plugin.springsecurity.LoginController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void grails.plugin.springsecurity.LoginController.setTagLibraryLookup(org.grails.taglib.TagLibraryLookup); nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.grails.taglib.TagLibraryLookup] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grails.plugin.springsecurity.LoginController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void grails.plugin.springsecurity.LoginController.setTagLibraryLookup(org.grails.taglib.TagLibraryLookup); nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.grails.taglib.TagLibraryLookup] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1210) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]

    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1210)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]

    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
    at org.springframework.beans.factory.support.AbstractBeanFa at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
ctory.getBean(AbstractBeanFactory.java:194) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) ~[spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) ~[spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.2.5.RELEASE.jar:1.2.5.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) ~[spring-boot-1.2.5.RELEASE.jar:1.2.5.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) ~[spring-boot-1.2.5.RELEASE.jar:1.2.5.RELEASE]
    at grails.boot.GrailsApp.run(GrailsApp.groovy:52) [grails-core-3.0.7.jar:3.0.7]
    at grails.boot.GrailsApp.run(GrailsApp.groovy:330) [grails-core-3.0.7.jar:3.0.7]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
    at grails.boot.GrailsApp.run(GrailsApp.groovy:319) [grails-core-3.0.7.jar:3.0.7]
    at grails.boot.GrailsApp.run(GrailsApp.groovy:52)
    at grails.boot.GrailsApp$run.call(Unknown Source) [grails-core-3.0.7.jar:3.0.7]
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) [groovy-2.4.4.jar:2.4.4]
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) [groovy-2.4.4.jar:2.4.4]
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133) [groovy-2.4.4.jar:2.4.4]
    at japixx.Application.main(Application.groovy:8) [main/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void grails.plugin.springsecurity.LoginController.setTagLibraryLookup(org.grails.taglib.TagLibraryLookup); nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.grails.taglib.TagLibraryLookup] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:649) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    ... 21 common frames omitted
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.grails.taglib.TagLibraryLookup] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1301) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1047) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:942) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:606) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
    ... 23 common frames omitted
    at grails.boot.GrailsApp.run(GrailsApp.groovy:330)
    at grails.boot.GrailsApp.run(GrailsApp.groovy:319)
    at grails.boot.GrailsApp$run.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
    at japixx.Application.main(Application.groovy:8)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void grails.plugin.springsecurity.LoginController.setTagLibraryLookup(org.grails.taglib.TagLibraryLookup); nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.grails.taglib.TagLibraryLookup] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:649)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
    ... 21 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.grails.taglib.TagLibraryLookup] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1301)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1047)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:942)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:606)
    ... 23 more

FAILURE: Build failed with an exception.
volnei commented 8 years ago

Any plan to release the 3.0.0.M2?

@alvarosanchez

Thanks

hamdrew commented 8 years ago

I have also encountered this issue and am unable to find a suitable workaround. Spring Security wants to provide an HTML login form, which opposes the idea of the web-api profile.

graemerocher commented 8 years ago

The plugin needs to be split out into a web part and a non web-part, in the meantime the workaround is to add the GSP plugin to your application:

   compile "org.grails:grails-plugin-gsp"
graemerocher commented 8 years ago

For some reason my commit closed this issue, but this issue is still valid and requires the plugin to be reworked and split into web and non-web parts

ddelponte commented 6 years ago

@jeffwils there does not appear to be a web-api profile available:

| Available Profiles
--------------------
* angular - A profile for creating Grails applications with Angular 5+
* rest-api - Profile for REST API applications
* base - The base profile extended by other profiles
* angularjs - A profile for creating applications using AngularJS
* plugin - Profile for plugins designed to work across all profiles
* profile - A profile for creating new Grails profiles
* react - A profile for creating Grails applications with a React frontend
* react-webpack - A profile for creating Grails applications with a React frontend using Webpack
* webpack - A profile for creating applications with node-based frontends using webpack 2
* web - Profile for Web applications
* rest-api-plugin - Profile for REST API plugins
* vue - A profile for creating Grails applications with a Vue.js frontend
* web-jboss7 - A Profile for Creating a JBoss 7.1 EAP Project
* web-plugin - Profile for Plugins designed for Web applications

Would you be so kind as to clarify which profile is causing the issue?

ddelponte commented 6 years ago

Marking this as Cannot Reproduce and closing.

I will be happy to reopen it if you would be so kind as to attach or link to a sample app which reproduces the problem.