【问题标题】:Error loading Neo4j from grails app从 grails 应用程序加载 Neo4j 时出错
【发布时间】:2012-11-02 18:51:02
【问题描述】:

我正在使用 Grails 2.0.1 和 Neo4J 1.8,并希望在我的 spring 资源文件中实例化 Neo4j 数据库,如下所示:

import org.codehaus.groovy.grails.commons.ConfigurationHolder as CH;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;

// Place your Spring DSL code here
beans = {
    GraphDatabaseService db = getGraph();
    enronService(com.fxpal.neo4j.EnronService) {
        graph = db;
        index = db.index()
            .getNodeAutoIndexer()
            .getAutoIndex();
    }
}

protected GraphDatabaseService getGraph() {
    String graphDBName = CH.config.enron.graphdb ?: "../databases/enrontest";
    GraphDatabaseService db = new GraphDatabaseFactory().
        newEmbeddedDatabaseBuilder( graphDBName ).
        setConfig( GraphDatabaseSettings.node_keys_indexable, "emailID,address" ).
        setConfig( GraphDatabaseSettings.node_auto_indexing, "true" ).
        setConfig( GraphDatabaseSettings.dump_configuration, "true").
        newGraphDatabase();

    return db;
}

我的BuildConfig.groovy 文件启用了mavenLocal(),并且我的路径中有Lucene 3.5 核心库。

当我运行我的应用程序时,我在 Neo4j 启动时收到以下消息:

| Running Grails application
Physical mem: 7987MB, Heap size: 455MB
| Error 2012-11-02 11:34:48,597 [pool-5-thread-1] ERROR spring.GrailsRuntimeConfigurator  - [RuntimeConfiguration] Unable to load beans from resources.groovy
Message: Failed to transition org.neo4j.kernel.InternalAbstractGraphDatabase$DefaultKernelExtensionLoader@2116b32 from NONE to STOPPED
   Line | Method
->> 388 | init                      in org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    82 | init                      in org.neo4j.kernel.lifecycle.LifeSupport
|   116 | start . . . . . . . . . . in     ''
|   227 | run                       in org.neo4j.kernel.InternalAbstractGraphDatabase
|    79 | <init> . . . . . . . . .  in org.neo4j.kernel.EmbeddedGraphDatabase
|    70 | newDatabase               in org.neo4j.graphdb.factory.GraphDatabaseFactory$1
|   205 | newGraphDatabase . . . .  in org.neo4j.graphdb.factory.GraphDatabaseBuilder
|    21 | getGraph                  in resources
|     8 | doCall . . . . . . . . .  in resources$_run_closure1
|   736 | invokeBeanDefiningClosure in grails.spring.BeanBuilder
|   569 | beans . . . . . . . . . . in     ''
|   303 | innerRun                  in java.util.concurrent.FutureTask$Sync
|   138 | run . . . . . . . . . . . in java.util.concurrent.FutureTask
|   886 | runTask                   in java.util.concurrent.ThreadPoolExecutor$Worker
|   908 | run . . . . . . . . . . . in     ''
^   619 | run                       in java.lang.Thread
Caused by NoClassDefFoundError: org/apache/lucene/util/Version
->> 113 | <clinit>                  in org.neo4j.index.impl.lucene.LuceneDataSource
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    72 | load                      in org.neo4j.index.lucene.LuceneIndexProvider
|   1171 | loadIndexImplementations  in org.neo4j.kernel.InternalAbstractGraphDatabase$DefaultKernelExtensionLoader
|   1143 | init                      in     ''
|   382 | init . . . . . . . . . .  in org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance
|    82 | init                      in org.neo4j.kernel.lifecycle.LifeSupport
|   116 | start . . . . . . . . . . in     ''
|   227 | run                       in org.neo4j.kernel.InternalAbstractGraphDatabase
|    79 | <init> . . . . . . . . .  in org.neo4j.kernel.EmbeddedGraphDatabase
|    70 | newDatabase               in org.neo4j.graphdb.factory.GraphDatabaseFactory$1
|   205 | newGraphDatabase . . . .  in org.neo4j.graphdb.factory.GraphDatabaseBuilder
|    21 | getGraph                  in resources
|     8 | doCall . . . . . . . . .  in resources$_run_closure1
|   736 | invokeBeanDefiningClosure in grails.spring.BeanBuilder
|   569 | beans . . . . . . . . . . in     ''
|   303 | innerRun                  in java.util.concurrent.FutureTask$Sync
|   138 | run . . . . . . . . . . . in java.util.concurrent.FutureTask
|   886 | runTask                   in java.util.concurrent.ThreadPoolExecutor$Worker
|   908 | run . . . . . . . . . . . in     ''
^   619 | run                       in java.lang.Thread
Caused by ClassNotFoundException: org.apache.lucene.util.Version
->> 156 | findClass                 in org.codehaus.groovy.tools.RootLoader
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   307 | loadClass                 in java.lang.ClassLoader
|   128 | loadClass . . . . . . . . in org.codehaus.groovy.tools.RootLoader
|   248 | loadClass                 in java.lang.ClassLoader
|   113 | <clinit> . . . . . . . .  in org.neo4j.index.impl.lucene.LuceneDataSource
|    72 | load                      in org.neo4j.index.lucene.LuceneIndexProvider
|   1171 | loadIndexImplementations  in org.neo4j.kernel.InternalAbstractGraphDatabase$DefaultKernelExtensionLoader
|   1143 | init                      in     ''
|   382 | init . . . . . . . . . .  in org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance
|    82 | init                      in org.neo4j.kernel.lifecycle.LifeSupport
|   116 | start . . . . . . . . . . in     ''
|   227 | run                       in org.neo4j.kernel.InternalAbstractGraphDatabase
|    79 | <init> . . . . . . . . .  in org.neo4j.kernel.EmbeddedGraphDatabase
|    70 | newDatabase               in org.neo4j.graphdb.factory.GraphDatabaseFactory$1
|   205 | newGraphDatabase . . . .  in org.neo4j.graphdb.factory.GraphDatabaseBuilder
|    21 | getGraph                  in resources
|     8 | doCall . . . . . . . . .  in resources$_run_closure1
|   736 | invokeBeanDefiningClosure in grails.spring.BeanBuilder
|   569 | beans . . . . . . . . . . in     ''
|   303 | innerRun                  in java.util.concurrent.FutureTask$Sync
|   138 | run . . . . . . . . . . . in java.util.concurrent.FutureTask
|   886 | runTask                   in java.util.concurrent.ThreadPoolExecutor$Worker
|   908 | run . . . . . . . . . . . in     ''
^   619 | run                       in java.lang.Thread

