9 Replies Latest reply on Dec 9, 2010 7:53 AM by Kevin Conner

    FTP Client and Static Route Example

    Marcus Achiume Newbie

      Hello,

       

      I'm trying to ftp some files off the machine running JBOSS 5.1 AS to a remote server. I first tried doing so using an FTP client built around Apache's FTPClient. This runs okay when I run it as a standalone class, but once I incorporate into the AS environment, the process hangs when connect is called on SocketClient.

       

      I then followed the Static Route example, and find that the FTP connection is done using the URL object. I would prefer to use the more functional FTPClient class within the ESB. Is there a limitation on the using more sophisticated FTP classes? Does anyone have an example of how I would go about simply connecting to an FTP server and porting over a list of files?

       

      Thanks.

        • 1. Re: FTP Client and Static Route Example
          Kevin Conner Master

          I assume you are talking about the CreateTestFile class, which simply seeds some files for the example.

           

          Within the ESB we use the apache FTP client to support ftp and ftps, with sftp being supported by JSch from jcraft.

           

          Kev

          • 2. Re: FTP Client and Static Route Example
            Marcus Achiume Newbie

            Thanks for the response Kevin. So, all I really want to do is have files that I generate ported over to an FTP server somewhere. The samples all show the reverse situation, and the one that comes close is the Static Route example. Where/how would I use the ESB to achieve this. Your guidance would be greatly appreciated.

             

            Thanks.

            • 3. Re: FTP Client and Static Route Example
              Tom Eicher Newbie

              Well, you should be able to use FTPEpr to define an ftp endpoint from the config, but I have never tries this.

               

              Since we had to go to different endpoints programmatically anyway, we did implement our own FTPRouter which does something like


              // clone and modify the AbstractActionPipelineProcessor's ConfigTree

              ConfigTree configTreeConfiguredForThisMessage = myConfigTree.cloneObj();
              configTreeConfiguredForThisMessage.setAttribute(RemoteFileSystem.PARMS_FTP_SERVER, sftpFtpServer);

              configTreeConfiguredForThisMessage.setAttribute(RemoteFileSystem.PARMS_PASSIVE, ftpPassive);

              ...

              // instantiate and use FTPImpl

              ftpImpl = new FtpImpl(configTreeConfiguredForThisMessage, true);

              ftpImpl.uploadFile(localFile, remoteFileName);

               

              Be sure to check the JIRA for some problems with FTPImpl, concerning ignored timeouts etc...

               

              Cheers, Tom.

              • 4. Re: FTP Client and Static Route Example
                Igor JStarter Novice

                Did u manage to do the trnsfer to another FTP ?

                • 5. Re: FTP Client and Static Route Example
                  Tom Eicher Newbie

                  ??? We did it implement like/with the code I pasted above... Works fine...

                  • 6. Re: FTP Client and Static Route Example
                    Igor JStarter Novice

                    Damn... i can't even run the sample...

                     

                    Deployment "vfszip:/D:/KKISSWORK/jboss-5.1.0.GA-jdk6/server/default/deploy/Quickstart_static_router.esb/" is in error due to the following reason(s): com.ctc.wstx.exc.WstxUnexpectedCharException: Illegal character ((CTRL-CHAR, code 12))
                    at [row,col {unknown-source}]: [11,27]

                     

                    How to solve this "illegal charachter" ?

                    Trying...

                    • 7. Re: FTP Client and Static Route Example
                      Kevin Conner Master

                      Sounds like the jboss-esb-template.xml or the filtered version has been corrupted, can you check them?

                      • 8. Re: FTP Client and Static Route Example
                        Igor JStarter Novice

                        I dont find the jboss-esb-template.xml.

                         

                        I found jboss-esb.xml in the static_router directory, and it could be this character in line directory="D: tptest" which makes the error(it is line 11).

                        In my pspad i have this file opened, and it looks like a square behind D: and before tptest.

                        But if I change this, it gets generated again when deployed. So, what rewrites the jboss-esb.xml ?  Isn't this the main ESB file? Why is it changed?

                         

                        What is more... I don't understand the database binding when doing FTP. Why would I need it? I have only a mysql database for Riftsaw...

                         

                        <providers>
                                  <ftp-provider name="FTPprovider" hostname="localhost" >
                                      <ftp-bus busid="StaticRouterFtpGW" >
                                          <ftp-message-filter
                                              username="esb"
                                              password="esb"
                                              passive="false"
                                              directory="D: tptest"
                                              input-suffix=".dat"
                                          />
                                      </ftp-bus>
                                  </ftp-provider>

                         

                                  <fs-provider name="LocalFsProvider">
                                      <fs-bus busid="staticRouter" >
                                          <fs-message-filter
                                              directory="D:\KKISSWORK\jbossesb-4.8\samples\quickstarts\static_router\build\dirs\staticrouter"
                                              input-suffix=".esbMessage"
                                          />
                                      </fs-bus>
                                      <fs-bus busid="fileMessageDestination_01" >
                                          <fs-message-filter
                                              directory="D:\KKISSWORK\jbossesb-4.8\samples\quickstarts\static_router\build\dirs\service01\input"
                                              input-suffix=".toRoute01"
                                              post-delete="false"
                                              post-directory="D:\KKISSWORK\jbossesb-4.8\samples\quickstarts\static_router\build\dirs\service01\post"
                                          />

                        ...

                        • 9. Re: FTP Client and Static Route Example
                          Kevin Conner Master

                          Sorry, file is called jboss-esb-unfiltered.xml.

                           

                          Looks like the path is not being set correctly on windows, please change it to /D:/KKISSWORK/jbossesb-4.8/ ...., replacing \ with /