Skip to content

java.lang.IllegalArgumentException: name org.springframework.boot.loader.LaunchedURLClassLoader.findResource #19098

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

Closed
Roronoa-Zoro opened this issue Nov 22, 2019 · 9 comments

Comments

@Roronoa-Zoro
Copy link

Roronoa-Zoro commented Nov 22, 2019

please see below exception:

2019-11-22 14:34:52.829 - - [ERROR] main XXXXXXFactory  failed to load properties file: classpath:config/app.properties
java.lang.IllegalArgumentException: name
        at sun.misc.URLClassPath$Loader.findResource(URLClassPath.java:658) ~[?:1.8.0_45]
        at sun.misc.URLClassPath.findResource(URLClassPath.java:188) ~[?:1.8.0_45]
        at java.net.URLClassLoader$2.run(URLClassLoader.java:569) ~[?:1.8.0_45]
        at java.net.URLClassLoader$2.run(URLClassLoader.java:567) ~[?:1.8.0_45]
        at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_45]
        at java.net.URLClassLoader.findResource(URLClassLoader.java:566) ~[?:1.8.0_45]
        at org.springframework.boot.loader.LaunchedURLClassLoader.findResource(LaunchedURLClassLoader.java:58) ~[xxx-server-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]

When we run java -jar xxx-server-1.0.0-SNAPSHOT.jar in local macbook, it's ok,
we run it in our test env, we get those exception. (centos 6.8)

below code triggered above exception:

URL url = Thread.currentThread().getContextClassLoader().getResource(file);

file is String, and we try to use "classpath:config/app.properties", "classpath*:app.properties", "config/app.properties", we all get above exception.

jdk:1.8
springboot:2.2.1
spring: 5.2.1

Can you please figure it out? Thanks a lot.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 22, 2019
@wilkinsona
Copy link
Member

We can try to figure it out, but we'll need some more information to be able to do so. Can you please create a minimal sample that reproduces the problem and share it with us by zipping it up and attaching it to this issue?

Given that this works for you on macOS but fails on CentOS, there's a chance that the problem is operating system- or environment-specific so any information about your macOS environment and your CentOS environment and the differences between them would also be useful.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Nov 22, 2019
@Roronoa-Zoro
Copy link
Author

We can try to figure it out, but we'll need some more information to be able to do so. Can you please create a minimal sample that reproduces the problem and share it with us by zipping it up and attaching it to this issue?

Given that this works for you on macOS but fails on CentOS, there's a chance that the problem is operating system- or environment-specific so any information about your macOS environment and your CentOS environment and the differences between them would also be useful.

Thanks a lot for your reply, there's another information, Thread.currentThread().getContextClassLoader() is Launcher$AppClassLoader when I run in IDEA, but LaunchedURLClassLoader in test environment(centOS).
I will create a sample later.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Nov 23, 2019
@wilkinsona wilkinsona added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Nov 23, 2019
@spring-projects-issues
Copy link
Collaborator

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Nov 30, 2019
@spring-projects-issues
Copy link
Collaborator

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

@spring-projects-issues spring-projects-issues removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged labels Dec 7, 2019
@wilkinsona wilkinsona added the status: invalid An issue that we don't feel is valid label Dec 7, 2019
@woodforda
Copy link

Hi,
I'm actually having this issue as well. In my case it's to do with finding a resource (as stream) which looks something like this C:\Users\woodford/.keystore (this is coming out of Apache CXF org.apache.cxf.configuration.jsse.SSLUtils - calling soap service). Once the getResourceAsStream is called I receive the IllegalArgumentException.

I'm in a large application and am trying to isolate it in a repeatable test. Linux works fine... windows fails - only when using the fat jar. Boot 2.2.4. Java 1.8

cheers,
Andrew

@woodforda
Copy link

pretty easy to duplicate - https://github.com/woodforda/issue-classloader

See readme for details.

@wilkinsona wilkinsona reopened this May 15, 2020
@wilkinsona wilkinsona added status: waiting-for-triage An issue we've not yet triaged and removed status: invalid An issue that we don't feel is valid labels May 15, 2020
@wilkinsona
Copy link
Member

Thanks for the reproducer, @woodforda. We'll take a look.

@woodforda
Copy link

I suspect this is not an issue. It's due to the MalformedURl (which is from rubbish CXF code).

If I force usage of the URLClassLoader it too has the same issue. It's just that it's not normally the class loader you get when running another way... (i.e. not fat jar).

I have to work around the CXF defaults - currently just setting javax.net.ssl.keyStore to something non existent and compliant works - though doesn't leave a pleasant taste.

@wilkinsona
Copy link
Member

Thanks, @woodforda. The differences in behaviour between the system class loader and a URL class loader are unfortunate. In the past, we've considered trying to work around them but decided not to do so (see #1744 and #2057 for example). I still think that was the right decision so I'm going to close this one again. Thanks for sharing your findings. Hopefully they'll help others in the future.

@wilkinsona wilkinsona removed the status: waiting-for-triage An issue we've not yet triaged label May 18, 2020
JeanPrince pushed a commit to AxaFrance/webengine-java that referenced this issue Dec 23, 2024
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

4 participants