Olá, comunidade ! Antes de mais nada agradeço pela atenção dos senhores, vamos ao problema.
Eu já procurei em inúmeros fóruns (inclusive aqui no Guj) solução para o meu problema, eu encontrei pessoas com o mesmo problema, mas a causa (aparentemente) é diferente.
Eu estou precisando realizar operações via FTP com o FTPClient, eu consigo conectar e autenticar, mas qualquer operação que eu faça, ele lança esta maldita exception:
`Caused by: org.apache.commons.net.ftp.FTPConnectionClosedException: Connection closed without indication.
at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:313)
at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:290)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:479)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:552)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:601)
at org.apache.commons.net.ftp.FTP.pasv(FTP.java:952)
at org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:755)
at org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:657)
at org.apache.commons.net.ftp.FTPClient.listNames(FTPClient.java:2633)
at org.apache.commons.net.ftp.FTPClient.listNames(FTPClient.java:2682)
at br.com.copimar.visao.util.ClienteFTP.<init>(Unknown Source)
at br.com.copimar.negocio.BoletoNegocioImpl.EnviarBoletoParaServidor(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy37.EnviarBoletoParaServidor(Unknown Source)
at br.com.copimar.visao.SendFileBean.handleFileUpload(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.el.parser.AstValue.invoke(AstValue.java:279)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:273)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
... 101 more`
Esta é o meu método que eu uso para realizar a operação de listar arquivos:
public ClienteFTP(String host, String user, String pwd) throws Exception {
FTPClient ftp = new FTPClient();
ftp.connect(host);
ftp.login(user, pwd);
ftp.enterLocalPassiveMode();
ftp.changeWorkingDirectory("/");
String[] arq = ftp.listNames();
System.out.println("Listando arquivos: \n");
for (String f : arq) {
System.out.println(f);
}
}
Aparentemente está tudo nos conformes. Vocês sabem o que pode está acontecendo? Desde já agradeço. Um grande abraço.