apache / apache/grails-core

Table per hierarchy on User class causes application not to start

Open
#15,883 1 comment 0 reactions 0 assignees View on GitHub
relates-to:spring-security
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

- [x] Steps to reproduce provided
- [x] Stacktrace provided
- [x] Example that reproduces the problem uploaded to Github
- [x] Full description of the issue provided (see below)

### Steps to Reproduce

1. Create a grails app
2. Install spring security core plugin `compile 'org.grails.plugins:spring-security-core:4.0.0'`
3. Add "tablePerHierarchy false" to User class
4. Extend another class from User

### Expected Behaviour

It should create a separate table for the extended class.

### Actual Behaviour

Application doesn't start and throws:

`
Disconnected from the target VM, address: '127.0.0.1:39131', transport: 'socket'
2020-05-08 19:15:10.534 ERROR --- [ restartedMain] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'authenticationProcessingFilterDeregistrationBean': Cannot resolve reference to bean 'authenticationProcessingFilter' while setting bean property 'filter'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationProcessingFilter': Cannot resolve reference to bean 'authenticationManager' while setting bean property 'authenticationManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationManager': Cannot resolve reference to bean 'daoAuthenticationProvider' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'daoAuthenticationProvider': Cannot resolve reference to bean 'userDetailsService' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userDetailsService': Unsatisfied dependency expressed through method 'setTargetDatastore' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastore': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.orm.hibernate.HibernateDatastore]: Constructor threw exception; nested exception is java.lang.NullPointerException
2020-05-08 19:15:10.584 ERROR --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
`

[Complete stacktrace](https://pastebin.com/9DZLnMYa)

The problem occurs only when trying to extend from the User class, it works ok with any other class.

### Environment Information

- **Operating System**: Linux Manjaro
- **GORM Version:** 7.0.4
- **Grails Version:** 4.0.3
- **JDK Version:** 1.8 openjdk

### Example Application

Github repository with example that reproduces the issue:
[https://github.com/richardvil/spring-security-core-user-hierarchy-error](https://github.com/richardvil/spring-security-core-user-hierarchy-error)

Contributor guide

Open the contributing guide

Research direction

Start with the linked example application and the complete stacktrace, then reproduce the failure with tablePerHierarchy false on User and a subclass. Trace the Hibernate datastore startup failure through the Spring Security user configuration; done means the application starts and the subclass receives a separate table.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy, spring
Domain
authentication, backend, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.