昨天我已经能够从其他应用程序加载这个数据库。在寻找这个问题的解决方案时,我在 Neo4j Google 组上遇到了这个discussion。这意味着这个问题应该已经在我的 Neo4j 版本(1.8,上周下载)中解决了。接下来我应该尝试什么?

更新

BuildConfig.groovy。主要是库存; mavenLocal() 未注释;休眠已移除。

grails.servlet.version = "2.5" // Change depending on target container compliance (2.5 or 3.0)
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.target.level = 1.6
grails.project.source.level = 1.6
//grails.project.war.file = "target/${appName}-${appVersion}.war"

grails.project.dependency.resolution = {
    // inherit Grails' default dependencies
    inherits("global") {
        // uncomment to disable ehcache
        // excludes 'ehcache'
    }
    log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
    checksums true // Whether to verify checksums on resolve

    repositories {
        inherits true // Whether to inherit repository definitions from plugins
        grailsPlugins()
        grailsHome()
        grailsCentral()
        mavenCentral()



        // uncomment these to enable remote dependency resolution from public Maven repositories
        //mavenCentral()
        mavenLocal()
       //mavenRepo "http://snapshots.repository.codehaus.org"
        //mavenRepo "http://repository.codehaus.org"
        //mavenRepo "http://download.java.net/maven/2/"
        //mavenRepo "http://repository.jboss.com/maven2/"
    }
    dependencies {
        // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.

        // runtime 'mysql:mysql-connector-java:5.1.16'
    }

    plugins {
//        runtime ":hibernate:$grailsVersion"
        runtime ":jquery:1.7.1"
        runtime ":resources:1.1.6"

        // Uncomment these (or add new ones) to enable additional resources capabilities
        //runtime ":zipped-resources:1.0"
        //runtime ":cached-resources:1.0"
        //runtime ":yui-minify-resources:0.1.4"

        build ":tomcat:$grailsVersion"
    }
}

【问题讨论】:

  • 请粘贴grails-app/conf/BuildConfig.groovy(尤其是依赖项部分)
  • 我已经添加了。它与默认值基本没有变化,除了我添加了 mavenLocal()。删除它并不能解决问题。

标签: grails neo4j grails-2.0


【解决方案1】:

添加到您的 grails-app/conf/BuildConfig.groovy 的依赖部分:

compile('org.neo4j:neo4j-community:1.8')

【讨论】:

  • 我很快就接受了答案:在大量下载后我得到了同样的错误
  • 您的$GRAILS_APP/lib 是空的吗?如果没有,请删除其内容。
  • 我有 neo4j 库。删除这些库后,1)我得到一堆编译器错误; 2)我仍然得到与以前相同的运行时错误。注意:我没有使用插件;我只想处理我自己从数据库中读取的数据。
  • 不知道...试图在我的机器上安装 git,但它不起作用。说它couldn't execute "D:\Program Files (x86)\Git\libexec\git-core\git-update-index.exe": no such file or directory。我没有 cigwyn,所以这可能是一个老鼠洞......
猜你喜欢
  • 2016-02-21
  • 2016-03-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-09-07
  • 2017-06-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多