Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
927 views
in Technique[技术] by (71.8m points)

csv - java.lang.NoClassDefFoundError: org/apache/commons/lang3/ObjectUtils

I'm trying to code a program to read a CSV file and then make some stuff with it. I've searching a lot, and finally I found out this library.

Some days ago I finished the code, and everything worked fine. Today I updated the library to the 4.0 v, and then a lot of warnings popped out.

I made some testing and the part that fails is:

public void LeerCSV(File CSVCat, File CSVProd){  
//Creo un objeto de la clase FileReader que me hace falta para los CSVReader
CSVReaderBuilder lectorCatBuilder = null;
CSVReaderBuilder lectorProdBuilder = null;

CSVReader CatReader = null;
CSVReader ProdReader = null;

CSVParser CatParser = null;
CSVParser ProdParser = null;
        //Vamos a intentar abrirlos y operar con ellos 

try {
    //Se crea una especie de "constructor" para crear los lectores de archivos.
    //para ello, antes se le pasan todos los atributos que queramos        

   CatParser =
   new CSVParserBuilder()
   .withSeparator(SEPARADOR)
   .withIgnoreQuotations(true)
   .build();
   CatReader =
   new CSVReaderBuilder(new FileReader(CSVCat))
   .withSkipLines(1)
   .withCSVParser(CatParser)
   .build();

   ProdParser =
   new CSVParserBuilder()
   .withSeparator(SEPARADOR)
   .withIgnoreQuotations(true)
   .build();
   ProdReader =
   new CSVReaderBuilder(new FileReader(CSVProd))
   .withSkipLines(1)
   .withCSVParser(ProdParser)
   .build();

This one.

The warnings are:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: 
org/apache/commons/lang3/ObjectUtils
at com.opencsv.CSVParser.<init>(CSVParser.java:207)
at com.opencsv.CSVParserBuilder.build(CSVParserBuilder.java:138)
...
...
Caused by: java.lang.ClassNotFoundException: 
org.apache.commons.lang3.ObjectUtils
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

This ones.

I know that is a library problem but I don't know what library is causing it, or if I need to update or install something.

Thank you very much.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It's seem that you are not using apache commons lang3 library : https://mvnrepository.com/artifact/org.apache.commons/commons-lang3


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...