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?)

Comment From: philwebb

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?

Comment From: funnelspider

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.

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

Comment From: philwebb

@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.

Comment From: funnelspider

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

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

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 ?

Comment From: scottfrederick

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.