我为节点的内置网络服务器定义了以下API:
@Path("example")
class ExampleApi(private val rpcOps: CordaRPCOps) {
companion object {
private val logger: Logger = loggerFor<ExampleApi>()
}
@GET
@Path("test")
fun test(@QueryParam("id") id: UniqueIdentifier) {
}
}
当我启动节点的网络服务器时,出现以下错误:
javax.servlet.ServletException: org.glassfish.jersey.servlet.ServletContainer-3892802b@81527534==org.glassfish.jersey.servlet.ServletContainer,jsp=null,order=0,inst=false
at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:658) ~[jetty-servlet-9.4.7.v20170914.jar:9.4.7.v20170914]
at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:421) ~[jetty-servlet-9.4.7.v20170914.jar:9.4.7.v20170914]
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:760) ~[jetty-servlet-9.4.7.v20170914.jar:9.4.7.v20170914]
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:348) ~[jetty-servlet-9.4.7.v20170914.jar:9.4.7.v20170914]
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:785) ~[jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914]
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:261) ~[jetty-servlet-9.4.7.v20170914.jar:9.4.7.v20170914]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) ~[jetty-util-9.4.7.v20170914.jar:9.4.7.v20170914]
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131) ~[jetty-util-9.4.7.v20170914.jar:9.4.7.v20170914]
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:113) ~[jetty-util-9.4.7.v20170914.jar:9.4.7.v20170914]
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) ~[jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) ~[jetty-util-9.4.7.v20170914.jar:9.4.7.v20170914]
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131) ~[jetty-util-9.4.7.v20170914.jar:9.4.7.v20170914]
at org.eclipse.jetty.server.Server.start(Server.java:449) ~[jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914]
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:105) ~[jetty-util-9.4.7.v20170914.jar:9.4.7.v20170914]
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) ~[jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914]
at org.eclipse.jetty.server.Server.doStart(Server.java:416) ~[jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) ~[jetty-util-9.4.7.v20170914.jar:9.4.7.v20170914]
at net.corda.webserver.internal.NodeWebServer.initWebServer(NodeWebServer.kt:90) ~[corda-webserver-impl-3.1-corda.jar:?]
at net.corda.webserver.internal.NodeWebServer.start(NodeWebServer.kt:45) ~[corda-webserver-impl-3.1-corda.jar:?]
at net.corda.webserver.WebServer.main(WebServer.kt:64) [corda-webserver-impl-3.1-corda.jar:?]
Caused by: org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
[[FATAL] No injection source found for a parameter of type public final void com.example.api.ExampleApi.test(net.corda.core.contracts.UniqueIdentifier) at index 0.; source='ResourceMethod{httpMethod=GET, consumedTypes=[], producedTypes=[], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class com.example.api.ExampleApi, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@15096b0e]}, definitionMethod=public final void com.example.api.ExampleApi.test(net.corda.core.contracts.UniqueIdentifier), parameters=[Parameter [type=class net.corda.core.contracts.UniqueIdentifier, source=id, defaultValue=null]], responseType=void}, nameBindings=[]}', [HINT] A HTTP GET method, public final void com.example.api.ExampleApi.test(net.corda.core.contracts.UniqueIdentifier), returns a void type. It can be intentional and perfectly fine, but it is a little uncommon that GET method returns always "204 No Content".; source='ResourceMethod{httpMethod=GET, consumedTypes=[], producedTypes=[], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class com.example.api.ExampleApi, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@15096b0e]}, definitionMethod=public final void com.example.api.ExampleApi.test(net.corda.core.contracts.UniqueIdentifier), parameters=[Parameter [type=class net.corda.core.contracts.UniqueIdentifier, source=id, defaultValue=null]], responseType=void}, nameBindings=[]}']
at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:555) ~[jersey-server-2.25.jar:?]
at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:184) ~[jersey-server-2.25.jar:?]
at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:350) ~[jersey-server-2.25.jar:?]
at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:347) ~[jersey-server-2.25.jar:?]
at org.glassfish.jersey.internal.Errors.process(Errors.java:315) ~[jersey-common-2.25.jar:?]
at org.glassfish.jersey.internal.Errors.process(Errors.java:297) ~[jersey-common-2.25.jar:?]
at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255) ~[jersey-common-2.25.jar:?]
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:347) ~[jersey-server-2.25.jar:?]
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:392) ~[jersey-container-servlet-core-2.25.jar:?]
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:177) ~[jersey-container-servlet-core-2.25.jar:?]
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:369) ~[jersey-container-servlet-core-2.25.jar:?]
at javax.servlet.GenericServlet.init(GenericServlet.java:244) ~[javax.servlet-api-3.1.0.jar:3.1.0]
at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:637) ~[jetty-servlet-9.4.7.v20170914.jar:9.4.7.v20170914]
... 19 more
答案 0 :(得分:0)
您不能在节点内置网络服务器的API中使用UniqueIdentiifer
作为端点参数类型。
您需要将标识符作为字符串传递,并使用UniqueIdentifier.fromString
检索UniqueIdentifier
。