Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grails 5.1.6: integration tests, bootRun, bootWar are broken #12460

Closed
gschueler opened this issue Mar 31, 2022 · 28 comments
Closed

Grails 5.1.6: integration tests, bootRun, bootWar are broken #12460

gschueler opened this issue Mar 31, 2022 · 28 comments

Comments

@gschueler
Copy link

Expected Behavior

integration tests should run
bootRun gradle task should run
bootWar war product should run

Actual Behaviour

Exception is thrown:

./gradlew bootRun

> Task :bootRun
2022-03-31 14:36:25.370 ERROR --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'compositeViewResolver': Unsatisfied dependency expressed through field 'viewResolvers'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jspViewResolver': Cannot create inner bean '(inner bean)#4f48b570' of type [grails.plugin.scaffolding.ScaffoldingViewResolver] while setting bean property 'innerViewResolver'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#4f48b570': Cannot resolve reference to bean 'groovyPagesTemplateEngine' while setting bean property 'templateEngine'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'groovyPagesTemplateEngine': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'classLoader' of bean class [org.grails.gsp.GroovyPagesTemplateEngine]: Bean property 'classLoader' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:659)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:639)
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
        at grails.boot.GrailsApp.run(GrailsApp.groovy:99)
        at grails.boot.GrailsApp.run(GrailsApp.groovy:485)
        at grails.boot.GrailsApp.run(GrailsApp.groovy:472)
        at test.g516.Application.main(Application.groovy:11)
        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.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jspViewResolver': Cannot create inner bean '(inner bean)#4f48b570' of type [grails.plugin.scaffolding.ScaffoldingViewResolver] while setting bean property 'innerViewResolver'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#4f48b570': Cannot resolve reference to bean 'groovyPagesTemplateEngine' while setting bean property 'templateEngine'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'groovyPagesTemplateEngine': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'classLoader' of bean class [org.grails.gsp.GroovyPagesTemplateEngine]: Bean property 'classLoader' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:389)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:134)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1707)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1452)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
        at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1607)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1571)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1460)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1347)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:656)
        ... 26 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#4f48b570': Cannot resolve reference to bean 'groovyPagesTemplateEngine' while setting bean property 'templateEngine'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'groovyPagesTemplateEngine': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'classLoader' of bean class [org.grails.gsp.GroovyPagesTemplateEngine]: Bean property 'classLoader' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:342)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:113)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1707)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1452)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:374)
        ... 42 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'groovyPagesTemplateEngine': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'classLoader' of bean class [org.grails.gsp.GroovyPagesTemplateEngine]: Bean property 'classLoader' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1744)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1452)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:330)
        ... 48 common frames omitted
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'classLoader' of bean class [org.grails.gsp.GroovyPagesTemplateEngine]: Bean property 'classLoader' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
        at org.springframework.beans.BeanWrapperImpl.createNotWritablePropertyException(BeanWrapperImpl.java:243)
        at org.springframework.beans.AbstractNestablePropertyAccessor.processLocalProperty(AbstractNestablePropertyAccessor.java:432)
        at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:278)
        at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:266)
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:104)
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:79)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1740)
        ... 56 common frames omitted

Steps To Reproduce

  1. grails create-app myapp
  2. cd myapp
  3. ./gradlew bootRun

Environment Information

OS: macos
JDK: openjdk version "1.8.0_302"

Example Application

No response

Version

5.1.6

@rainboyan
Copy link
Contributor

rainboyan commented Apr 1, 2022

Downgrade from Spring Framework 5.3.18 to 5.3.17, and Spring Boot 2.6.5 build and released with 5.3.17, waiting for next Grails release based on Spring Boot 2.6.6 and Spring Framework 5.3.18.

Update gradle.properties:

spring.version=5.3.17

@boardbloke
Copy link

+1 from me - would like to do the upgrade to get Spring's mitigation for Spring4Shell, but currently cannot

@jmfdz
Copy link

jmfdz commented Apr 1, 2022

Same issue here.

@xqliu
Copy link

xqliu commented Apr 1, 2022

Same issue here, upgrade from 5.1.5 to 5.1.6 by just change gradle.properties and didn't change any other settings, meet same issue

@xqliu
Copy link

xqliu commented Apr 1, 2022

BTW: Seems the security issue has been fixed on springboot 2.6.6, not 2.6.5, am I missing something

https://spring.io/blog/2022/03/31/spring-framework-rce-early-announcement

@rainboyan
Copy link
Contributor

