ApacheCommonsFTPClientを使用してFTP経由でWindowsサーバーからファイルを取得するJavaアプリケーションがWebsphereにあります。Windows環境で実行されているWebsphereにアプリケーションをデプロイすると、すべてのファイルをクリーンに取得できます。ただし、同じアプリケーションをLinux上のWebpshereにデプロイすると、ファイルが不完全または破損する場合があります。ただし、これらのケースは一貫しており、同じファイルが毎回失敗し、同じバイト数(通常は取得するはずのバイト数よりもわずか数バイト少ない)を返します。Linuxではファイルの約95%を正常に読み取ることができると言えます。
関連するコードは次のとおりです...
ftpc = new FTPClient();
// set the timeout to 30 seconds
ftpc.enterLocalPassiveMode();
ftpc.setDefaultTimeout(30000);
ftpc.setDataTimeout(30000);
try
{
String ftpServer = CoreApplication.getProperty("ftp.server");
String ftpUserID = CoreApplication.getProperty("ftp.userid");
String ftpPassword = CoreApplication.getProperty("ftp.password");
log.debug("attempting to connect to ftp server = "+ftpServer);
log.debug("credentials = "+ftpUserID+"/"+ftpPassword);
ftpc.connect(ftpServer);
boolean login = ftpc.login(ftpUserID, ftpPassword);
if (login)
{
log.debug("Login success..."); }
else
{
log.error("Login failed - connecting to FTP server = "+ftpServer+", with credentials "+ftpUserID+"/"+ftpPassword);
throw new Exception("Login failed - connecting to FTP server = "+ftpServer+", with credentials "+ftpUserID+"/"+ftpPassword);
}
is = ftpc.retrieveFileStream(fileName);
ByteArrayOutputStream out = null;
try {
out = new ByteArrayOutputStream();
IOUtils.copy(is, out);
} finally {
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(out);
}
byte[] bytes = out.toByteArray();
log.info("got bytes from input stream - byte[] size is "+ bytes.length);
これに関する支援をいただければ幸いです。
ありがとう。