You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An exception occurs when constructing a new Smooks instance
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.smooks.Smooks]: Factory method 'smooks' threw exception with message: nested:/path/to/myapplication.jar
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:177)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:644)
... 68 common frames omitted
Caused by: org.smooks.api.SmooksException: nested:/path/to/myapplication.jar
at org.smooks.engine.DefaultApplicationContext.<init>(DefaultApplicationContext.java:93)
at org.smooks.engine.DefaultApplicationContextBuilder.build(DefaultApplicationContextBuilder.java:90)
at org.smooks.Smooks.<init>(Smooks.java:152)
....
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:258)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
at cloud.rio.dispatch.ediconverter.configuration.SmooksConfig$$SpringCGLIB$$0.smooksD20B(<generated>)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:140)
... 69 common frames omitted
Caused by: java.nio.file.NoSuchFileException: nested:/path/to/myapplication.jar
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
at java.base/sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:148)
at java.base/sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99)
at java.base/java.nio.file.Files.readAttributes(Files.java:1851)
at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1428)
at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:718)
at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:252)
at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:181)
at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:195)
at org.smooks.classpath.Scanner.handleArchive(Scanner.java:121)
at org.smooks.classpath.Scanner.scanClasspath(Scanner.java:104)
at org.smooks.engine.DefaultApplicationContext.<init>(DefaultApplicationContext.java:91)
... 82 common frames omitted
I did a little digging and found that the handling of URLs in org.smooks.classpath.Scanner#scanClasspath
public void scanClasspath(ClassLoader classLoader) throws IOException {
if (!(classLoader instanceof URLClassLoader)) {
LOGGER.warn("Not scanning classpath for ClassLoader '" + classLoader.getClass().getName() + "'. ClassLoader must implement '" + URLClassLoader.class.getName() + "'.");
return;
}
URL[] urls = ((URLClassLoader) classLoader).getURLs();
Set<String> alreadyScanned = new HashSet<String>();
for (URL url : urls) {
String urlPath = url.getFile();
urlPath = URLDecoder.decode(urlPath, "UTF-8");
if (urlPath.startsWith("file:")) {
urlPath = urlPath.substring(5);
}
if (urlPath.indexOf('!') > 0) {
urlPath = urlPath.substring(0, urlPath.indexOf('!'));
}
File file = new File(urlPath);
if(alreadyScanned.contains(file.getAbsolutePath())) {
LOGGER.debug("Ignoring classpath URL '" + file.getAbsolutePath() + "'. Already scanned this URL.");
continue;
} if (file.isDirectory()) {
handleDirectory(file, null);
} else {
handleArchive(file);
}
alreadyScanned.add(file.getAbsolutePath());
}
}
Describe the bug
An exception occurs when constructing a new Smooks instance
I did a little digging and found that the handling of URLs in
org.smooks.classpath.Scanner#scanClasspath
is incompatible with the class loader from spring boot, see spring-projects/spring-boot@7ad4a98. In the commit it was mentioned that
This seems to be the root of the
java.nio.file.NoSuchFileException: nested:/path/to/myapplication.jar
.To Reproduce
Create a spring boot project (v3.2.4) and create a bean of type Smooks.
Expected behavior
Instantiating Smooks works with class loaders from spring boot without the aforementioned exception.
Environment
Sample
Don't have one at the moment. Can do if required.
The text was updated successfully, but these errors were encountered: