I've just recently discovered Kotlin and decided to recreate a small web-app I developed using pure Java with Dropwizard 0.6.2.
This new project has such a structure:
package com.christian.servicepublic class MyService: Service() {
public override fun initialize(bootstrap: Bootstrap?) {
bootstrap?.setName(“kotlin-service”)
}public override fun run(configuration: MyConfiguration?, environment: Environment?) {
}
}
And the corresponding main class:
package com.christian.service;public class Main {
public static void main(String args) throws Exception {
new com.christian.service.MyService().run(args);
}
}
Dropwizard, for those that haven’t used it, comes with a built-in Jetty Server that you start up with the following command:
java -jar target/KotlinTest.jar server kotlin-configuration.yml
However, I get the following ClassDefNotFoundException:
Exception in thread "main" java.lang.NoClassDefFoundError: jet/JetObject at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$100(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at com.syncofy.service.Main.main(Main.java:12) Caused by: java.lang.ClassNotFoundException: jet.JetObject at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 13 more
I've already tried using
java -cp kotlin-runtime.jar; com/christian/service server kotlin-configuration
but that doesn't work:
Error: Could not find or load main class com.christian.service
Any suggestions?