Appendium / flatpack

CSV/Tab Delimited and Fixed Length Parser and Writer
http://flatpack.sf.net
Apache License 2.0
57 stars 20 forks source link

Getting an error - "java.net.SocketException: Connection reset" #31

Open avikadam opened 7 years ago

avikadam commented 7 years ago

Any clue...

Caused by: java.net.SocketException: Connection reset at java.net.SocketInputStream.read(Unknown Source) at java.net.SocketInputStream.read(Unknown Source) at java.io.BufferedInputStream.fill(Unknown Source) at java.io.BufferedInputStream.read1(Unknown Source) at java.io.BufferedInputStream.read(Unknown Source) at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source) at sun.net.www.http.HttpClient.parseHTTP(Unknown Source) at sun.net.www.http.HttpClient.parseHTTP(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source) at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source) at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown Source) at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown Source) at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at org.jdom.input.SAXBuilder.build(SAXBuilder.java:518) at org.jdom.input.SAXBuilder.build(SAXBuilder.java:970) at net.sf.flatpack.xml.MapParser.parse(MapParser.java:130) at net.sf.flatpack.xml.MapParser.parseMap(MapParser.java:276) at net.sf.flatpack.FixedLengthParser.init(FixedLengthParser.java:110)

benoitx commented 7 years ago

Hello

No clue no. But you have provided very little information. Could you kindly provide a test case, what is the xml file that you are trying to load? It seems to be a network exception.

More info please

Thanks


Important Notice This communication contains information that is considered confidential and may also be privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender and delete the original

On 27 Sep 2017, at 04:02, Avinash notifications@github.com wrote:

Any clue...

Caused by: java.net.SocketException: Connection reset at java.net.SocketInputStream.read(Unknown Source) at java.net.SocketInputStream.read(Unknown Source) at java.io.BufferedInputStream.fill(Unknown Source) at java.io.BufferedInputStream.read1(Unknown Source) at java.io.BufferedInputStream.read(Unknown Source) at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source) at sun.net.www.http.HttpClient.parseHTTP(Unknown Source) at sun.net.www.http.HttpClient.parseHTTP(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source) at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source) at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown Source) at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown Source) at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at org.jdom.input.SAXBuilder.build(SAXBuilder.java:518) at org.jdom.input.SAXBuilder.build(SAXBuilder.java:970) at net.sf.flatpack.xml.MapParser.parse(MapParser.java:130) at net.sf.flatpack.xml.MapParser.parseMap(MapParser.java:276) at net.sf.flatpack.FixedLengthParser.init(FixedLengthParser.java:110)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

avikadam commented 7 years ago

// It worked fine first time but 2nd onward it's failing. Please find following code. This is from my web application. Somehow it started failing in production. It fails at parser.parse()

    public class FixedLengthFlatpackFileProcessor extends FlatpackFlatFileProcessor {
 protected String mappingFilePath;
 private static Logger logger = Logger.getLogger(FixedLengthFlatpackFileProcessor.class);

/**
 * Construct new {@link FixedLengthFlatpackFileProcessor} using the XML file layout.
 *
 * @param mappingFilePath
 */
public FixedLengthFlatpackFileProcessor(final String mappingFilePath) {
    this.mappingFilePath = mappingFilePath;
}

@Override
public Stream<FlatFileRecord> streamFlatFileRecords(final Parser parser, final FileInterfaceExecution fileExecution){
    return parser.stream().map(record -> this.mapFlatPackRecordToflatFileRecord(fileExecution, record));
}

@Override
public final BuffReaderFixedParser getFlatpackParser(final String filePath){
    try{
        return (BuffReaderFixedParser) BuffReaderParseFactory.getInstance()
            .newFixedLengthParser(new FileReader(new File(this.mappingFilePath)), new FileReader(new File(filePath)));
    }catch(final FileNotFoundException e){
        FixedLengthFlatpackFileProcessor.logger.error(e.getMessage(), e);
        throw new ResourceNotFoundException(e, "FRM000022", filePath);
    }
}

           public List<ErrorDescriptor> validateFileForStaging(final String filePath){
    final Parser parser = this.getFlatpackParser(filePath);
    final DataSet ds = parser.parse(); //**# Failing here**
       }

 }
avikadam commented 7 years ago

//This is the mapping file

<?xml version='1.0'?>

<!DOCTYPE PZMAP SYSTEM "http://flatpack.sourceforge.net/flatpack.dtd" > <PZMAP> <RECORD id="header" indicator="H" startPosition="1" endPosition="1"> <COLUMN name="RECORD_TYPE_CODE" length="1" /> <COLUMN name="HEADER_ID" length="50" /> <COLUMN name="FILE_CREATION_DATE" length="8" /> </RECORD> <RECORD id="batchHeader" indicator="B" startPosition="1" endPosition="1"> <COLUMN name="RECORD_TYPE_CODE" length="1" /> <COLUMN name="BATCH_NUMBER" length="50" /> </RECORD> <COLUMN name="RECORD_TYPE_CODE" length="1" /> <COLUMN name="INVOICE_NUMBER" length="50" /> <COLUMN name="PAYMENT_AMOUNT" length="13" /> <RECORD id="batchTrailer" indicator="A" startPosition="1" endPosition="1"> <COLUMN name="RECORD_TYPE_CODE" length="1" /> <COLUMN name="BATCH_NUMBER" length="50" /> <COLUMN name="RECORD_COUNT" length="10" /> </RECORD> <RECORD id="trailer" indicator="T" startPosition="1" endPosition="1"> <COLUMN name="RECORD_TYPE_CODE" length="1" /> <COLUMN name="RECORD_COUNT" length="10" /> </RECORD> </PZMAP>

benoitx commented 7 years ago

Is the DTD still available at

http://flatpack.sourceforge.net/flatpack.dtd ?


Important Notice This communication contains information that is considered confidential and may also be privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender and delete the original

On 27 Sep 2017, at 18:41, Avinash notifications@github.com wrote:

<!DOCTYPE PZMAP SYSTEM "http://flatpack.sourceforge.net/flatpack.dtd" >

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

avikadam commented 7 years ago

Yes but looks like Sourceforge.net is down

avikadam commented 7 years ago

what i need to do in this case

benoitx commented 7 years ago

Interesting...

1) are you sure this is the problem? 2) Can you change the xml file to point somewhere else? 3) Can it work without the URL for the DTD?

Suggestions welcome

On 27 September 2017 at 18:49, Avinash notifications@github.com wrote:

what i need to do in this case

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Appendium/flatpack/issues/31#issuecomment-332602523, or mute the thread https://github.com/notifications/unsubscribe-auth/AAPeaRkpF15Xp4nKKmImTWjfIRq4Phfzks5smoq3gaJpZM4PlJxV .

-- Follow us on Twitter @appendium http://twitter.com/appendium and http://www.appendium.com

IMPORTANT NOTICE This communication contains information that is considered confidential and may also be privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender and delete the original.

avikadam commented 7 years ago

Thanks Man for replying so promptly i appreciate it.

Yes, i did confirmed, this is the problem. I tried with local dtd location, it works. Sometime these remote or dtds located at other server makes problem in case they stops supporting or goes down.

benoitx commented 7 years ago

If you could help me by telling me how we could make FlatPack more robust with this issue, that would be very appreciated.

I'm not on my computer at the moment, so I could only give you some ideas and guidance.

Thanks

On 27 September 2017 at 19:31, Avinash notifications@github.com wrote:

Thanks Man for replying so promptly i appreciate.

Yes, i did confirmed, this is the problem. I tried with local dtd location

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Appendium/flatpack/issues/31#issuecomment-332614451, or mute the thread https://github.com/notifications/unsubscribe-auth/AAPeaWn-qQKVue7zBVaiJQMFSjQh1GWeks5smpRogaJpZM4PlJxV .

-- Follow us on Twitter @appendium http://twitter.com/appendium and http://www.appendium.com

IMPORTANT NOTICE This communication contains information that is considered confidential and may also be privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender and delete the original.

avikadam commented 7 years ago

Sounds good. Will post details and observations.

Thanks

benoitx commented 7 years ago

Credit will be given for any solution.

Thanks a lot

Regards from London

On 27 September 2017 at 21:30, Avinash notifications@github.com wrote:

Sounds good. Will post details and observations.

Thanks

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Appendium/flatpack/issues/31#issuecomment-332645790, or mute the thread https://github.com/notifications/unsubscribe-auth/AAPeaRrGVBsFPh0n6YrifAWJlZrvQRbeks5smrBmgaJpZM4PlJxV .

-- Follow us on Twitter @appendium http://twitter.com/appendium and http://www.appendium.com

IMPORTANT NOTICE This communication contains information that is considered confidential and may also be privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender and delete the original.

martindiphoorn commented 6 years ago

Wondering if this is still an issue when we have dropped JDOM in #11