Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
5.2k views
in Java FTP by (340 points)
Hi ,
I am getting a StringIndexOutOfBoundsException while trying to upload a file onto a server.

Please find below the logs of the same. The line of code that throws the error is as follows


ftp.put(fileBase2.localCopy.getAbsolutePath(), s);


2009/08/12 02:47:47:385] ERROR -->> FTPSender -> FAILED to distribute file to FTP server java.lang.StringIndexOutOfBoundsException: String index out of range: -50 at java.lang.String.substring(String.java:1444) at com.enterprisedt.net.ftp.FTPControlSocket.getPASVParts(FTPControlSocket.java:838) at com.enterprisedt.net.ftp.FTPControlSocket.createDataSocketPASV(FTPControlSocket.java:775) at com.enterprisedt.net.ftp.FTPControlSocket.createDataSocket(FTPControlSocket.java:547) at com.enterprisedt.net.ftp.FTPClient.setupDataSocket(FTPClient.java:2452) at com.enterprisedt.net.ftp.FTPClient.initPut(FTPClient.java:2503) at com.enterprisedt.net.ftp.FTPClient.putData(FTPClient.java:2576) at com.enterprisedt.net.ftp.FTPClient.putStream(FTPClient.java:2309) at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:2194).

After sometime if i rettry the same file , it goes through successfully.

Also this behaviour is sporadic, i face this problem say once in 10-15 files .

Can someone please help me out on this.

4 Answers

0 votes
by (162k points)
Hi please post the log file at DEBUG level that shows where this goes wrong.
0 votes
by (340 points)
[2009/08/25 04:51:36:982] FTP Reply : 200 NOOP command successful.[2009/08/25 04:52:37:058] FTP Command : ---> NOOP[2009/08/25 04:52:37:058] FTP Reply : 200 NOOP command successful.[2009/08/25 04:53:37:135] FTP Command : ---> NOOP[2009/08/25 04:53:37:135] FTP Reply : 200 NOOP command successful.[2009/08/25 04:54:37:212] FTP Command : ---> NOOP[2009/08/25 04:54:37:212] FTP Reply : 200 NOOP command successful.[2009/08/25 04:55:37:289] FTP Command : ---> NOOP[2009/08/25 04:55:37:289] FTP Reply : 200 NOOP command successful.[2009/08/25 04:56:37:366] FTP Command : ---> NOOP[2009/08/25 04:56:37:366] FTP Reply : 200 NOOP command successful.[2009/08/25 04:56:41:871] FTP Command : ---> PWD[2009/08/25 04:56:41:871] FTP Reply : 200 NOOP command successful.[2009/08/25 04:56:41:871] FTP Command : ---> PWD[2009/08/25 04:56:41:949] FTP Reply : 257 "/" is current directory.[2009/08/25 04:56:41:949] FTP Command : ---> CWD /IPB_IN/GCOM_Collection/CRC/[2009/08/25 04:56:42:023] FTP Reply : 257 "/" is current directory.[2009/08/25 04:56:42:023] FTP Command : ---> PWD[2009/08/25 04:56:42:121] FTP Reply : 250 CWD command successful.[2009/08/25 04:56:42:128] FTP Command : ---> PASV[2009/08/25 04:56:42:192] FTP Reply : 257 "/IPB_IN/GCOM_Collection/CRC" is current directory.[2009/08/25 04:56:42:193] FTPSender -> End FTP Trace Messages -- [2009/08/25 04:56:42:193] ERROR -->> FTPSender -> FAILED to distribute file to FTP server java.lang.StringIndexOutOfBoundsException: String index out of range: -50 at java.lang.String.substring(String.java:1444) at com.enterprisedt.net.ftp.FTPControlSocket.getPASVParts(FTPControlSocket.java:838) at com.enterprisedt.net.ftp.FTPControlSocket.createDataSocketPASV(FTPControlSocket.java:775) at com.enterprisedt.net.ftp.FTPControlSocket.createDataSocket(FTPControlSocket.java:547) at com.enterprisedt.net.ftp.FTPClient.setupDataSocket(FTPClient.java:2452) at com.enterprisedt.net.ftp.FTPClient.initPut(FTPClient.java:2503) at com.enterprisedt.net.ftp.FTPClient.putData(FTPClient.java:2576) at com.enterprisedt.net.ftp.FTPClient.putStream(FTPClient.java:2309) at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:2194) at com.ml.gpb.distfrmw.connector.DFFTPClient.put(DFFTPClient.java:308) at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:2280) at com.ml.gpb.distfrmw.connector.DFFTPClient.put(DFFTPClient.java:369) at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:2245) at com.ml.gpb.distfrmw.connector.DFFTPClient.put(DFFTPClient.java:338) at com.ml.gpb.distfrmw.sender.FTPSender.send(FTPSender.java:268) at com.ml.gpb.distfrmw.sender.Sender.sendObject(Sender.java:276) at com.ml.gpb.distfrmw.core.DistributionTask.processDistribution(DistributionTask.java:255) at com.ml.gpb.distfrmw.core.DistributionTask.call(DistributionTask.java:66) at edu.emory.mathcs.backport.java.util.concurrent.FutureTask.run(FutureTask.java:178) at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061) at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575) at java.lang.Thread.run(Thread.java:534)[2009/08/25 04:56:42:266] ERROR -->> Sender -> ERROR -->> Cannot send filejava.lang.StringIndexOutOfBoundsException: String index out of range: -50 at java.lang.String.substring(String.java:1444) at com.enterprisedt.net.ftp.FTPControlSocket.getPASVParts(FTPControlSocket.java:838) at com.enterprisedt.net.ftp.FTPControlSocket.createDataSocketPASV(FTPControlSocket.java:775) at com.enterprisedt.net.ftp.FTPControlSocket.createDataSocket(FTPControlSocket.java:547) at com.enterprisedt.net.ftp.FTPClient.setupDataSocket(FTPClient.java:2452) at com.enterprisedt.net.ftp.FTPClient.initPut(FTPClient.java:2503) at com.enterprisedt.net.ftp.FTPClient.putData(FTPClient.java:2576) at com.enterprisedt.net.ftp.FTPClient.putStream(FTPClient.java:2309) at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:2194) at com.ml.gpb.distfrmw.connector.DFFTPClient.put(DFFTPClient.java:308) at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:2280) at com.ml.gpb.distfrmw.connector.DFFTPClient.put(DFFTPClient.java:369) at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:2245) at com.ml.gpb.distfrmw.connector.DFFTPClient.put(DFFTPClient.java:338) at com.ml.gpb.distfrmw.sender.FTPSender.send(FTPSender.java:268) at com.ml.gpb.distfrmw.sender.Sender.sendObject(Sender.java:276) at com.ml.gpb.distfrmw.core.DistributionTask.processDistribution(DistributionTask.java:255) at com.ml.gpb.distfrmw.core.DistributionTask.call(DistributionTask.java:66) at edu.emory.mathcs.backport.java.util.concurrent.FutureTask.run(FutureTask.java:178) at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061) at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575) at java.lang.Thread.run(Thread.java:534)
0 votes
by (162k points)
You are sending NOOP and PWD commands.

