KDatabases / Kedis

Redis Kotlin wrapper based on Jedis
Apache License 2.0
16 stars 6 forks source link

kotlin exit block error #4

Closed allphfa closed 6 years ago

allphfa commented 6 years ago
    runBlocking {

        val redis = Kedis.get(File(this.javaClass.getResource("/redis.conf").toURI()))
        redis.enable()

        redis {

        }
        // err??
}
Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at kotlin.reflect.jvm.internal.FunctionCaller$Method.callMethod(FunctionCaller.kt:97)
    at kotlin.reflect.jvm.internal.FunctionCaller$StaticMethod.call(FunctionCaller.kt:107)
    at kotlin.reflect.jvm.internal.KCallableImpl.call(KCallableImpl.kt:106)
    at kotlin.reflect.jvm.internal.KCallableImpl.callDefaultMethod(KCallableImpl.kt:148)
    at kotlin.reflect.jvm.internal.KCallableImpl.callBy(KCallableImpl.kt:110)
    at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.callFunctionWithInjection(ApplicationEngineEnvironmentReloading.kt:334)
    at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.executeModuleFunction(ApplicationEngineEnvironmentReloading.kt:285)
    at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.instantiateAndConfigureApplication(ApplicationEngineEnvironmentReloading.kt:262)
    at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.createApplication(ApplicationEngineEnvironmentReloading.kt:119)
    at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.start(ApplicationEngineEnvironmentReloading.kt:234)
    at io.ktor.server.netty.NettyApplicationEngine.start(NettyApplicationEngine.kt:90)
    at io.ktor.server.netty.NettyApplicationEngine.start(NettyApplicationEngine.kt:16)
    at io.ktor.server.engine.ApplicationEngine$DefaultImpls.start$default(ApplicationEngine.kt:46)
    at io.ktor.server.netty.DevelopmentEngine.main(DevelopmentEngine.kt:14)
Caused by: java.lang.NoClassDefFoundError: kotlin/AutoCloseableKt
    at com.sxtanna.database.base.Database.invoke(Database.kt:115)
    at io.fastpay.order.OrderKt$orderApi$1.doResume(order.kt:137)
    at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:42)
    at kotlinx.coroutines.experimental.DispatchedTask$DefaultImpls.run(Dispatched.kt:149)
    at kotlinx.coroutines.experimental.DispatchedContinuation.run(Dispatched.kt:13)
    at kotlinx.coroutines.experimental.EventLoopBase.processNextEvent(EventLoop.kt:140)
    at kotlinx.coroutines.experimental.BlockingCoroutine.joinBlocking(Builders.kt:70)
    at kotlinx.coroutines.experimental.BuildersKt__BuildersKt.runBlocking(Builders.kt:46)
    at kotlinx.coroutines.experimental.BuildersKt.runBlocking(Unknown Source)
    at kotlinx.coroutines.experimental.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:36)
    at kotlinx.coroutines.experimental.BuildersKt.runBlocking$default(Unknown Source)
    at io.fastpay.order.OrderKt.orderApi(order.kt:124)
    at io.fastpay.MainKt$main$1.invoke(main.kt:17)
    at io.fastpay.MainKt$main$1.invoke(main.kt)
    at io.ktor.routing.Routing$Feature.install(Routing.kt:65)
    at io.ktor.routing.Routing$Feature.install(Routing.kt:51)
    at io.ktor.application.ApplicationFeatureKt.install(ApplicationFeature.kt:59)
    at io.ktor.routing.RoutingKt.routing(Routing.kt:93)
    at io.fastpay.MainKt.main(main.kt:16)
    ... 18 more
Caused by: java.lang.ClassNotFoundException: kotlin.AutoCloseableKt
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 37 more
Sxtanna commented 6 years ago

@AlphaFase Looks like you aren't compiling the entire standard library into your project.

Do you mind providing your project's maven pom/gradle build file? And also information about this runtime environment.

allphfa commented 6 years ago

build.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

plugins {
    id 'java'
    id 'org.jetbrains.kotlin.jvm' version '1.2.70'
}

apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'kotlin'
apply plugin: 'application'

mainClassName = 'io.ktor.server.netty.DevelopmentEngine'

