java.lang.UnsupportedOperationException:Kotlin反射尚不支持程序包和文件外观

时间:2019-05-01 10:14:21

标签: kotlin ktor

启动基本的Ktor应用时,我得到:

# Create dummy data of length 91
x <- seq(1, 10, 0.1)
# Create dummy data of length 91
y <- seq(1, 46, 0.5)

getMat <- function(arrays, nrows, ncols, byrow = F) {
  if(length(arrays) == 0) {
    stop("The array is empty. Can't convert it to a matrix")
  }
  return (matrix(arrays, nrow = nrows, ncol = ncols, byrow = byrow))
}

# myMat will have x as first column, y as second column and so on 
myMat <- getMat(c(x, y), length(x), 2, F)
head(myMat)

# Output
head(myMat)
     [,1] [,2]
[1,]  1.0  1.0
[2,]  1.1  1.5
[3,]  1.2  2.0
[4,]  1.3  2.5
[5,]  1.4  3.0
[6,]  1.5  3.5

该应用程序就是:

Exception in thread "main" java.lang.UnsupportedOperationException: Packages and file facades are not yet supported in Kotlin reflection. Meanwhile please use Java reflection to inspect this class: class com.example.ApplicationKt
    at kotlin.reflect.jvm.internal.KClassImpl.reportUnresolvedClass(KClassImpl.kt:301)
    at kotlin.reflect.jvm.internal.KClassImpl.access$reportUnresolvedClass(KClassImpl.kt:43)
    at kotlin.reflect.jvm.internal.KClassImpl$Data$descriptor$2.invoke(KClassImpl.kt:53)
    at kotlin.reflect.jvm.internal.KClassImpl$Data$descriptor$2.invoke(KClassImpl.kt:44)
    at kotlin.reflect.jvm.internal.ReflectProperties$LazySoftVal.invoke(ReflectProperties.java:92)
    at kotlin.reflect.jvm.internal.ReflectProperties$Val.getValue(ReflectProperties.java:31)
    at kotlin.reflect.jvm.internal.KClassImpl$Data.getDescriptor(KClassImpl.kt)
    at kotlin.reflect.jvm.internal.KClassImpl$Data$objectInstance$2.invoke(KClassImpl.kt:106)
    at kotlin.reflect.jvm.internal.ReflectProperties$LazyVal.invoke(ReflectProperties.java:62)
    at kotlin.reflect.jvm.internal.ReflectProperties$Val.getValue(ReflectProperties.java:31)
    at kotlin.reflect.jvm.internal.KClassImpl$Data.getObjectInstance(KClassImpl.kt)
    at kotlin.reflect.jvm.internal.KClassImpl.getObjectInstance(KClassImpl.kt:239)
    at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.createModuleContainer(ApplicationEngineEnvironmentReloading.kt:328)
    at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.executeModuleFunction(ApplicationEngineEnvironmentReloading.kt:317)
    at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.instantiateAndConfigureApplication(ApplicationEngineEnvironmentReloading.kt:275)
    at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.createApplication(ApplicationEngineEnvironmentReloading.kt:127)
    at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.start(ApplicationEngineEnvironmentReloading.kt:247)
    at io.ktor.server.netty.NettyApplicationEngine.start(NettyApplicationEngine.kt:106)
    at io.ktor.server.netty.NettyApplicationEngine.start(NettyApplicationEngine.kt:18)
    at io.ktor.server.engine.ApplicationEngine$DefaultImpls.start$default(ApplicationEngine.kt:52)
    at io.ktor.server.netty.EngineMain.main(EngineMain.kt:17)
    at com.example.ApplicationKt.main(Application.kt:10)

1 个答案:

答案 0 :(得分:0)

我刚刚注意到文件resources.application.conf出现问题。 它的模块名称错误。我将com.example.ApplicationKt.module更改为com.example.ApplicationKt.demoModule

ktor {
    deployment {
        port = 8080
        port = ${?PORT}
    }
    application {
        modules = [ com.example.ApplicationKt.demoModule ]
    }
}

令人讨厌的是,错误帮助对此一无所知。