Claus, In the ChannelSftp class (package com.jcraft.jsch) the following constants are defined:
public static final int SSH_FX_OK= 0; public static final int SSH_FX_EOF= 1; public static final int SSH_FX_NO_SUCH_FILE= 2; public static final int SSH_FX_PERMISSION_DENIED= 3; public static final int SSH_FX_FAILURE= 4; public static final int SSH_FX_BAD_MESSAGE= 5; public static final int SSH_FX_NO_CONNECTION= 6; public static final int SSH_FX_CONNECTION_LOST= 7; public static final int SSH_FX_OP_UNSUPPORTED= 8; I think it might be a good idea if we check whether the id in the SftpException is SSH_FX_NO_SUCH_FILE and then accepts this as meaning that the directory does not exist. In the method existsFile() in class SftpOperations, you would then simply return false (meaning that the file/directory doesn't exist). /Bengt 2010/6/15 Bengt Rodehav <[email protected]> > I'll make some research, > > /Bengt > > 2010/6/15 Claus Ibsen <[email protected]> > > Hi >> >> Ah it could be jsch weird way of saying there is no files. There is >> this exception message with code 2 No such file. >> I bet they have a list of error codes. So we can interpret the >> exception and see that 2 = no files. >> >> Could you take a look at their web site to see if you can find such a >> list or something. Then we can fix this in the camel-ftp code. >> >> >> On Tue, Jun 15, 2010 at 3:05 PM, Bengt Rodehav <[email protected]> wrote: >> > I'm using camel-ftp with the sftp protocol. I'm basically using the >> > following route: >> > >> > from("file:data/sample/file2sftp").to("sftp://u...@localhost >> > /sample/file2sftp?password=password"); >> > >> > If the remote directory (sample/file2sftp) doesn't exist then it's >> supposed >> > to be created. However, I get an exception when camel is trying to find >> out >> > if the directory exists which causes the whole operation to fail. >> > >> > 2: No such file. >> > at >> > com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2289) >> > at com.jcraft.jsch.ChannelSftp._stat(ChannelSftp.java:1741) >> > at com.jcraft.jsch.ChannelSftp._stat(ChannelSftp.java:1758) >> > at com.jcraft.jsch.ChannelSftp.ls(ChannelSftp.java:1196) >> > at >> > >> org.apache.camel.component.file.remote.SftpOperations.existsFile(SftpOperations.java:463) >> > at >> > >> org.apache.camel.component.file.GenericFileProducer.processExchange(GenericFileProducer.java:92) >> > at >> > >> org.apache.camel.component.file.remote.RemoteFileProducer.process(RemoteFileProducer.java:49) >> > at >> > >> org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:91) >> > at >> > >> org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:88) >> > at >> > org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:206) >> > at >> > >> org.apache.camel.processor.SendProcessor.doProcess(SendProcessor.java:88) >> > at >> > org.apache.camel.processor.SendProcessor.process(SendProcessor.java:72) >> > at >> > >> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67) >> > at >> > >> org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53) >> > at >> > >> org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82) >> > at >> > >> org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:97) >> > at >> > >> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67) >> > at >> > >> org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:185) >> > at >> > >> org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:151) >> > at >> > >> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:89) >> > at >> > >> org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49) >> > at >> > >> org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:228) >> > at >> > >> org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:70) >> > at >> > >> org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48) >> > at >> > >> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67) >> > at >> > >> org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:269) >> > at >> > >> org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:137) >> > at >> > >> org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:103) >> > at >> > >> org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:98) >> > at >> > java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) >> > at >> > >> java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317) >> > at >> java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150) >> > at >> > >> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98) >> > at >> > >> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181) >> > at >> > >> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205) >> > 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) >> > >> > Note that I've added a few logging messages in SftpOperations.java. The >> line >> > number 463 above is really line 460: >> > >> > Vector files = channel.ls(directory); >> > >> > Thus it seems like the ChannelSftp class in jsch throws an exception >> instead >> > of just returning an empty Vector. The exception is thrown in the >> _stat() >> > method that reacts to not getting a return of type SSH_FXP_ATTRS but >> > of SSH_FXP_STATUS. >> > >> > Note that I have only tested this on Serv-U (Version 10.0.0.7). I use >> the >> > latest Camel version from trunk. Below is an excerpt of Serv-U's log >> file >> > from the failed file transfer: >> > >> > [02] Tue 15Jun10 14:11:43 - (000002) Connected to 127.0.0.1 (local >> address >> > 127.0.0.1, port 22) >> > [03] Tue 15Jun10 14:11:43 - (000002) IP-Name: localhost (127.0.0.1) >> > [30] Tue 15Jun10 14:11:43 - (000002) SSH2_MSG_USERAUTH_REQUEST: user: >> user; >> > service: ssh-connection; type: none >> > [31] Tue 15Jun10 14:11:43 - (000002) SSH2_MSG_USERAUTH_FAILURE: login >> failed >> > [30] Tue 15Jun10 14:11:43 - (000002) SSH2_MSG_USERAUTH_REQUEST: user: >> user; >> > service: ssh-connection; type: password >> > [02] Tue 15Jun10 14:11:43 - (000002) User "user" logged in >> > [31] Tue 15Jun10 14:11:43 - (000002) SSH2_MSG_USERAUTH_SUCCESS: >> successful >> > login >> > [30] Tue 15Jun10 14:11:43 - (000002) SSH_FXP_INIT: client version 3 >> > (JSCH-0.1.42) >> > [31] Tue 15Jun10 14:11:43 - (000002) SSH_FXP_VERSION: server version 3 >> > [30] Tue 15Jun10 14:11:43 - (000002) {0x00000001} SSH_FXP_REALPATH: >> path: >> > "~" >> > [31] Tue 15Jun10 14:11:43 - (000002) {0x00000001} SSH_FXP_NAME: path: >> "/" >> > [30] Tue 15Jun10 14:11:43 - (000002) {0x00000002} SSH_FXP_STAT: path: >> > "/sample/file2sftp" >> > [31] Tue 15Jun10 14:11:43 - (000002) {0x00000002} SSH_FX_NO_SUCH_FILE: >> No >> > such file. >> > [02] Tue 15Jun10 14:11:43 - (000002) Closed session >> > [02] Tue 15Jun10 14:11:43 - (000002) User "user" logged out >> > >> > Anyone had problems like this before? Is it just Serv-U that is >> problematic? >> > >> > /Bengt >> > >> >> >> >> -- >> Claus Ibsen >> Apache Camel Committer >> >> Author of Camel in Action: http://www.manning.com/ibsen/ >> Open Source Integration: http://fusesource.com >> Blog: http://davsclaus.blogspot.com/ >> Twitter: http://twitter.com/davsclaus >> > >
