1

我正在尝试在 Neo4J 之上构建一个 Web 应用程序 - 1.9.2 我编写了一个 servlet 程序,它将连接到 neo4j 并以 HTML 格式显示员工姓名 - 选择框。从选择框中,用户将单击一个名称,我想使用该选定的值进行进一步检索,方法是将其传递给CQL - where

从选择框中单击一个值一切正常,但是一旦我们单击其中一个名称并提交,它就会显示null并引发错误。

我的 servlet 代码是 -

public void service(HttpServletRequest request, HttpServletResponse res) throws     ServletException, IOException {

    try {

        PrintWriter out = res.getWriter();
        res.setContentType("text/html");
        String[] collectNode;
        out.println("<center>Welcome</center>");
        NeoWrapper nw = new NeoWrapper();
        nw.GetNeoData();
        collectNode=nw.getNodes();
        out.println("<form action=\"NeoServlet\" method=\"POST\">");
        out.println("<select name=\"nodes\">");
        for(int i=0;i<collectNode.length;i++)
        {
            out.println("<option value='" + collectNode[i] + "'>"+collectNode[i]+"</option>");
        }
        out.println("</select>");
        out.println("<button type=\"submit\">Submit</button>");
        out.println("</form>");
        String element = request.getParameter("nodes");
        out.println(element);

    }
    catch(Exception te) {
        te.printStackTrace();
    }
}

这里out.println(element)显示null和它显示的更多错误如下:

java.lang.RuntimeException: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.StoreLockerLifecycleAdapter@6fa37fac' was successfully initialized, but failed to start. Please see attached cause exception.
at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:281)
at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:106)
at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:88)
at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:207)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:69)
at com.sampleServlet.CaseNeo4J.connect(CaseNeo4J.java:53)
at com.sampleServlet.NeoWrapper.GetNeoData(NeoWrapper.java:9)
at com.sampleServlet.NeoServlet.service(NeoServlet.java:23)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.jav     a:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:     589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component       'org.neo4j.kernel.StoreLockerLifecycleAdapter@6fa37fac' was successfully initialized, but      failed to start. Please see attached cause exception.
at      org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:497)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:104)
at    org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:259)
... 24 more
Caused by: org.neo4j.kernel.StoreLockException: Could not create lock file
at org.neo4j.kernel.StoreLocker.checkLock(StoreLocker.java:74)
at      org.neo4j.kernel.StoreLockerLifecycleAdapter.start(StoreLockerLifecycleAdapter.java:40)
at     org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:491)
... 26 more
java.lang.NullPointerException
at com.sampleServlet.CaseNeo4J.storeNodes(CaseNeo4J.java:86)
at com.sampleServlet.NeoWrapper.getNodes(NeoWrapper.java:18)
at com.sampleServlet.NeoServlet.service(NeoServlet.java:24)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at     org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.jav    a:305)
at      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at     org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at     org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at com.sampleServlet.NeoServlet.service(NeoServlet.java:27)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.jav     a:305)
at      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:     589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)**

由于我对 neo4j 很陌生,所以没有太多想法。这个错误是怎么回事?

4

2 回答 2

1

Connection to Neo4j should be disconnected i.e. shutDown() properly. It will work.

于 2013-09-12T08:53:46.877 回答
1
Caused by: org.neo4j.kernel.StoreLockException: Could not create lock file

表示已经有另一个 neo4j 实例正在运行。确保您不要尝试为每个线程启动一个新的服务器实例,并且您没有运行任何正在访问您的数据库的工具(即 neoclipse)。

编辑:使用 servlet 输出 html 通常不是最好的主意。

于 2013-09-12T07:22:17.437 回答