NetBeans maven项目中的Neo4j 2.1.6 Hello World

时间:2021-05-29 18:03:55

My configuration is : * OS : Windows 8 * Neo4j community 2.1.6 (latest stable) * IDE : NetBeans 8.0.2 (latest) * java -version

我的配置是:* OS: Windows 8 * Neo4j社区2.1.6(最新稳定)* IDE: NetBeans 8.0.2(最新)* java -version

java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
  1. I created a maven Java project and put the Hello world example provided by Neo4j guys for the appropriate version.
  2. 我创建了一个maven Java项目,并将Neo4j提供的Hello world示例用于适当的版本。
  3. I added all the main dependencies (neo4j-kernel 2.1.6) and maven transitively added the remaining dependencies.
  4. 我添加了所有的主要依赖项(neo4j-kernel 2.1.6)和maven临时添加了其余的依赖项。
  5. Build process is 100% OK
  6. 构建过程是100%没问题的

I still get a the following exception at runtime :

在运行时,我仍然得到以下异常:

Exception in thread "main" java.lang.RuntimeException: Error starting org.neo4j.kernel.EmbeddedGraphDatabase, C:\Users\Mehdy\Documents\NetBeansProjects\neo4j-example\target\neo4j-hello-db

I looked in the stack trace and I found $EmbeddedGraphDatabase constructor is deprecated.

我查看了堆栈跟踪,发现不赞成使用$EmbeddedGraphDatabase构造函数。

Here's the whole console output :

这是整个控制台输出:

------------------------------------------------------------------------
Building neo4j-example 1.0-SNAPSHOT
------------------------------------------------------------------------

--- exec-maven-plugin:1.2.1:exec (default-cli) @ neo4j-example ---
Exception in thread "main" java.lang.RuntimeException: Error starting org.neo4j.kernel.EmbeddedGraphDatabase, C:\Users\Mehdy\Documents\NetBeansProjects\neo4j-example\target\neo4j-hello-db
    at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:366)
    at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:59)
    at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:91)
    at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:181)
    at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:71)
    at com.lirmm.neo4j.example.Hello.createDb(Hello.java:51)
    at com.lirmm.neo4j.example.Hello.main(Hello.java:41)
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.impl.transaction.XaDataSourceManager@53f65459' was successfully initialized, but failed to start. Please see attached cause exception.
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:513)
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:115)
    at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:343)
    ... 6 more
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.impl.nioneo.xa.NeoStoreXaDataSource@4d95d2a2' was successfully initialized, but failed to start. Please see attached cause exception.
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:513)
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:115)
    at org.neo4j.kernel.impl.transaction.XaDataSourceManager.start(XaDataSourceManager.java:164)
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:507)
    ... 8 more
Caused by: java.lang.IllegalArgumentException: No schema index provider org.neo4j.kernel.api.index.SchemaIndexProvider found. Kernel extensions available on classpath: 

Class path entries:
  C:\Users\Mehdy\Documents\NetBeansProjects\neo4j-example\target\classes
  C:\Users\Mehdy\.m2\repository\org\neo4j\neo4j-kernel\2.1.6\neo4j-kernel-2.1.6.jar
  C:\Users\Mehdy\.m2\repository\org\neo4j\neo4j-primitive-collections\2.1.6\neo4j-primitive-collections-2.1.6.jar
  C:\Users\Mehdy\.m2\repository\org\apache\geronimo\specs\geronimo-jta_1.1_spec\1.1.1\geronimo-jta_1.1_spec-1.1.1.jar
    at org.neo4j.kernel.api.index.SchemaIndexProvider$2.select(SchemaIndexProvider.java:140)
    at org.neo4j.kernel.extension.KernelExtensions.resolveDependency(KernelExtensions.java:206)
    at org.neo4j.kernel.InternalAbstractGraphDatabase$DependencyResolverImpl.resolveDependency(InternalAbstractGraphDatabase.java:1524)
    at org.neo4j.kernel.impl.nioneo.xa.NeoStoreXaDataSource.start(NeoStoreXaDataSource.java:337)
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:507)
    ... 11 more
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 10.883s
Finished at: Wed Dec 10 12:55:47 CET 2014
Final Memory: 5M/72M
------------------------------------------------------------------------
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project neo4j-example: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project neo4j-example: Command execution failed.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Command execution failed.
    at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:362)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
Caused by: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
    at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:377)
    at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
    at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:610)
    at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:352)
    ... 21 more

Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

I don't think it's a dependency problem but the use of a deprecated method. How can I get rid of this code snippet and use something compliant neo4j 2.1.6 ?

我不认为这是一个依赖问题,而是不赞成使用方法。如何删除这个代码片段并使用符合标准的neo4j 2.1.6 ?

I tried different solutions found in SO, but still the same result. What should I do to make this work ?

我在SO中尝试了不同的解,但结果还是一样的。我该怎么做才能让它工作呢?

1 个解决方案

#1


2  

You're missing a dependency. Neo4j requires a schema index provider which is located in neo4j-lucene-index. Since it's an exchangeable component (you can write your own index provider) it's bundled in a separate artifact.

你失踪的依赖。Neo4j需要一个位于Neo4j -lucene-index中的模式索引提供程序。因为它是一个可交换的组件(您可以编写自己的索引提供程序),所以它被绑定到一个单独的工件中。

Amend your dependencies in pom.xml with:

在pom中修改依赖项。xml:

<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-lucene-index</artifactId>
    <version>2.1.6</version>
</dependency>

If you only want to have one single dependency for all neo4j stuff in your pom.xml use:

如果您只想对pom中的所有neo4j内容有一个单独的依赖关系。xml使用:

<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-community</artifactId>
    <version>2.1.6</version>
</dependency>

#1


2  

You're missing a dependency. Neo4j requires a schema index provider which is located in neo4j-lucene-index. Since it's an exchangeable component (you can write your own index provider) it's bundled in a separate artifact.

你失踪的依赖。Neo4j需要一个位于Neo4j -lucene-index中的模式索引提供程序。因为它是一个可交换的组件(您可以编写自己的索引提供程序),所以它被绑定到一个单独的工件中。

Amend your dependencies in pom.xml with:

在pom中修改依赖项。xml:

<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-lucene-index</artifactId>
    <version>2.1.6</version>
</dependency>

If you only want to have one single dependency for all neo4j stuff in your pom.xml use:

如果您只想对pom中的所有neo4j内容有一个单独的依赖关系。xml使用:

<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-community</artifactId>
    <version>2.1.6</version>
</dependency>