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

IllegalAccessError for package-private member of AzureStorageConfiguration on WebSphere #34684

Closed
sachinkumar579 opened this issue Mar 29, 2025 · 4 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: regression A bug that is also a regression
Milestone

Comments

@sachinkumar579
Copy link

Getting an exception after upgrading from Spring boot 3.3.8 to 3.3.9 .

Caused by: java.lang.IllegalAccessError: Class 'com.azure.spring.cloud.autoconfigure.implementation.storage.AzureStorageConfiguration$$SpringCGLIB' illegally accessing package-private member of class 'com.azure.spring.cloud.autoconfigure.implementation.storage.AzureStorageConfiguration'
at com.azure.spring.cloud.autoconfigure.implementation.storage.AzureStorageConfiguration$$SpringCGLIB.()

spring-cloud-azure-dependencies : 5.19.0
Java : A custom image built on websphere-liberty:kernel-java17-openj9

Please note it seems to be working fine with OpenJDK 17 .

Since Spring framework is responsible for creating CGLib proxies for configuration classes , posting it here.
Spring Framework 6.1.17 version shipped with Spring Boot 3.3.9. Previous spring boot version 3.3.8 had Spring Framework 6.1.17, which seemed to work fine .

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 29, 2025
@jhoeller
Copy link
Contributor

jhoeller commented Mar 31, 2025

When exactly is that exception being thrown? Could you post the full stacktrace, at least to the degree that Spring is involved? Is this about a package-visible @Bean method?

Also, what's the different ClassLoader involved? The CGLIB subclass is being generated into a different ClassLoader than the original user class in such a scenario.

In any case, this looks like a regression caused by #34274. We'll see what we can do about using the original ClassLoader of the configuration class in such a scenario, as we did before.

@jhoeller jhoeller added type: regression A bug that is also a regression in: core Issues in core modules (aop, beans, core, context, expression) and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Mar 31, 2025
@jhoeller jhoeller self-assigned this Mar 31, 2025
@jhoeller jhoeller added this to the 6.2.6 milestone Mar 31, 2025
@jhoeller jhoeller changed the title BeanCreationException after upgrading from Spring boot 3.3.8 to 3.3.9 IllegalAccessError for package-private member of AzureStorageConfiguration on WebSphere Mar 31, 2025
@jhoeller jhoeller added the for: backport-to-6.1.x Marks an issue as a candidate for backport to 6.1.x label Mar 31, 2025
@github-actions github-actions bot added status: backported An issue that has been backported to maintenance branches and removed for: backport-to-6.1.x Marks an issue as a candidate for backport to 6.1.x labels Mar 31, 2025
@jhoeller
Copy link
Contributor

jhoeller commented Apr 1, 2025

@sachinkumar579 I have not been able to locally reproduce this yet. As you say, it seems to be working fine on OpenJDK/HotSpot, with the package visibility check happening at a different point there. It'd be great if you could provide the stacktrace for that IllegalAccessError indeed, otherwise it's hard to consider what we can do to be equally defensive on OpenJ9 as well.

@jhoeller jhoeller added the status: waiting-for-feedback We need additional information before we can continue label Apr 1, 2025
@jhoeller
Copy link
Contributor

jhoeller commented Apr 2, 2025

I've added an explicit check for package visibility, always defining the generated subclass in the same ClassLoader as the original user class then. This is the only way to guarantee that package visibility works consisently: within the same ClassLoader. Previously, we relied on CGLIB class generation to fail in that case but apparently it does not fail consistently there, potential causing errors later on.

@jhoeller jhoeller removed the status: waiting-for-feedback We need additional information before we can continue label Apr 2, 2025
jhoeller added a commit that referenced this issue Apr 2, 2025
@jhoeller
Copy link
Contributor

jhoeller commented Apr 2, 2025

This is available in the latest 6.2.6 and 6.1.19 snapshots now. Please give it an early try and let me know whether it works for you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

3 participants