启动corda节点时出现错误消息。
Exception in thread "main" java.lang.NoClassDefFoundError:
net/corda/webserver/services/WebServerPluginRegistry
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 java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at java.util.ServiceLoader$LazyIterator.nextService(Unknown Source)
at java.util.ServiceLoader$LazyIterator.next(Unknown Source)
at java.util.ServiceLoader$1.next(Unknown Source)
插件的代码:
class testcasePlugin : SerializationWhitelist, WebServerPluginRegistry{
override val webApis = listOf(
Function(::MiscApi),
)
override val staticServeDirs: Map<String, String> = mapOf(
// URL is /web/index
"index" to javaClass.classLoader.getResource("index").toExternalForm(),
// URL is /web/testcase
"testcase" to javaClass.classLoader.getResource("testcase").toExternalForm()
)
override val whitelist: List<Class<*>> = listOf(TransactionBuilder::class.java)
}
获取错误的诀窍是删除&#39; net.corda.core.serialization.SerializationWhitelist&#39;来自META-INF.services文件夹的文件只留下&net; net.corda.webserver.services.WebServerPluginRegistry&#39;文件。
知道出了什么问题吗?
答案 0 :(得分:0)
您必须将插件拆分为两个,如下所示:
class testcaseWebPlugin : WebServerPluginRegistry {
override val webApis = listOf(
Function(::MiscApi))
override val staticServeDirs: Map<String, String> = mapOf(
// URL is /web/index
"index" to javaClass.classLoader.getResource("index").toExternalForm(),
// URL is /web/testcase
"testcase" to javaClass.classLoader.getResource("testcase").toExternalForm()
)
class testcaseSerializationPlugin : SerializationWhitelist {
override val whitelist: List<Class<*>> =
listOf(TransactionBuilder::class.java)
}
}