Skip to content

NullPointerException thrown when ConfigurationClassEnhancer creates CGLIB proxy #34423

Description

@spencergibb

Spring cloud uses boots dependency management of framework

[INFO] |     +- org.springframework:spring-context:jar:6.2.3-SNAPSHOT:compile

@sbrannen thinks it mightt be related to #34274

I can share links to CI builds if needed.

These are examples of failing tests https://github.com/spring-cloud/spring-cloud-stream/blob/fb3c889c9cbbbe0314824f401895118ae4b37a27/core/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/binding/BindingServiceTests.java#L542-L557

java.lang.NullPointerException: Cannot read field "generatedClass" because "data" is null
	at org.springframework.cglib.proxy.Enhancer.nextInstance(Enhancer.java:783)
	at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:321)
	at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:562)
	at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:407)
	at org.springframework.context.annotation.ConfigurationClassEnhancer.createClass(ConfigurationClassEnhancer.java:169)
	at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:121)
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:539)
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:311)
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:363)
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:153)
	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:791)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:609)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:318)
	at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:149)
	at org.springframework.cloud.stream.binding.BindingServiceTests.bindingAutostartup(BindingServiceTests.java:544)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

Activity

  1. added
    in: coreIssues in core modules (aop, beans, core, context, expression)
    on Feb 13, 2025
  2. changed the title [-]NPE while framework is creating proxies[/-] [+]`NullPointerException` thrown when `ConfigurationClassEnhancer` creates CGLIB proxy[/+] on Feb 13, 2025
  3. added and removed on Feb 14, 2025
  4. self-assigned this
    on Feb 14, 2025
  5. added this to the 6.2.4 milestone on Feb 14, 2025
  6. wind57 commented on Feb 17, 2025

    @wind57
    Contributor
  7. added a commit that references this issue on Feb 17, 2025
  8. added a commit that references this issue on Feb 18, 2025
    93134fd
  9. added 3 commits that reference this issue on Feb 18, 2025
    4862819
    6786e1c
    b48d72c
  10. breun commented on Feb 24, 2025

    @breun

    I found that for me changing @Configuration to @Configuration(proxyBeanMethods = false) worked as a workaround for this NullPointerException with Spring Framework 6.2.3 (Spring Boot 3.4.3).

  11. added a commit that references this issue on Feb 24, 2025
  12. added 2 commits that reference this issue on Feb 24, 2025
    eecc508
    182e975
  13. added 2 commits that reference this issue on Feb 26, 2025
    06721ba
    a018ae6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: regressionA bug that is also a regression

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions