Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 769
Indieaiden Avatar asked Sep 04 '17 09:09

Indieaiden


1 Answers

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

like image 93
Stéphane Ammar Avatar answered Nov 02 '22 23:11

Stéphane Ammar