I have code to use SFTP for uploading file to a remote server. I am using Kotlin/Java and Apache commons library.
val manager = StandardFileSystemManager()
manager.init()
...
val tempFile: File = File ("/test.txt")
I am following the example here . However I get following error at manager.init()
call
java.lang.NullPointerException: Cannot invoke
"java.nio.file.attribute.BasicFileAttributes.lastModifiedTime()" because
"this.attrs" is null
Stacktrace
0 = {StackTraceElement@4220} "java.base/java.util.zip.ZipFile$Source$Key.hashCode(ZipFile.java:1235)"
1 = {StackTraceElement@4221} "java.base/java.util.HashMap.hash(HashMap.java:338)"
2 = {StackTraceElement@4222} "java.base/java.util.HashMap.getNode(HashMap.java:568)"
3 = {StackTraceElement@4223} "java.base/java.util.HashMap.get(HashMap.java:556)"
4 = {StackTraceElement@4224} "java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1271)"
5 = {StackTraceElement@4225} "java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:709)"
6 = {StackTraceElement@4226} "java.base/java.util.zip.ZipFile.<init>(ZipFile.java:243)"
7 = {StackTraceElement@4227} "java.base/java.util.zip.ZipFile.<init>(ZipFile.java:172)"
8 = {StackTraceElement@4228} "java.base/java.util.jar.JarFile.<init>(JarFile.java:347)"
9 = {StackTraceElement@4229} "java.base/sun.net.www.protocol.jar.URLJarFile.<init>(URLJarFile.java:103)"
10 = {StackTraceElement@4230} "java.base/sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:72)"
11 = {StackTraceElement@4231} "java.base/sun.net.www.protocol.jar.JarFileFactory.getOrCreate(JarFileFactory.java:106)"
12 = {StackTraceElement@4232} "java.base/sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:132)"
13 = {StackTraceElement@4233} "java.base/sun.net.www.protocol.jar.JarURLConnection.getInputStream(JarURLConnection.java:175)"
14 = {StackTraceElement@4234} "org.apache.commons.vfs2.util.CombinedResources.loadResources(CombinedResources.java:85)"
15 = {StackTraceElement@4235} "org.apache.commons.vfs2.util.CombinedResources.init(CombinedResources.java:48)"
16 = {StackTraceElement@4236} "org.apache.commons.vfs2.util.CombinedResources.handleGetObject(CombinedResources.java:123)"
17 = {StackTraceElement@4237} "java.base/java.util.ResourceBundle.getObject(ResourceBundle.java:555)"
18 = {StackTraceElement@4238} "java.base/java.util.ResourceBundle.getString(ResourceBundle.java:521)"
19 = {StackTraceElement@4239} "org.apache.commons.vfs2.util.Messages.findMessage(Messages.java:93)"
20 = {StackTraceElement@4240} "org.apache.commons.vfs2.util.Messages.getString(Messages.java:76)"
21 = {StackTraceElement@4241} "org.apache.commons.vfs2.util.Messages.getString(Messages.java:60)"
22 = {StackTraceElement@4242} "org.apache.commons.vfs2.impl.DefaultFileReplicator.init(DefaultFileReplicator.java:180)"
23 = {StackTraceElement@4243} "org.apache.commons.vfs2.impl.PrivilegedFileReplicator$InitAction.run(PrivilegedFileReplicator.java:127)"
24 = {StackTraceElement@4244} "java.base/java.security.AccessController.doPrivileged(AccessController.java:569)"
25 = {StackTraceElement@4245} "org.apache.commons.vfs2.impl.PrivilegedFileReplicator.init(PrivilegedFileReplicator.java:83)"
26 = {StackTraceElement@4246} "org.apache.commons.vfs2.impl.DefaultFileSystemManager.setupComponent(DefaultFileSystemManager.java:434)"
27 = {StackTraceElement@4247} "org.apache.commons.vfs2.impl.DefaultFileSystemManager.setReplicator(DefaultFileSystemManager.java:393)"
28 = {StackTraceElement@4248} "org.apache.commons.vfs2.impl.StandardFileSystemManager.init(StandardFileSystemManager.java:94)"
What could be the issue here? Is it due to Kotlin? What am I missing?
Thanks