Skip to content

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

Closed

Description

@spring-projects-issues

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

Activity

  1. spring-projects-issues commented on Apr 23, 2014

    @spring-projects-issues
    CollaboratorAuthor

    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

  2. spring-projects-issues commented on Apr 23, 2014

    @spring-projects-issues
    CollaboratorAuthor

    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

  3. spring-projects-issues commented on May 12, 2014

    @spring-projects-issues
    CollaboratorAuthor

    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

  4. spring-projects-issues commented on May 12, 2014

    @spring-projects-issues
    CollaboratorAuthor

    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

  5. added
    type: bug
    status: backported
    in: core
    on Jan 11, 2019
  6. added this to the 4.0.4 milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: corestatus: backportedtype: bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions