【问题标题】:Neo4j unmanaged extension: The ResourceConfig instance does not contain any root resource classesNeo4j 非托管扩展:ResourceConfig 实例不包含任何根资源类
【发布时间】:2015-08-31 14:59:20
【问题描述】:

我遇到了来自HelloWorldResource.java 的“经典”The ResourceConfig instance does not contain any root resource classes 错误

我已按照Unmanaged Extensions 的说明进行操作:

  • plugins 目录中添加了 JAR 文件
  • 设置 org.neo4j.server.thirdparty_jaxrs_classes=org.neo4j.examples.server.unmanaged=/examples/unmanaged

这是代码:

package org.neo4j.examples.server.unmanaged;

import ...

@Path( "/helloworld" )
public class HelloWorldResource {

    //private final GraphDatabaseService database;

    //public HelloWorldResource( @Context GraphDatabaseService database )
    //{
    //    this.database = database;
    //}

    @GET
    @Produces( MediaType.TEXT_PLAIN )
    @Path( "/{nodeId}" )
    public Response hello( @PathParam( "nodeId" ) long nodeId )
    {
        // Do stuff with the database
        return Response.status( Status.OK ).entity(
                ("Hello World, nodeId=" + nodeId).getBytes( Charset.forName("UTF-8") ) ).build();
    }
}

我使用的是 Windows 8.1 和 ENTERPRISE 2.2.0_M02,运行 bin\Neo4j.bat 时出现错误。

C:\Users\user\Dropbox\MyDBs\neo4j\dbmusicovery3>bin\Neo4j.bat
    2015-06-15 23:14:58.889+0000 INFO  [API] Setting startup timeout to: 120000ms based on 120000
    2015-06-15 23:15:05.397+0000 INFO  [API] Successfully started database
    2015-06-15 23:15:05.477+0000 INFO  [API] Starting HTTP on port :7474 with 4 threads available
    2015-06-15 23:15:05.724+0000 INFO  [API] Enabling HTTPS on port :7473
    2015-06-15 23:15:05.856+0000 INFO  [API] Mounted REST API at: /db/manage
    2015-06-15 23:15:05.875+0000 INFO  [API] Mounted unmanaged extension [neo4j.unmanaged] at [/examples/unmanaged]
    01:15:05.894 [main] INFO  org.eclipse.jetty.util.log - Logging initialized @8256ms
    2015-06-15 23:15:05.956+0000 INFO  [API] Mounting static content at [/webadmin] from [webadmin-html]
    2015-06-15 23:15:06.015+0000 INFO  [API] Mounting static content at [/browser] from [browser]
    01:15:06.019 [main] INFO  org.eclipse.jetty.server.Server - jetty-9.2.1.v20140609
    01:15:06.065 [main] INFO  o.e.j.server.handler.ContextHandler - Started o.e.j.s.h.MovedContextHandler@3827eac9{/,null,AVAILABLE}
    01:15:06.206 [main] INFO  o.e.j.w.StandardDescriptorProcessor - NO JSP Support for /webadmin, did not find org.apache.jasper.servlet.JspServlet
    01:15:06.226 [main] INFO  o.e.j.server.handler.ContextHandler - Started o.e.j.w.WebAppContext@2aea41c2{/webadmin,jar:file:/C:/Users/user/Dropbox/MyDBs/neo4j/dbmusico
    very3/system/lib/neo4j-server-2.2.0-M02-static-web.jar!/webadmin-html,AVAILABLE}
    01:15:06.764 [main] WARN  /examples/unmanaged - unavailable
com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.
...
... FAILED o.e.j.s.ServletContextHandler@1f7bd4dd{/examples/unmanaged,null,STARTING}:
...

一些日志:

juin 16, 2015 9:51:26 AM com.sun.jersey.api.core.PackagesResourceConfig init
INFOS: Scanning for root resource and provider classes in the packages:
  neo4j.unmanaged
juin 16, 2015 9:51:26 AM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFOS: Initiating Jersey application, version 'Jersey: 1.18.1 02/19/2014 03:28 AM'
juin 16, 2015 9:51:26 AM com.sun.jersey.server.impl.application.RootResourceUriRules <init>
GRAVE: The ResourceConfig instance does not contain any root resource classes.

JAR 的快速 jar:

C:\...\plugins>jar tf myapp.jar
META-INF/MANIFEST.MF
pom.xml
.project
org/neo4j/examples/server/unmanaged/AppTest.class
org/neo4j/examples/server/unmanaged/HelloWorldResource.class
target/test-classes/org/neo4j/examples/server/unmanaged/AppTest.class
.classpath

【问题讨论】:

  • 我也遇到了同样的问题。你解决了吗?
  • 遇到同样的问题...有人知道如何解决吗?

标签: java neo4j


【解决方案1】:

JAR 文件似乎有问题。我已经在 localhost:7474 (Windows 8.1) 和 AWS EC2 (Ubuntu 14.04) 上测试了 dmontag/neo4j-unmanaged-extension-template,它工作正常。因此,我会尽量坚持这个模板。顺便说一句,不是“curl http://localhost:7474/example/helloworld”而是“curl http://localhost:7474/example/service/helloworld”,别忘了授权标头curl -H "Authorization: Basic &lt;Base64 of user:password&gt;"curl -u ":&lt;token&gt;"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-12
    • 1970-01-01
    • 2011-08-31
    • 1970-01-01
    相关资源
    最近更新 更多