apache / apache/grails-core

Referring to Thing.gormPersistentEntity from inside domain class Thing causes exception during build

Open
#12,660 5 comments 0 reactions 0 assignees View on GitHub
closed: notabug status: awaiting feedback
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

### Expected Behavior

```./gradlew build```

should not throw exception

### Actual Behaviour

```
$ ./gradlew build

Welcome to Gradle 7.2!

Here are the highlights of this release:
- Toolchain support for Scala
- More cache hits when Java source files have platform-specific line endings
- More resilient remote HTTP build cache behavior

For more details see https://docs.gradle.org/7.2/release-notes.html

Starting a Gradle Daemon, 1 stopped Daemon could not be reused, use --status for details

> Task :configureChromeDriverBinary
Downloading https://chromedriver.storage.googleapis.com/2.45/chromedriver_linux64.zip
Unpacking /home/peter/.gradle/webdriver/chromedriver/2.45.0/chromedriver_linux64/1ropgkuyqn7cy6rtlx2wlvynq/chromedriver_linux64.zip to /home/peter/.gradle/webdriver/chromedriver/2.45.0/chromedriver_linux64/1ropgkuyqn7cy6rtlx2wlvynq

> Task :configureGeckoDriverBinary
Downloading https://github.com/mozilla/geckodriver/releases/download/v0.30.0/geckodriver-v0.30.0-linux64.tar.gz
Unpacking /home/peter/.gradle/webdriver/geckodriver/0.30.0/geckodriver-v0.30.0-linux64.tar/euthfmvi7pbf1d5mgtkqs707x/geckodriver-v0.30.0-linux64.tar.gz to /home/peter/.gradle/webdriver/geckodriver/0.30.0/geckodriver-v0.30.0-linux64.tar/euthfmvi7pbf1d5mgtkqs707x

> Task :test

ThingSpec > initializationError FAILED
org.springframework.beans.factory.BeanCreationException at ConstructorResolver.java:315
Caused by: org.springframework.beans.BeanInstantiationException at BeanUtils.java:224
Caused by: java.lang.ExceptionInInitializerError at Unsafe.java:1042
Caused by: java.lang.IllegalStateException at GormEnhancer.groovy:467

1 test completed, 1 failed

> Task :test FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///home/peter/Nextcloud/Hal-Con/example/build/reports/tests/test/index.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1m
13 actionable tasks: 13 executed
```

### Steps To Reproduce

```
$ grails --version
| Grails Version: 5.1.2
| JVM Version: 11.0.15

$ grails create-app example

$ cd example

$ grails create-domain-class Thing

$ nano grails-app/domain/example/Thing.groovy

# Add the following line inside the Thing domain class
static tmp = Thing.gormPersistentEntity

$ ./gradlew build
```

### Environment Information

$ uname -a
Linux redacted 3.10.0-1160.2.1.el7.x86_64 #1 SMP Mon Sep 21 21:00:09 EDT 2020 x86_64 x86_64 x86_64 GNU/Linux
$ java --version
openjdk 11.0.15 2022-04-19 LTS
OpenJDK Runtime Environment Corretto-11.0.15.9.1 (build 11.0.15+9-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.15.9.1 (build 11.0.15+9-LTS, mixed mode)

### Example Application

https://github.com/spierepf/example2

### Version

5.1.2

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure in the example application by adding `static tmp = Thing.gormPersistentEntity` to `grails-app/domain/example/Thing.groovy` and running `./gradlew build`. Start with the `GormEnhancer.groovy:467` stack-trace location; done means the build completes without the initialization exception.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.