How to use in Tomcat java.nio.file.spi.FileSystemProvider: software.amazon.nio.spi.s3.S3FileSystemProvider Unable to get public no-arg constructor #539
Replies: 4 comments 1 reply
-
It does have a I think it should be easy to add one if you want to make a PR. I will address this but it might not be this week. |
Beta Was this translation helpful? Give feedback.
-
Hey, thanks for the quick reply. I have progress. I was wrong, that's not the issue. I had read the exception wrongly, the clue was there all along java.lang.ClassNotFoundException: software.amazon.awssdk.services.s3.model.NoSuchKeyException I have given Tomcat the S3 NIO Jar as an external Jar. But then it needs the Jars that this library depends on. NoSuchKeyException is a class in the S3 core Jar. When I gave Tomcat that Jar as well, then it moved onto a new ClassNotFoundException - you guessed it, for another library. If I keep going I'm going to have to manually supply all the Jars to Tomcat, which breaks the point of Maven etc. So I'm back to the real problem - how to supply this library to Tomcat. There is a very similar issue discussed on one of the earlier projects producing a similar library. This is out of my area of expertise and I could really do with some help |
Beta Was this translation helpful? Give feedback.
-
Victory I was using the jar from my local maven repo. I needed to use the fat jar directly downloadable from here. Let me document this a bit for others. You need the full jar and it needs to go into the classpath of Tomcat/your web server. (I will have to cross the bridge on what that means for deployment) and then the next gotcha. We already use AWS code - we pull in the Maven AWS BOM. You will need to match up versions, you can find the right version in the file Version.java that's in the root of the fat jar. For the current version 2.0.5 that means using
PS there is a typo in your ReadMe (you've got aws.accessKey) many thanks |
Beta Was this translation helpful? Give feedback.
-
Hey, you are correct. We don't need the public constructor. |
Beta Was this translation helpful? Give feedback.
-
I've got a question about using the library within Tomcat. (Tomcat 9 on Corretto 17)
At first I used the library in a console app to get it working, very happy.
Then I've been through a couple of days of hitting the problems of trying to get the jar loaded within Tomcat. Finally I realised I need to supply the jar to Tomcat's classpath and that's now set up in my IDE's config. Great
The web app is up and then I try and use the Files API to read the following
Path.of(URI.create("s3://mybucket/file.xml"))
The FileSystemProvider code to register the provider is going bang with the following
[Handler dispatch failed; nested exception is java.util.ServiceConfigurationError: java.nio.file.spi.FileSystemProvider: software.amazon.nio.spi.s3.S3FileSystemProvider Unable to get public no-arg constructor] with root cause java.lang.ClassNotFoundException: software.amazon.awssdk.services.s3.model.NoSuchKeyException at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) at java.base/java.lang.Class.getDeclaredConstructors0(Native Method) at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3373) at java.base/java.lang.Class.getConstructor0(Class.java:3578) at java.base/java.lang.Class.getConstructor(Class.java:2271) at java.base/java.util.ServiceLoader$1.run(ServiceLoader.java:666) at java.base/java.util.ServiceLoader$1.run(ServiceLoader.java:663) at java.base/java.security.AccessController.doPrivileged(AccessController.java:569) at java.base/java.util.ServiceLoader.getConstructor(ServiceLoader.java:674) at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1240) at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1273) at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1309) at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1393) at java.base/java.nio.file.spi.FileSystemProvider.loadInstalledProviders(FileSystemProvider.java:156) at java.base/java.nio.file.spi.FileSystemProvider$1.run(FileSystemProvider.java:207) at java.base/java.nio.file.spi.FileSystemProvider$1.run(FileSystemProvider.java:204) at java.base/java.security.AccessController.doPrivileged(AccessController.java:318) at java.base/java.nio.file.spi.FileSystemProvider.installedProviders(FileSystemProvider.java:204) at java.base/java.nio.file.Path.of(Path.java:206)
Looking at the docs for FileSystemProvider it says that
But S3FileSystemProvider.java doesn't have a zero argument constructor. Am I doing something wrong? Should it have not reached that far?
I get the same issue whether I bring in the library using maven or not.
Beta Was this translation helpful? Give feedback.
All reactions