8 Replies Latest reply on Dec 28, 2008 2:43 PM by mimra

    Is it possible to upload  (put) a file to directory on a sft

    kaba

      I would like to upload a file to an sftp directory.
      I know how to download file from an sftp directory using the sftp-Gateway.
      But i would like to use the same ways to copy file from one sftp share to another using JBOSSESB

      Thank you

        • 1. Re: Is it possible to upload  (put) a file to directory on a
          kaba

          Would some JbossESB specialist help me with this probleme.
          i want to copy a file from one Server to another through JBOSSESB using the sftp protocol
          How should i configer a sftp-gateway for upload?
          Thank you

          • 2. Re: Is it possible to upload  (put) a file to directory on a
            mimra

            You use the ftp-provider to bring files from an FTP server in to the ESB. You can use the Notifier action to upload a file to an FTP server. The following is an example from the quickstart 'smooks_file_splitter_router':

            <action name="notificationAction" class="org.jboss.soa.esb.actions.Notifier">
             <property name="okMethod" value="notifyOK" />
             <property name="notification-details">
             <NotificationList type="ok">
             <target class="NotifyFTPList">
             <ftp URL="ftp://@FTP_USERNAME@:@FTP_PASSWORD@@@FTP_HOSTNAME@/@FTP_DIRECTORY@"
             filename="{org.jboss.soa.esb.gateway.file}"
             listFiles="true"
             deleteListFile="true"/>
             </target>
             </NotificationList>
             </property>
            </action>
            


            I do think the NotifyFTP action also supports SFTP, but I'm not certain. Give it a try though.

            /Michael

            • 3. Re: Is it possible to upload  (put) a file to directory on a
              kaba

              This doesnt seem to work i get the following exception

              09:36:06,861 INFO [NotifyFTPList] Sending file [/tmp/order-332.lst]
              09:36:07,031 ERROR [NotificationList] Can't instantiate target target class="NotifyFTPList">
              <ftp URL="sftp://user:passwd@ftpserver:22//localdata/in_work" deleteListFile="false" filename="{org.jboss.soa.esb.gateway.file}" listFiles="false"/
              </target
              org.jboss.soa.esb.notification.NotificationException: Could not complete FTP notification
              at org.jboss.soa.esb.notification.NotifyFTP.sendNotification(NotifyFTP.java:162)
              at org.jboss.soa.esb.notification.NotifyFTPList.send(NotifyFTPList.java:184)
              at org.jboss.soa.esb.notification.NotifyFTPList.sendFile(NotifyFTPList.java:132)
              at org.jboss.soa.esb.notification.NotifyFTPList.send(NotifyFTPList.java:124)
              at org.jboss.soa.esb.notification.NotifyFTPList.sendNotification(NotifyFTPList.java:105)
              at org.jboss.soa.esb.notification.NotificationList.notifyAll(NotificationList.java:164)
              at org.jboss.soa.esb.actions.Notifier.notifyOK(Notifier.java:93)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.jboss.soa.esb.listeners.message.ActionProcessorMethodInfo.processSuccess(ActionProcessorMethodInfo.java:165)
              at org.jboss.soa.esb.listeners.message.OverriddenActionLifecycleProcessor.processSuccess(OverriddenActionLifecycleProcessor.java:108)
              at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.notifySuccess(ActionProcessingPipeline.java:610)
              at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.process(ActionProcessingPipeline.java:384)
              at org.jboss.soa.esb.listeners.message.MessageAwareListener$TransactionalRunner.run(MessageAwareListener.java:530)
              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.jboss.soa.esb.util.RemoteFileSystemException: 2: The system cannot find the file specified.
              at org.jboss.internal.soa.esb.util.SecureFtpImpl.uploadFile(SecureFtpImpl.java:542)
              at org.jboss.soa.esb.notification.NotifyFTP.sendNotification(NotifyFTP.java:160)
              ... 18 more
              Caused by: 2: The system cannot find the file specified.
              at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2291)
              at com.jcraft.jsch.ChannelSftp._realpath(ChannelSftp.java:1824)
              at com.jcraft.jsch.ChannelSftp.cd(ChannelSftp.java:263)
              at org.jboss.internal.soa.esb.util.SecureFtpImpl.uploadFile(SecureFtpImpl.java:512)
              ... 19 more



              • 4. Re: Is it possible to upload  (put) a file to directory on a
                mimra

                The exception seems to be thrown when changing to the remote directory on the FTP server. Have you verified that the the folder exists and the the users has access to it?

                /Michael

                • 5. Re: Is it possible to upload  (put) a file to directory on a
                  kaba

                  i am sure that the user has access to the directory specified. i am using the same user to download file from this directory to the local drive. i can also upload file to this directory using the plain old unix shell command sftp user@server

                  • 6. Re: Is it possible to upload  (put) a file to directory on a
                    mimra

                    Kaba,

                    Could you try the following to make things a bit more simple. There are two FTPNotifiers: NotifyFTP and NotifyFTPList. The last one is a bit more complex. I have tested the following (although without sftp). Could you try that:

                     <action name="notificationAction" class="org.jboss.soa.esb.actions.Notifier">
                     <property name="okMethod" value="notifyOK" />
                     <property name="notification-details">
                     <NotificationList type="ok">
                     <target class="NotifyFTP">
                     <ftp URL="ftp://user:password@ftp.server.com/uploads/sandbox/"
                     filename="sandbox-file.txt"/>
                     </target>
                     </NotificationList>
                     </property>
                     </action>
                    


                    I set the file content in an action:

                    public Message process(Message message) throws ActionProcessingException {
                     String filePayload = "Hello World";
                     message.getBody().add(filePayload);
                     return message;
                    }
                    


                    This works with plan ftp - could you try this with the sftp protocol?

                    /Michael

                    • 7. Re: Is it possible to upload  (put) a file to directory on a
                      kaba

                      thank you Michael,

                      i have found my mistake by carefully looking at the following line in the exception stacktrace.


                      <ftp URL="sftp://user:passwd@ftpserver:22//localdata/in_work" deleteListFile="false" filename="{org.jboss.soa.esb.gateway.file}" listFiles="false"
                      /

                      do you see the :// after the port number 22
                      my directory was set to /localdata/in-arbeit and the format of the ftp was
                      sftp://@user@:@password@@ftpserver@:sftp://user:passwd@ftpserver@:/@directory@

                      if the directory starts with / so you get <ftp URL="sftp://user:passwd@ftpserver:22//localdata/in_work which of course cannot be found.
                      thank you for your help i would have given it up if you had not tell me that it should work and you have successfully test it.
                      now i can say it works also with sftp. i have tested it it works.
                      but one should be careful not to start the ftp-directory with / and mainain the format of the ftp-notify action parameter sftp://@user@:@password@@ftpserver@:sftp://user:passwd@ftpserver@:/@directory@ otherwise you will run into the same problem as i do
                      thank again for your help

                      batemady

                      • 8. Re: Is it possible to upload  (put) a file to directory on a
                        mimra

                        Kaba,

                        You're welcome - glad you got it working.

                        /Michael