gradle - Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/csv/CSVFormat -


i using gradle project log4j2... , getting following error while creating csvlayout: exception in thread "main" java.lang.noclassdeffounderror: org/apache/commons/csv/csvformat

csvparameterlayoutexample class

package log4j_tutorial; import org.apache.logging.log4j.logmanager;  import org.apache.logging.log4j.logger;  public class csvparameterlayoutexample {  private static final logger logger = logmanager.getlogger();  public static void main(string[] args) {     int val1 = 10, val2 = 11, val3 = 12;     logger.trace("trace message!", val1, val2, val3);     logger.debug("debug message!", val1, val2, val3);     logger.info("info message!", val1, val2, val3);     logger.warn("warn message!", val1, val2, val3);     logger.error("error message!", val1, val2, val3);     logger.fatal("fatal message!", val1, val2, val3); } 

}

log4j2.xml

<?xml version="1.0" encoding="utf-8"?> <configuration status="warn" xmlns="http://logging.apache.org/log4j/2.0/config" packages="log4j_tutorial"> <appenders> <file name="my_file_appender"  filename="c:/users/bishal.gupta/desktop/testing/csvlog4jtest/application.log"> <csvparameterlayout delimiter=","/> </file> </appenders>  <loggers>    <root level="info">        <appenderref ref="my_file_appender" />    </root> </loggers> </configuration> 

build.gradle dependencies

exception:

exception in thread "main" java.lang.noclassdeffounderror: org/apache/commons/csv/csvformat @ java.lang.class.getdeclaredmethods0(native method) @ java.lang.class.privategetdeclaredmethods(class.java:2442) @ java.lang.class.getdeclaredmethods(class.java:1808) @     org.apache.logging.log4j.core.config.plugins.util.pluginbuilder.createbuilder(pluginbuilder.java:149) @   org.apache.logging.log4j.core.config.plugins.util.pluginbuilder.build(pluginbuilder.java:119) @ org.apache.logging.log4j.core.config.abstractconfiguration.createpluginobject(abstractconfiguration.java:888) @ org.apache.logging.log4j.core.config.abstractconfiguration.createconfiguration(abstractconfiguration.java:828) @ org.apache.logging.log4j.core.config.abstractconfiguration.createconfiguration(abstractconfiguration.java:820) @ org.apache.logging.log4j.core.config.abstractconfiguration.createconfiguration(abstractconfiguration.java:820) @ org.apache.logging.log4j.core.config.abstractconfiguration.doconfigure(abstractconfiguration.java:449) @ org.apache.logging.log4j.core.config.abstractconfiguration.initialize(abstractconfiguration.java:197) @ org.apache.logging.log4j.core.config.abstractconfiguration.start(abstractconfiguration.java:209) @ org.apache.logging.log4j.core.loggercontext.setconfiguration(loggercontext.java:492) @ org.apache.logging.log4j.core.loggercontext.reconfigure(loggercontext.java:562) @ org.apache.logging.log4j.core.loggercontext.reconfigure(loggercontext.java:578) @ org.apache.logging.log4j.core.loggercontext.start(loggercontext.java:214) @ org.apache.logging.log4j.core.impl.log4jcontextfactory.getcontext(log4jcontextfactory.java:145) @ org.apache.logging.log4j.core.impl.log4jcontextfactory.getcontext(log4jcontextfactory.java:41) @ org.apache.logging.log4j.logmanager.getcontext(logmanager.java:182) @ org.apache.logging.log4j.logmanager.getlogger(logmanager.java:455) @ org.apache.logging.log4j.logmanager.getlogger(logmanager.java:441) @ log4j_tutorial.csvparameterlayoutexample.<clinit>(csvparameterlayoutexample.java:7) caused by: java.lang.classnotfoundexception: org.apache.commons.csv.csvformat @ java.net.urlclassloader$1.run(urlclassloader.java:366) @ java.net.urlclassloader$1.run(urlclassloader.java:355) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:354) @ java.lang.classloader.loadclass(classloader.java:423) @ sun.misc.launcher$appclassloader.loadclass(launcher.java:308) @ java.lang.classloader.loadclass(classloader.java:356) ... 22 more 

i got stuck morning ... :(

you have add commons-csv dependency.

if use gradle question tagged, add these line:

// https://mvnrepository.com/artifact/org.apache.commons/commons-csv compile group: 'org.apache.commons', name: 'commons-csv', version: '1.4' 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -