CSV Import fails with sun.io.MalformedInputException

http://confluence.atlassian.com/display/JIRAKB/CSV+Import+fails+with+sun.io.MalformedInputException

Symptoms

When trying to import issues via CSV the following error is thrown and the import fails:

Only new Users will be imported FAILED: Unexpected failure occurred. Importer will stop immediately. Data maybe in an unstable state com.atlassian.jira.exception.DataAccessException: com.atlassian.jira.imports.csv.ImportException: sun.io.MalformedInputException
at com.atlassian.jira.imports.csv.CsvDataBean.populateCache(CsvDataBean.java:201)
at com.atlassian.jira.imports.csv.CsvDataBean.refreshCache(CsvDataBean.java:105)
at com.atlassian.jira.imports.csv.CsvDataBean.getUsers(CsvDataBean.java:251)
at com.atlassian.jira.imports.importer.impl.DefaultJiraDataImporter.importUsers(DefaultJiraDataImporter.java:223)
at com.atlassian.jira.imports.importer.impl.DefaultJiraDataImporter.doImport(DefaultJiraDataImporter.java:94)
at com.atlassian.jira.imports.importer.impl.ImporterThread.run(ImporterThread.java:21)
Caused by: com.atlassian.jira.imports.csv.ImportException: sun.io.MalformedInputException
at com.atlassian.jira.imports.csv.MindProdCsvProvider.getNextLine(MindProdCsvProvider.java:102)
at com.atlassian.jira.imports.csv.CsvDataBean.populateCache(CsvDataBean.java:125)
... 5 more
Caused by: sun.io.MalformedInputException
at sun.io.ByteToCharUTF8.convert(ByteToCharUTF8.java:149)
at sun.nio.cs.StreamDecoder$ConverterSD.convertInto(StreamDecoder.java:247)
at sun.nio.cs.StreamDecoder$ConverterSD.implRead(StreamDecoder.java:297)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:182)
at java.io.InputStreamReader.read(InputStreamReader.java:167)
at java.io.BufferedReader.fill(BufferedReader.java:136)
at java.io.BufferedReader.readLine(BufferedReader.java:299)
at java.io.BufferedReader.readLine(BufferedReader.java:362)
at com.mindprod.csv.CSVReader.getLineIfNeeded(CSVReader.java:690)
at com.mindprod.csv.CSVReader.get(CSVReader.java:343)
at com.mindprod.csv.CSVReader.getAllFieldsInLine(CSVReader.java:305)
at com.atlassian.jira.imports.csv.MindProdCsvProvider.getNextLine(MindProdCsvProvider.java:87)

Cause

This error is thrown when the system encoding is in UTF-8 but the CSV file is in a different character encoding.

Resolution

On Unix/Linux you can check the encoding of the CSV using the file command:

[amyers@erdinger:~]$ file mycsvfile.csv
mycsvfile.csv: ISO-8859 English text, with very long lines, with CRLF, LF line terminators

Once you have determind the encoding of the file, you can use the inconv command to change the encoding:

[amyers@erdinger:~]$ iconv -f ISO-8859-1 -t UTF-8 mycsvfile.csv > myutf8csvfile.csv

你可能感兴趣的:(java,linux,unix,F#,sun)