GroovyPagesTemplateEngine need a GroovyPageClassLoader, not the ref("classLoader"), so I think it may be wrong, we can remove the line or set it null, it will be initialized by initGroovyClassLoader.

    // Setup the main templateEngine used to render GSPs
    groovyPagesTemplateEngine(GroovyPagesTemplateEngine) { bean ->
        classLoader = ref("classLoader")
        groovyPageLocator = groovyPageLocator
        if (enableReload) {
            reloadEnabled = enableReload
        }
        tagLibraryLookup = gspTagLibraryLookup
        jspTagLibraryResolver = jspTagLibraryResolver
        cacheResources = enableCacheResources
    }

I have a workaround to fix this error, see the demo here ->
https://github.com/rainboyan/grails-issue-12460-demo

@puneetbehl
Copy link
Contributor

@rainboyan I am surprised that it breaks after updating the Spring and Spring Boot version for Grails as that is the only change between 5.1.5 and 5.1.6. I would like to investigate further that why it is broken now.

@rainboyan
Copy link
Contributor

@puneetbehl related Spring Framework issue here: spring-projects/spring-framework#28261

@rainboyan
Copy link
Contributor

Grails 4 app could be upgrade to Spring Framework 5.3.18, I create another demo here, it works with grails-gsp 4.0.3, but I'm not sure it works for the other old plugins, need a lot of tests!

@codeconsole
Copy link
Contributor

#12467

@xqliu
Copy link

xqliu commented Apr 5, 2022

Hi Team,

Is there any update to this issue or anything we can do to help on resolving this issue?

Thanks.

@JasonTypesCodes
Copy link
Member

We are still working through the framework-wide implications of this issue. Spring has labeled the upstream issue as a regression. Current experimentation with Spring Core 5.3.19-SNAPSHOT has been yielding positive results. Presuming that the official release of Spring Core 5.3.19 resolves this issue and does not introduce any other complications, we will be releasing a new Grails 5.1 to use the updated dependency from Spring.

@rainboyan
Copy link
Contributor

Spring Framework 5.3.19 will be released on April 13, 2022, Spring Boot 2.6.7 will be released on April 21, 2022.
I test Grails 5.1.6 with Spring Framework 5.3.19-SNAPSHOT, it works now. But Grails Gradle Plugin 5.1.3 still use Spring Boot 2.6.4, we should release a new version align with Spring Boot 2.6.5 or 2.6.6.

@rainboyan
Copy link
Contributor

Spring Framework 5.3.19 and 5.2.21 are available now

In addition, Spring Framework 5.3.19 and 5.2.21 include a fix for CVE-2022-22968: Spring Framework Data Binding Rules Vulnerability and are recommended upgrades for all Spring production scenarios.

@jnunderwood
Copy link

My Grails 5.1.6 app was failing due to this issue. However, when I upgrade Spring by using spring.version=5.3.19 in my gradle.properties files, it runs. Thanks!

@codeconsole
Copy link
Contributor

codeconsole commented Apr 14, 2022

My Grails 5.1.6 app was failing due to this issue. However, when I upgrade Spring by using spring.version=5.3.19 in my gradle.properties files, it runs. Thanks!

I can confirm gradle.properties

spring.version=5.3.19

fixes this issue.

I can also confirm Grails 5.1.6 points to Spring Boot 2.6.4

@JasonTypesCodes Considering 5.1.6 is completely broken and doesn't even point to the correct version, I would recommend releasing 5.1.7 as soon as possible.

Otherwise, anyone attempting to use the latest version of Grails will be banging their head against the wall.

#12472

@codeconsole
Copy link
Contributor

I can confirm Grails 5.1.7 fixes this issue and points to Spring 5.3.19 but it still points to Spring Boot 2.6.4

@rainboyan
Copy link
Contributor

@codeconsole There is an easy way to set spring-boot version in Grails project, the reason why Grails 5.1.7 still points to Spring Boot 2.6.4 could be found in the comments #12472.

apply plugin: "io.spring.dependency-management"

dependencyManagement {
    imports {
        mavenBom "org.springframework.boot:spring-boot-starter-parent:$springBootVersion"
    }
}

@codeconsole
Copy link
Contributor

@rainboyan adding your spring boot 2.6.6. workaround breaks Grails 5.1.7 with the previous error

