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

SpringProperties: the ClassLoader might be null, if class is loaded by the bootstrap class loader [SPR-11721] #16343

Closed
spring-projects-issues opened this issue Apr 22, 2014 · 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: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Apr 22, 2014

Artem Bilan opened SPR-11721 and commented

The NPE is here:

ClassLoader cl = SpringProperties.class.getClassLoader();
			URL url = cl.getResource(PROPERTIES_RESOURCE_LOCATION);

The similar issue is here: http://stackoverflow.com/questions/1921238/getclass-getclassloader-is-null-why


Affects: 3.2.8, 4.0.3

Reference URL: http://stackoverflow.com/questions/23228968

Issue Links:

Backported to: 3.2.9

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Indeed, getClassLoader() may return null for the bootstrap loader depending on the JVM. We're falling back to ClassLoader.getSystemResource(name) now, since even ClassLoader.getSystemClassLoader() may return null...

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

While being at it, I've updated all our classpath resource accessing spots with a fallback to the system ClassLoader or (if even that is null) to getSystemResource(s).

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Artem, does this work for you now, against 4.0.4 and/or the latest 3.2.9 snapshot? What does your deployment layout actually look like there?

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Artem Bilan commented

Thanks, Juergen, for your attention!

Spring Integration works well with those snapshots:
https://build.spring.io/browse/INT-MEIGHT
https://build.spring.io/browse/INT-SIJDK7

I can't say anything about that issue, because the original was from SO post. I mentioned there that you fixed it, but it is without feedback

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: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants