jeffwils / grails-spring-security-saml

Grails Spring Security SAML2.0 Plugin for Grails 3
8 stars 24 forks source link

Exception on load #1

Closed mburak closed 7 years ago

mburak commented 7 years ago

I'm getting this when I add the v3 of the plugin:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsApplicationPostProcessor' defined in brinqa.Application: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [grails.boot.config.GrailsApplicationPostProcessor]: Factory method 'grailsApplicationPostProcessor' threw exception; nested exception is grails.plugins.exceptions.PluginException: Failed to initialize class [test.TestRole] from plugin [springSecuritySaml] : org/grails/datastore/gorm/GormEntity$Trait$FieldHelper
        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:115)
        at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:686)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:524)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:762)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:372)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
        at grails.boot.GrailsApp.run(GrailsApp.groovy:83)
        at grails.boot.GrailsApp.run(GrailsApp.groovy:388)
        at grails.boot.GrailsApp.run(GrailsApp.groovy:375)
        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 brinqa.Application.main(Application.groovy:8)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [grails.boot.config.GrailsApplicationPostProcessor]: Factory method 'grailsApplicationPostProcessor' threw exception; nested exception is grails.plugins.exceptions.PluginException: Failed to initialize class [test.TestRole] from plugin [springSecuritySaml] : org/grails/datastore/gorm/GormEntity$Trait$FieldHelper
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
        ... 23 common frames omitted
Caused by: grails.plugins.exceptions.PluginException: Failed to initialize class [test.TestRole] from plugin [springSecuritySaml] : org/grails/datastore/gorm/GormEntity$Trait$FieldHelper
        at org.grails.plugins.BinaryGrailsPlugin.initializeProvidedArtefacts(BinaryGrailsPlugin.java:175)
        at org.grails.plugins.BinaryGrailsPlugin.<init>(BinaryGrailsPlugin.java:104)
        at grails.plugins.DefaultGrailsPluginManager.createBinaryGrailsPlugin(DefaultGrailsPluginManager.java:375)
        at grails.plugins.DefaultGrailsPluginManager.findCorePlugins(DefaultGrailsPluginManager.java:362)
        at grails.plugins.DefaultGrailsPluginManager.attemptLoadPlugins(DefaultGrailsPluginManager.java:314)
        at grails.plugins.DefaultGrailsPluginManager.loadPlugins(DefaultGrailsPluginManager.java:224)
        at grails.boot.config.GrailsApplicationPostProcessor.initializeGrailsApplication(GrailsApplicationPostProcessor.groovy:89)
        at grails.boot.config.GrailsApplicationPostProcessor.setApplicationContext(GrailsApplicationPostProcessor.groovy:225)
        at grails.boot.config.GrailsApplicationPostProcessor.<init>(GrailsApplicationPostProcessor.groovy:77)
        at grails.boot.config.GrailsAutoConfiguration.grailsApplicationPostProcessor(GrailsAutoConfiguration.groovy:68)
        at brinqa.Application.grailsApplicationPostProcessor(Application.groovy)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
        ... 24 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/grails/datastore/gorm/GormEntity$Trait$FieldHelper
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
        at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:677)
        at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:787)
        at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:775)
        at org.grails.plugins.BinaryGrailsPlugin.initializeProvidedArtefacts(BinaryGrailsPlugin.java:173)
        ... 40 common frames omitted

It looks like trying to load a different version of gorm? Any ideas?

n8price commented 7 years ago

I'm also getting this error: Failed to initialize class [test.TestRole] from plugin

I'm assuming this is referring to className being set to test.testRole in the plugins application.yml file:

grails:
  plugin:
    springsecurity:
      authority:
        className:  'test.testRole'

I attempted to overwrite this value in the project's application.yml file but it doesn't appear to accept that value, falling back to the plugin defaults.

jeffwils commented 7 years ago

The plugin has Spring Security Test Classes to perform testing on the plugin. As this plugin is dependent on the Spring Security Core Plugin, The plugin assumes that the Spring Security will be set up as well.

Either you don't have the spring security quickstart classes.... or they are not in your application.yml/application.groovy

To resolve this. Run the Spring Security Plugin s2-quickstart Read More

You have an opportunity to specify the package and classname. The quickstart will create the 3 domain classes and populate application.groovy with the following entries:

grails.plugin.springsecurity.userLookup.userDomainClassName = 'your.package.User' grails.plugin.springsecurity.userLookup.authorityJoinClassName = 'your.package.UserRole' grails.plugin.springsecurity.authority.className = 'your.package.Role' grails.plugin.springsecurity.authority.nameField = 'authority'

You can then convert that to application.yml as well.

I will add this to the documentation as well.

jeffwils commented 7 years ago

I created this plugin against an application that already had all of the required spring security dependencies and settings in place. I have updated the documentation to outline those other configuration items (build.gradle and applicatIon.(groovy/yml) and have also added examples of all 3 of those files which will fully load successfully and then allow you to change the configuration to match your sp/idp setup.

n8price commented 7 years ago

Thanks so much. I'll give it a try soon.

jeffwils commented 7 years ago

Version 3.1.0 of the plugin has been released. It resolves the GORM incompatibility issues as well. If your grails app uses version 3.0.x then use version 3.0.0 of the plugin. If your grails app is 3.1+ then use the 3.1.0 version of the plugin.