• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

FTP file transfer not working from Application Server(WAS)  RSS feed

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

The Ftp file transfer is not working in WAS application server but when i ran as a stand alone Java application it works fine.

The FTP connection gets established but the file not getting uploaded and not even throwing error. Even the file permission is set to RW.

below is the code

import java.io.File;

import com.jscape.inet.ftp.Ftp;
import com.jscape.inet.ftp.FtpException;

public class FTPUploadFileDemo {
public static void main(String[] args) throws Exception {
Ftp ftpClient = getFtpClient("XXXX", "XXX", "XX", "21");
copyFile(ftpClient, "File path in your local", "devdata/reports");
ftpClient.issueCommand(new StringBuilder().append("put ").append("any file from your local").append(" ")

private static Ftp getFtpClient(final String ftpServerName, final String ftpUserName, final String ftpPassword,
final String ftpPort) throws FtpException {
final Ftp ftp = new Ftp(ftpServerName, ftpUserName, ftpPassword);
System.out.println("Port value set..");
System.out.println("Timeout set..");
return ftp;

private static void copyFile(final Ftp ftp, final String localPath, final String remotePath) throws FtpException {
System.out.println("Copy File started");
try {
File newFile = null;
newFile = new File(localPath);
System.out.println("Local file ----- " + newFile.getPath());
System.out.println("Remote  file ----- " + remotePath);
ftp.upload(newFile, "Test_File.txt");
System.out.println("Upload Complete-----" + newFile.getPath());
} catch (Exception e) {


[3/27/18 10:10:50:660 EDT] 0000002e GpirsFtpUtilH I   Remote  file ----- devdata/reports
[3/27/18 10:10:50:661 EDT] 0000002e SystemOut     O PASV
[3/27/18 10:10:50:664 EDT] 0000002e SystemOut     O 227 Entering Passive Mode (19,110,198,20,178,31)
[3/27/18 10:10:50:676 EDT] 0000002e SystemOut     O QUIT
[3/27/18 10:10:50:678 EDT] 0000002e SystemOut     O 221 Goodbye.

Saloon Keeper
Posts: 5132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I notice that the output of your System.out.println is not shown. Maybe start with looking into why that is, so that you get better diagnostics.

Wait - you said the standalone code you posted does work, but not when you're using similar code running on an app server? What code is running there?
Posts: 20124
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have no idea why this is posted in the JSF forum. But JSF doesn't know/care/interfere with FTP.

It's unclear whether or not the ultimate sources for the filepaths in the example are absolute or relative. If they're relative, they should be made absolute, since there's no such thing as a "current" or "working" directory in a web application. So it would be unpredictable where the files being transferred were expected to be.

Actually, the webapp environment doesn't support stdio, either, so there's no absolutely gurantee where/if System.out.println statements would write. The preferred approach is to use a logger.

Finally, any files read or written by a web application must have access rights for the userid that the web application server runs under. There are no separate userids for web applications.
All of life is a contant education - Eleanor Roosevelt. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!