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

LaunchedClassLoader issue Illegal character in opaque part when log4j2.xml (or any file) is in a jar file #38827

Closed
funnelspider opened this issue Dec 15, 2023 · 5 comments
Labels
status: duplicate A duplicate of another issue

Comments

@funnelspider
Copy link

funnelspider commented Dec 15, 2023

I have a spring boot application which is started via

java -jar app.jar 

It uses log4j2 as a logging framework

Recently I updated to java 21 (from java 17) and to spring boot 3.1.5 / 3.2.0 from spring boot 2.7.4

With the old java and spring boot 2.7.4 log4j find the log4j2.xml with no issues

DEBUG StatusLogger Apache Log4j Core 2.17.2 initializing configuration XmlConfiguration[location=jar:file:/C:/Program%20Files%20(x86)/my_app/app.jar!/BOOT-INF/classes!/log4j2.xml]

With the new spring boot 3.1.5 it fails

WARN StatusLogger Error accessing jar:nested:/C:/Program Files (x86)/my_app/app.jar/!BOOT-INF/classes/!/log4j2.xml due to Illegal character in opaque part at index 22: jar:nested:/C:/Program Files (x86)/my_app/app.jar/!BOOT-INF/classes/!/log4j2.xml, ignoring.

Far as I can tell the old spring boot was using the LaunchedUrlClassLoader while the new one is using LaunchedClassLoader

This in turn uses a wrong format for the URL (spaces not converted to %20?)

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 15, 2023
@funnelspider funnelspider changed the title LaunchedClassLoader issue when log4j2.xml (or any file) is in a jar file LaunchedClassLoader issue Illegal character in opaque part when log4j2.xml (or any file) is in a jar file Dec 15, 2023
@philwebb
Copy link
Member

This may well be a duplicate of #38660. @funnelspider are you able to give the latest 3.2.1-SNAPSHOT a try to see if we've already fixed this one?

@philwebb philwebb added the status: waiting-for-feedback We need additional information before we can continue label Dec 15, 2023
@funnelspider
Copy link
Author

funnelspider commented Dec 15, 2023

tried it right now and with version 3.2.1-SNAPSHOT i still get the same error

WARN StatusLogger Error accessing jar:nested:/C:/Program Files (x86)/my_app/app.jar/!BOOT-INF/classes/!/log4j2.xml due to Illegal character in opaque part at index 22: jar:nested:/C:/Program Files (x86)/my_app/app.jar/!BOOT-INF/classes/!/log4j2.xml, ignoring.

image

@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 Dec 15, 2023
@philwebb
Copy link
Member

@funnelspider Thanks for trying the SNAPSHOT. Do you have a sample project you can share that replicates the problem. Either a GitHub project or a zip file.

@philwebb philwebb added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Dec 15, 2023
@funnelspider
Copy link
Author

funnelspider commented Dec 16, 2023

I couldn't reproduce the issue with a new spring boot project so I started checking what is wrong in my project
It seems that the spring-boot-maven-plugin wasn't using the 3.2.1-SNAPSHOT version and I was getting the wrong spring-boot loader.

Forcing the correct 3.2.1-SNAPSHOT plugin seems to do the trick

image

So it is indeed fixed in the 3.2.1-SNAPSHOT build.
Log now looks like this
DEBUG StatusLogger Apache Log4j Core 2.17.2 initializing configuration XmlConfiguration[location=jar:nested:/C:/Program%20Files%20(x86)/app/app.jar/!BOOT-INF/classes/!/log4j2.xml]

When will this be released ?

@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 Dec 16, 2023
@scottfrederick
Copy link
Contributor

Thanks for trying the snapshot and letting us know it fixed your problem.

You can see the scheduled dates for releases on the GitHub milestones page and on the Spring release calendar.

@scottfrederick scottfrederick closed this as not planned Won't fix, can't repro, duplicate, stale Dec 16, 2023
@scottfrederick scottfrederick added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Dec 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

4 participants