/*
sourceSets {
    main.kotlin.srcDirs = [ 'src/main/kotlin' ]
    //test.kotlin.srcDirs = [ 'src/test/kotlin' ]
    //main.resources.srcDirs = [ 'src/mian/resources' ]
}
*/

group 'fastpay'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
    jcenter()
    maven { url "http://kotlin.bintray.com/ktor" }
    maven { url "https://kotlin.bintray.com/kotlin-js-wrappers" }
    maven { url 'https://jitpack.io' }

}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

    testCompile group: 'junit', name: 'junit', version: "$junit_version"

    compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinx_coroutines_version"

    compile "io.ktor:ktor:$ktor_version"
    compile "io.ktor:ktor-server-netty:$ktor_version"
    compile "io.ktor:ktor-html-builder:$ktor_version"
    compile "ch.qos.logback:logback-classic:$logback_version"
    compile "net.logstash.logback:logstash-logback-encoder:5.1"

    compile "org.jetbrains:kotlin-css-jvm:1.0.0-pre.31-kotlin-1.2.41"
    testCompile "io.ktor:ktor-server-tests:$ktor_version"

    compile "io.ktor:ktor-gson:$ktor_version"
    compile "io.ktor:ktor-locations:$ktor_version"

    // https://github.com/KDatabases/Kedis
    compile "redis.clients:jedis:$jedis_version"
    // http://litote.org/kmongo/
    compile "org.litote.kmongo:kmongo:$kmongo_version"
    compile 'com.uchuhimo:konf:0.11'

    compile "com.sxtanna.database:Kedis:+"
}

compileKotlin {
    kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
    kotlinOptions.jvmTarget = "1.8"
}

kotlin.experimental.coroutines = 'enable'

gradle.properties

kotlin_version = 1.2.70
ktor_version = 0.9.5

logback_version = 1.2.3
slf4j_version = 1.7.25
gce_logback_version = 0.60.0-alpha

kotlinx_coroutines_version = 0.25.0
kotlinx_serialization_version = 0.6.2

junit_version = 4.12

kmongo_version = 3.8.3
jedis_version = 2.9.0

redis.conf

{
  "server": {
    "address": "127.0.0.1",
    "port": 6379
  },
  "user": {
    "auth": "xxxx",
    "defaultDB": 0
  },
  "pool": {
    "maxSize": 200,
    "idleSize": 200,
    "timeout": 0
  }
}

main.kt

package io.fastpay

import io.fastpay.order.orderApi
import io.ktor.application.Application
import io.ktor.application.install
import io.ktor.features.CallLogging
import io.ktor.features.DefaultHeaders
import io.ktor.locations.Locations
import io.ktor.routing.routing

fun Route.orderApi() {
    runBlocking {

        val redis = Kedis.get(File(this.javaClass.getResource("/redis.conf").toURI()))
        redis.enable()

        redis {

        }
      // here error
     println(1111)
    }
}

fun Application.main() {
    install(DefaultHeaders)
    install(CallLogging)
    install(Locations)
    routing {
        orderApi()
    }
}
allphfa commented 6 years ago

mian class: io.ktor.server.netty.DevelopmentEngine

resources > application.conf

ktor {
    deployment {
        port = 80
        watch = [ io.fastpay.MainKt ]
    }

    application {
        modules = [ io.fastpay.MainKt.main ]
    }
}
allphfa commented 6 years ago

online wait

Sxtanna commented 6 years ago

@AlphaFase Ok, I've identified the issue.

In the newer version of Kotlin, they have moved these functions from kotlin.AutoCloseableKt to kotlin.io.CloseableKt

A simple fix for this would just be a recompilation on my end, and then a quick push to central. I can make a release on here with the new binaries, and you would just need to install it manually. (or wait for central to refresh with the new update).

allphfa commented 6 years ago

ok

Sxtanna commented 6 years ago

@AlphaFase

Addressed in https://github.com/KDatabases/Core/commit/f12ba983726cceb6d75dad62c1ed2f260e788cbc and integrated in https://github.com/KDatabases/Kedis/commit/b15b59ffe9e7eace55c3d35f89c16cd87cea4135

Push to central should be done in a couple of hours