Giter Site home page Giter Site logo

Comments (6)

aladine avatar aladine commented on August 18, 2024 7

@and-marsh I am using kotlin script too and the imporing of kotlin-logging works for me. My file is like this:

#!/usr/bin/env kotlin

@file:Repository("https://jcenter.bintray.com")
@file:DependsOn("io.github.microutils:kotlin-logging-jvm:2.0.2")
@file:DependsOn("com.github.doyaaaaaken:kotlin-csv-jvm:0.11.0")

from kotlin-csv.

ltpquang avatar ltpquang commented on August 18, 2024

In my case the Maven try to resolve mu/KotlinLogging via JitPack.io instead of Maven Central, and receive an empty Jar, causing such exception.

from kotlin-csv.

doyaaaaaken avatar doyaaaaaken commented on August 18, 2024

@ltpquang OK, thanks for reporting 🙇

from kotlin-csv.

and-marsh avatar and-marsh commented on August 18, 2024

I have the same issue with the kotlin script feature.
It looks like:

java.lang.NoClassDefFoundError: mu/KotlinLogging
        at com.github.doyaaaaaken.kotlincsv.client.CsvFileReader.<init>(CsvFileReader.kt:21)
        at com.github.doyaaaaaken.kotlincsv.client.CsvReader.open(CsvReader.kt:176)
        at com.github.doyaaaaaken.kotlincsv.client.CsvReader.readAllWithHeader(CsvReader.kt:58)
        at Kotlin_test_main$1.invoke(kotlin-test.main.kts:33)
        at Kotlin_test_main$1.invoke(kotlin-test.main.kts:14)
        at com.xenomachina.argparser.SystemExitExceptionKt.mainBody(SystemExitException.kt:74)
        at com.xenomachina.argparser.SystemExitExceptionKt.mainBody$default(SystemExitException.kt:72)
        at Kotlin_test_main.<init>(kotlin-test.main.kts:26)
Caused by: java.lang.ClassNotFoundException: mu.KotlinLogging
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:435)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)

And this my script:

#!/usr/bin/env kotlin

@file:Repository("https://jcenter.bintray.com")
@file:DependsOn("com.xenomachina:kotlin-argparser:2.0.7")
@file:DependsOn("com.github.doyaaaaaken:kotlin-csv-jvm:0.13.0")


import com.github.doyaaaaaken.kotlincsv.dsl.csvReader
import com.xenomachina.argparser.ArgParser
import com.xenomachina.argparser.mainBody
import java.io.File

class MyArgs(parser: ArgParser) {
    val verbose by parser.flagging(
            "-v", "--verbose",
            help = "enable verbose mode")

    val source by parser.positional(
            "SOURCE",
            help = "source filename")
}

mainBody {
    ArgParser(args).parseInto(::MyArgs).run {
        if (verbose) {
            println("Parsing source file: $source")
        }

        val csvData: String = "a,b,c\nd,e,f"
        val rows: List<Map<String, String>> = csvReader().readAllWithHeader(csvData)
        println(rows)
    }
}

Any suggestion?

Anyway, your parser looks great! Thank you for your job!

from kotlin-csv.

doyaaaaaken avatar doyaaaaaken commented on August 18, 2024

Hi, @and-marsh !
I'm sorry I'm not familiar with the kotlin script feature, but I'll try to describe the cause I imagine.

As you could see this line, kotlin-csv uses kotlin-logging as a logging library.

And the kotlin-logging depends on slf4j-api, so maybe you would need to add a concrete logger library like logback.
https://github.com/MicroUtils/kotlin-logging#download

Important note: kotlin-logging depends on slf4j-api (in the JVM artifact). In runtime, it is also required to depend on a logging implementation. More details in how-to-configure-slf4j. And an excellent detailed explanation in a-guide-to-logging-in-java.

from kotlin-csv.

ShehanAT avatar ShehanAT commented on August 18, 2024

Hey,
I ran into a similar error:

org.gradle.internal.resolve.ModuleVersionResolveException: 
Could not resolve io.github.microutils.kotlin-logging:kotlin-logging-common:1.7.9.

but I was able to resolve it by adding the following to my build.gradle file:

implementation 'io.github.microutils:kotlin-logging:1.12.5'

(for some reason implementation 'io.github.microutils:kotlin-logging-jvm:2.0.10' didn't work)

from kotlin-csv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.