The replies from these are getting mixed up with the expected reply to the PASV command, i.e. server responses are out of sequence.

Are you calling these from a different thread? You need to rethink what you are doing here ...
0 votes
by (340 points)
sorry for the confusing log.

Please find the entire log trace below for another file

[2009/08/25 00:00:38:235] File Status was set to UNDER DISTRIBUTION
[2009/08/25 00:00:38:533] FTPSender -> Start FTP Trace Messages --
[2009/08/24 23:54:13:772] FTP Command : ---> NOOP
[2009/08/24 23:54:13:772] FTP Reply : 227 Entering Passive Mode (169,243,160,1,4,96).
[2009/08/24 23:55:13:852] FTP Command : ---> NOOP
[2009/08/24 23:55:13:852] FTP Reply : 200 NOOP command successful.
[2009/08/24 23:56:13:927] FTP Command : ---> NOOP
[2009/08/24 23:56:13:927] FTP Reply : 200 NOOP command successful.
[2009/08/24 23:57:14:004] FTP Command : ---> NOOP
[2009/08/24 23:57:14:004] FTP Reply : 200 NOOP command successful.
[2009/08/24 23:58:14:080] FTP Command : ---> NOOP
[2009/08/24 23:58:14:080] FTP Reply : 200 NOOP command successful.
[2009/08/24 23:59:14:156] FTP Command : ---> NOOP
[2009/08/24 23:59:14:156] FTP Reply : 200 NOOP command successful.
[2009/08/25 00:00:14:232] FTP Command : ---> NOOP
[2009/08/25 00:00:14:232] FTP Reply : 200 NOOP command successful.
[2009/08/25 00:00:38:236] FTP Command : ---> PWD
[2009/08/25 00:00:38:236] FTP Reply : 200 NOOP command successful.
[2009/08/25 00:00:38:237] FTP Command : ---> PWD
[2009/08/25 00:00:38:307] FTP Reply : 257 "/IPB_IN/GCOM_Collection/CRC" is current directory.
[2009/08/25 00:00:38:308] FTP Command : ---> CWD /IPB_IN/GCOM_Collection/CRC/
[2009/08/25 00:00:38:378] FTP Reply : 257 "/IPB_IN/GCOM_Collection/CRC" is current directory.
[2009/08/25 00:00:38:378] FTP Command : ---> PWD
[2009/08/25 00:00:38:462] FTP Reply : 250 CWD command successful.
[2009/08/25 00:00:38:464] FTP Command : ---> PASV
[2009/08/25 00:00:38:533] FTP Reply : 257 "/IPB_IN/GCOM_Collection/CRC" is current directory.

[2009/08/25 00:00:38:533] FTPSender -> End FTP Trace Messages --
[2009/08/25 00:00:38:533] ERROR -->> FTPSender -> FAILED to distribute file to FTP server
java.lang.StringIndexOutOfBoundsException: String index out of range: -50
at java.lang.String.substring(String.java:1444)
at com.enterprisedt.net.ftp.FTPControlSocket.getPASVParts(FTPControlSocket.java:838)
at com.enterprisedt.net.ftp.FTPControlSocket.createDataSocketPASV(FTPControlSocket.java:775)
at com.enterprisedt.net.ftp.FTPControlSocket.createDataSocket(FTPControlSocket.java:547)
at com.enterprisedt.net.ftp.FTPClient.setupDataSocket(FTPClient.java:2452)
at com.enterprisedt.net.ftp.FTPClient.initPut(FTPClient.java:2503)
at com.enterprisedt.net.ftp.FTPClient.putData(FTPClient.java:2576)
at com.enterprisedt.net.ftp.FTPClient.putStream(FTPClient.java:2309)
at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:2194)
at com.ml.gpb.distfrmw.connector.DFFTPClient.put(DFFTPClient.java:308)
at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:2280)
at com.ml.gpb.distfrmw.connector.DFFTPClient.put(DFFTPClient.java:369)
at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:2245)
at com.ml.gpb.distfrmw.connector.DFFTPClient.put(DFFTPClient.java:338)
at com.ml.gpb.distfrmw.sender.FTPSender.send(FTPSender.java:268)
at com.ml.gpb.distfrmw.sender.Sender.sendObject(Sender.java:276)
at com.ml.gpb.distfrmw.core.DistributionTask.processDistribution(DistributionTask.java:255)
at com.ml.gpb.distfrmw.core.DistributionTask.call(DistributionTask.java:66)
at edu.emory.mathcs.backport.java.util.concurrent.FutureTask.run(FutureTask.java:178)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
at java.lang.Thread.run(Thread.java:534)

[2009/08/25 00:00:38:534] ERROR -->> Sender -> ERROR -->> Cannot send file
java.lang.StringIndexOutOfBoundsException: String index out of range: -50
at java.lang.String.substring(String.java:1444)
at com.enterprisedt.net.ftp.FTPControlSocket.getPASVParts(FTPControlSocket.java:838)
at com.enterprisedt.net.ftp.FTPControlSocket.createDataSocketPASV(FTPControlSocket.java:775)
at com.enterprisedt.net.ftp.FTPControlSocket.createDataSocket(FTPControlSocket.java:547)
at com.enterprisedt.net.ftp.FTPClient.setupDataSocket(FTPClient.java:2452)
at com.enterprisedt.net.ftp.FTPClient.initPut(FTPClient.java:2503)
at com.enterprisedt.net.ftp.FTPClient.putData(FTPClient.java:2576)
at com.enterprisedt.net.ftp.FTPClient.putStream(FTPClient.java:2309)
at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:2194)
at com.ml.gpb.distfrmw.connector.DFFTPClient.put(DFFTPClient.java:308)
at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:2280)
at com.ml.gpb.distfrmw.connector.DFFTPClient.put(DFFTPClient.java:369)
at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:2245)
at com.ml.gpb.distfrmw.connector.DFFTPClient.put(DFFTPClient.java:338)
at com.ml.gpb.distfrmw.sender.FTPSender.send(FTPSender.java:268)
at com.ml.gpb.distfrmw.sender.Sender.sendObject(Sender.java:276)
at com.ml.gpb.distfrmw.core.DistributionTask.processDistribution(DistributionTask.java:255)
at com.ml.gpb.distfrmw.core.DistributionTask.call(DistributionTask.java:66)
at edu.emory.mathcs.backport.java.util.concurrent.FutureTask.run(FutureTask.java:178)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
at java.lang.Thread.run(Thread.java:534)

Categories

...