Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
servicemix-vfs-2009.01, servicemix-vfs-2009.02, servicemix-vfs-2010.01
-
None
-
apache-servicemix-4.2.0-fuse-02-00
Win7 64
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
Java HotSpot(TM) 64-Bit Server VM (build 17.0-b16, mixed mode)
Description
servicemix-vfs fails with NullPointerException when sending.
servicemix.log
23:33:02,649 | ERROR | ix-vfs-thread-53 | VFSComponent | icemix.common.AsyncBaseLifeCycle 470 | Error processing exchange org.apache.servicemix.jbi.runtime.impl.InOnlyImpl@6687ec13 java.lang.NullPointerException at org.apache.servicemix.vfs.VFSSendingEndpoint.processInOnly(VFSSendingEndpoint.java:114) at org.apache.servicemix.common.endpoints.ProviderEndpoint.process(ProviderEndpoint.java:102) at org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:617) at org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:571) at org.apache.servicemix.common.AsyncBaseLifeCycle.processExchangeInTx(AsyncBaseLifeCycle.java:468) at org.apache.servicemix.common.AsyncBaseLifeCycle$2.run(AsyncBaseLifeCycle.java:347) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619)
To avoid this exception it would be better to check for null value tmpName variable
org.apache.servicemix.vfs.VFSSendingEndpoint.java
if (name != null && tmpName != null && !name.equals(tmpName)) { if (!tmpFile.canRenameTo(newFile)) { throw new IOException("File " + tmpName + " could not be renamed to " + name); } else { tmpFile.moveTo(newFile); } }
As discussed here http://servicemix.396122.n5.nabble.com/Exception-when-using-vsf-poller-with-sftp-ServiceMix-4-2-td417225.html#a417225
it would be nice to add root exception information along with IOException.
org.apache.servicemix.vfs.FileObjectResolver.java
catch (FileSystemException e) { throw new IOException("Failed to create folder: " + e, e); } } catch (FileSystemException e) { throw new IOException("Failed to initialize file system manager: " + e, e); }
Otherwise it is hard to track exceptions like this:
java.io.IOException: Failed to initialize file system manager: org.apache.commons.vfs.FileSystemException: Could not connect to SFTP server at "sftp://sab:sab@192.168.1.158/". at org.apache.servicemix.vfs.FileObjectResolver.resolveToFileObject(FileObjectResolver.java:74) at org.apache.servicemix.vfs.VFSPollingEndpoint.poll(VFSPollingEndpoint.java:229) at org.apache.servicemix.common.endpoints.PollingEndpoint$PollSchedulerTask$1.run(PollingEndpoint.java:202) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) Caused by: org.apache.commons.vfs.FileSystemException: Could not connect to SFTP server at "sftp://sab:sab@192.168.1.158/". at org.apache.commons.vfs.provider.sftp.SftpFileProvider.doCreateFileSystem(SftpFileProvider.java:99) at org.apache.commons.vfs.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:81) at org.apache.commons.vfs.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:62) at org.apache.commons.vfs.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:641) at org.apache.commons.vfs.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:602) at org.apache.commons.vfs.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:570) at org.apache.servicemix.vfs.FileObjectResolver.resolveToFileObject(FileObjectResolver.java:55) ... 5 more Caused by: org.apache.commons.vfs.FileSystemException: Could not connect to SFTP server at "192.168.1.158". at org.apache.commons.vfs.provider.sftp.SftpClientFactory.createConnection(SftpClientFactory.java:214) at org.apache.commons.vfs.provider.sftp.SftpFileProvider.doCreateFileSystem(SftpFileProvider.java:90) ... 11 more Caused by: com.jcraft.jsch.JSchException: UnknownHostKey: 192.168.1.158. RSA key fingerprint is 59:8f:eb:89:ef:ce:b2:8f:4d:ed:79:90:d1:1e:52:b4 at com.jcraft.jsch.Session.checkHost(Session.java:712) at com.jcraft.jsch.Session.connect(Session.java:309) at com.jcraft.jsch.Session.connect(Session.java:145) at org.apache.commons.vfs.provider.sftp.SftpClientFactory.createConnection(SftpClientFactory.java:210)
java.io.IOException: Failed to initialize file system manager: org.apache.commons.vfs.FileSystemException: Could not connect to SFTP server at "sftp://sab:sab@192.168.1.159/". at org.apache.servicemix.vfs.FileObjectResolver.resolveToFileObject(FileObjectResolver.java:74) at org.apache.servicemix.vfs.VFSPollingEndpoint.poll(VFSPollingEndpoint.java:229) at org.apache.servicemix.common.endpoints.PollingEndpoint$PollSchedulerTask$1.run(PollingEndpoint.java:202) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) Caused by: org.apache.commons.vfs.FileSystemException: Could not connect to SFTP server at "sftp://sab:sab@192.168.1.159/". at org.apache.commons.vfs.provider.sftp.SftpFileProvider.doCreateFileSystem(SftpFileProvider.java:99) at org.apache.commons.vfs.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:81) at org.apache.commons.vfs.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:62) at org.apache.commons.vfs.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:641) at org.apache.commons.vfs.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:602) at org.apache.commons.vfs.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:570) at org.apache.servicemix.vfs.FileObjectResolver.resolveToFileObject(FileObjectResolver.java:55) ... 5 more Caused by: org.apache.commons.vfs.FileSystemException: Could not connect to SFTP server at "192.168.1.159". at org.apache.commons.vfs.provider.sftp.SftpClientFactory.createConnection(SftpClientFactory.java:214) at org.apache.commons.vfs.provider.sftp.SftpFileProvider.doCreateFileSystem(SftpFileProvider.java:90) ... 11 more Caused by: com.jcraft.jsch.JSchException: java.net.ConnectException: Connection timed out: connect at com.jcraft.jsch.Util.createSocket(Util.java:258) at com.jcraft.jsch.Session.connect(Session.java:186) at com.jcraft.jsch.Session.connect(Session.java:145) at org.apache.commons.vfs.provider.sftp.SftpClientFactory.createConnection(SftpClientFactory.java:210) ... 12 more Caused by: java.net.ConnectException: Connection timed out: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at java.net.Socket.connect(Socket.java:529) at java.net.Socket.connect(Socket.java:478) at java.net.Socket.<init>(Socket.java:375) at java.net.Socket.<init>(Socket.java:189) at com.jcraft.jsch.Util.createSocket(Util.java:252) ... 15 more