tag:blogger.com,1999:blog-13911304.post-1121355487076768092005-07-14T08:25:00.000-07:002005-07-19T14:50:46.786-07:00apache.commons.net ParserInitializationException<div style="text-align: left;"><span style="font-size:85%;">We use the jakarta/apache (don't know what they call it these days) commons net jar as our ftp client and this seems to be failing with a TANDEM ftp box.</span><span style="font-size:85%;"> Looks like <a href="http://www.opensubscriber.com/message/commons-dev@jakarta.apache.org/1695230.html">someone else</a> was running into the same error at about the same time.<br />This is the error I was running into:</span><br /><br /><span style="font-size:85%;"><span style="color: rgb(102, 51, 51); font-weight: bold;font-family:courier new;" >org.apache.commons.net.ftp.parser.ParserInitializationException:<br />Error initializing parser at org.apache.commons.net.ftp.parser.DefaultFTPFileEntryParserFactory.<br />createFileEntryParser(DefaultFTPFileEntryParserFactory.java:115) at org.apache.commons.net.ftp.FTPClient.<br />initiateListParsing(FTPClient.java:2306) at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2055) at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2106) at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2146)</span></span><br /><br /><span style="font-size:85%;">After taking a look at the commons code, here's what I figured out, the TANDEM box was returning</span><br /><span style="font-size:85%;">an empty string on a FTP SYST command. Our good people at commons don't handle a null, assuming</span><br /><span style="font-size:85%;">the FTPClient.getSystemName() always returns something. So here's my hack to get around it.</span><br /><br /><span style="font-size:85%;"> <span style="color: rgb(102, 102, 0); font-weight: bold;font-family:courier new;" > if(null == ftpClient.getSystemName()) {</span></span><br /><span style="font-size:85%;"> <span style="color: rgb(102, 102, 0); font-weight: bold;font-family:courier new;" > //use parserKey,pathName method signature</span></span><br /><span style="font-size:85%;"> <span style="color: rgb(102, 102, 0); font-weight: bold;font-family:courier new;" > ftpFileArray = ftpClient.listFiles("UNIX",(String)null);</span></span><br /><span style="font-size:85%;"> <span style="color: rgb(102, 102, 0); font-weight: bold;font-family:courier new;" > } else {</span></span><br /><span style="font-size:85%;"> <span style="color: rgb(102, 102, 0); font-weight: bold;font-family:courier new;" > ftpFileArray = ftpClient.listFiles();</span></span><br /><span style="font-size:85%;"> <span style="color: rgb(102, 102, 0); font-weight: bold;font-family:courier new;" > }</span></span><br /><span style="font-size:85%;"> </span></div>Java Foohttp://www.blogger.com/profile/14104080800348407575noreply@blogger.com