Error creating bean with name 'groovyPagesTemplateEngine': Error setting property values; 
nested exception is org.springframework.beans.NotWritablePropertyException: 
Invalid property 'classLoader' of bean class [org.grails.gsp.GroovyPagesTemplateEngine]: 
Bean property 'classLoader' is not writable or has an invalid setter method. 
Does the parameter type of the setter match the return type of the getter?
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:389)

@rainboyan
Copy link
Contributor

rainboyan commented Apr 15, 2022

@codeconsole Sorry for the missing part, the full Gradle build script is:

Until Spring Boot 2.6.7 have been released, you should manually upgrade the Spring Framework dependency in your Spring Boot application. To override the Spring Framework version in your Maven or Gradle build, you should use the spring-framework.version property.

In gradle.properties, use spring-framework.version 5.3.19, not the previous spring.version, please use managed dependency versions that are provided by Spring Boot.

grailsVersion=5.1.7
grailsGradlePluginVersion=5.1.3
springBootVersion=2.6.6
spring-framework.version=5.3.19

build.gradle

buildscript {
    repositories {
        maven { url "https://repo.grails.org/grails/core" }
        maven { url "https://plugins.gradle.org/m2/" } // (1)
    }
    dependencies {
        classpath "io.spring.gradle:dependency-management-plugin:1.0.11.RELEASE" // (2)
        classpath "org.grails:grails-gradle-plugin:$grailsGradlePluginVersion"
        classpath "org.grails.plugins:hibernate5:7.2.2"
        classpath "gradle.plugin.com.github.erdi.webdriver-binaries:webdriver-binaries-gradle-plugin:2.6"
        classpath "com.bertramlabs.plugins:asset-pipeline-gradle:3.3.4"
    }
}

version "0.1"
group "org.grails.demo"

apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin: "io.spring.dependency-management" // (3)
apply plugin:"org.grails.grails-web"
apply plugin:"com.github.erdi.webdriver-binaries"
apply plugin:"com.bertramlabs.asset-pipeline"
apply plugin:"org.grails.grails-gsp"

repositories {
    maven { url "https://repo.grails.org/grails/core" }
}

// (4)
dependencyManagement {
    imports {
        mavenBom "org.springframework.boot:spring-boot-starter-parent:$springBootVersion"
    }
}

configurations {
    all {
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            // (5) Micronaut required
            if (details.requested.group == 'jakarta.annotation' && details.requested.name == 'jakarta.annotation-api') {
                details.useVersion '2.0.0'
            }
        }
    }
    developmentOnly
    runtimeClasspath {
        extendsFrom developmentOnly
    }
}

@codeconsole
Copy link
Contributor

@rainboyan thanks, I incorrectly assumes 2.6.6 used 5.3.19

What's the point of the large configurations block?

Using just

    implementation 'jakarta.annotation:jakarta.annotation-api:2.0.0'

works for me.

@rainboyan
Copy link
Contributor

@codeconsole my pleasure. Spring Boot and Micronaut use different version jakarta.annotation-api, use direct dependency also works.

@darxriggs
Copy link
Contributor

@puneetbehl Do you plan to release a new Grails version using Spring Framework 5.3.19 and Spring Boot 2.6.7?

@puneetbehl
Copy link
Contributor

Yes, there will be a Grails 5.2.0 release soon. However, this error should be resolved with Grails 5.1.7 which updates to Spring 5.3.19.

@rainboyan
Copy link
Contributor

@puneetbehl Grails 5.2 branch will based on Spring Boot 2.6.x or 2.7.x? last week, Spring Boot 2.7.0-RC1 has been released, and will be GA next month.

I also noticed that Grails 6.0.x branch was created, switch to Groovy 4, is that will be using Spring Boot 3.0?

https://github.com/grails/grails-core/wiki/Roadmap was outdated a lot, the goals for the next phase should be updated.
I suggest that using GH project to manage the tasks and issues, grails users and developers in the community will join discussions and give some help or feedback as they can.

@puneetbehl
Copy link
Contributor

Grails 5.2 will be based on 2.6. We would probably do another minor release of Grails 5 once 2.7 is released.

@puneetbehl
Copy link
Contributor

I will update the roadmap soon. Also, the feedback from the community is always welcome regardless we use Github projects or not. In the past, I tried to use the Github Project but I wasn't able to keep up with it. I will try to give it another try and also discuss the same in Grails Engineering Meeting next week. Thanks!

@rainboyan
Copy link
Contributor

@puneetbehl thanks for your reply. thank you for your hard work. Very much looking forward to Grails 6, and seeing the Team to talk about the big move.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants