从grails应用程序加载Neo4j时出错 [英] Error loading Neo4j from grails app

查看:104
本文介绍了从grails应用程序加载Neo4j时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

 将org.codehaus.groovy.grails.commons.ConfigurationHolder导入为CH; 
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;

//将您的Spring DSL代码放在这里
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启动时,我收到以下消息:

  |运行Grails应用程序
物理内存:7987MB,堆大小:455MB
|错误2012-11-02 11:34:48,597 [pool-5-thread-1]错误spring.GrailsRuntimeConfigurator - [RuntimeConfiguration]无法从resources.groovy
加载bean消息:未能转换org.neo4j.kernel .InternalAbstractGraphDatabase $ DefaultKernelExtensionLoader @ 2116b32从NONE到STOPPED
行|方法
- >> 388 | init in org.neo4j.kernel.lifecycle.LifeSupport $ LifecycleInstance
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 82 | init中的org.neo4j.kernel.lifecycle.LifeSupport
| 116 |开始。 。 。 。 。 。 。 。 。 。在''
|中227 |在org.neo4j.kernel.InternalAbstractGraphDatabase
|运行79 | < INIT> 。 。 。 。 。 。 。 。 。在org.neo4j.kernel.EmbeddedGraphDatabase
|中70 | org.neo4j.graphdb.factory.GraphDatabaseFactory中的newDatabase $ 1
| 205 | newGraphDatabase。 。 。 。在org.neo4j.graphdb.factory.GraphDatabaseBuilder
|中21 | getGraph的资源
| 8 | doCall。 。 。 。 。 。 。 。 。在资源$ _run_closure1
|中736 |在grails.spring.BeanBuilder
|中使用invokeBeanDefiningClosure 569 |豆 。 。 。 。 。 。 。 。 。 。在''
|中303 |在java.util.concurrent.FutureTask $ Sync
|中的innerRun 138 |跑 。 。 。 。 。 。 。 。 。 。 。在java.util.concurrent.FutureTask
|中886 | java.util.concurrent.ThreadPoolExecutor中的runTask $ Worker
| 908 |跑 。 。 。 。 。 。 。 。 。 。 。在''
^ 619 |在java.lang.Thread中运行
由NoClassDefFoundError引发:org / apache / lucene / util /版本
- >> 113 | < clinit> in org.neo4j.index.impl.lucene.LuceneDataSource $ b $ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 72 |在org.neo4j.index.lucene.LuceneIndexProvider
|中加载1171 | org.neo4j.kernel.InternalAbstractGraphDatabase中的loadIndexImplementations $ DefaultKernelExtensionLoader
| 1143 | init'in''
| 382 |在里面 。 。 。 。 。 。 。 。 。 。 in org.neo4j.kernel.lifecycle.LifeSupport $ LifecycleInstance
| 82 | init中的org.neo4j.kernel.lifecycle.LifeSupport
| 116 |开始。 。 。 。 。 。 。 。 。 。在''
|中227 |在org.neo4j.kernel.InternalAbstractGraphDatabase
|运行79 | < INIT> 。 。 。 。 。 。 。 。 。在org.neo4j.kernel.EmbeddedGraphDatabase
|中70 | org.neo4j.graphdb.factory.GraphDatabaseFactory中的newDatabase $ 1
| 205 | newGraphDatabase。 。 。 。在org.neo4j.graphdb.factory.GraphDatabaseBuilder
|中21 | getGraph的资源
| 8 | doCall。 。 。 。 。 。 。 。 。在资源$ _run_closure1
|中736 |在grails.spring.BeanBuilder
|中使用invokeBeanDefiningClosure 569 |豆 。 。 。 。 。 。 。 。 。 。在''
|中303 |在java.util.concurrent.FutureTask $ Sync
|中的innerRun 138 |跑 。 。 。 。 。 。 。 。 。 。 。在java.util.concurrent.FutureTask
|中886 | java.util.concurrent.ThreadPoolExecutor中的runTask $ Worker
| 908 |跑 。 。 。 。 。 。 。 。 。 。 。在''
^ 619 |在java.lang.Thread中运行
由ClassNotFoundException引起:org.apache.lucene.util.Version
- >> 156 | findClass in org.codehaus.groovy.tools.RootLoader
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 307 | java.lang.ClassLoader中的loadClass
| 128 | loadClass。 。 。 。 。 。 。 。 in org.codehaus.groovy.tools.RootLoader
| 248 | java.lang.ClassLoader中的loadClass
| 113 | < clinit> 。 。 。 。 。 。 。 。 in org.neo4j.index.impl.lucene.LuceneDataSource
| 72 |在org.neo4j.index.lucene.LuceneIndexProvider
|中加载1171 | org.neo4j.kernel.InternalAbstractGraphDatabase中的loadIndexImplementations $ DefaultKernelExtensionLoader
| 1143 | init'in''
| 382 |在里面 。 。 。 。 。 。 。 。 。 。 in org.neo4j.kernel.lifecycle.LifeSupport $ LifecycleInstance
| 82 | init中的org.neo4j.kernel.lifecycle.LifeSupport
| 116 |开始。 。 。 。 。 。 。 。 。 。在''
|中227 |在org.neo4j.kernel.InternalAbstractGraphDatabase
|运行79 | < INIT> 。 。 。 。 。 。 。 。 。在org.neo4j.kernel.EmbeddedGraphDatabase
|中70 | org.neo4j.graphdb.factory.GraphDatabaseFactory中的newDatabase $ 1
| 205 | newGraphDatabase。 。 。 。在org.neo4j.graphdb.factory.GraphDatabaseBuilder
|中21 | getGraph的资源
| 8 | doCall。 。 。 。 。 。 。 。 。在资源$ _run_closure1
|中736 |在grails.spring.BeanBuilder
|中使用invokeBeanDefiningClosure 569 |豆 。 。 。 。 。 。 。 。 。 。在''
|中303 |在java.util.concurrent.FutureTask $ Sync
|中的innerRun 138 |跑 。 。 。 。 。 。 。 。 。 。 。在java.util.concurrent.FutureTask
|中886 | java.util.concurrent.ThreadPoolExecutor中的runTask $ Worker
| 908 |跑 。 。 。 。 。 。 。 。 。 。 。在''
^ 619 |在java.lang.Thread中运行

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

更新

BuildConfig.groovy。大多数股票; mavenLocal()未注释; hibernate已移除。

  grails.servlet.version =2.5//根据目标容器符合性(2.5或3.0) b $ b 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 = {
//继承Grails的默认依赖关系
inherits(global ){
//取消注释以禁用ehcache
//排除'ehcache'
}
日志warn//常春藤解析器的日志级别,'error','warn ','info','debug'或'verbose'
checksums true //是否验证校验和解析
$ b存储库{
inherits true //是否继承存储库定义来自插件
grailsPlugins()
grailsHome()
grailsCentral()
mavenCentral()



//取消注释以启用远程依赖关系解析公共Maven仓库
// mavenCentral()
mavenLocal()
// mavenRepohttp://snapshots.repository.codehaus.org
// mavenRepohttp:/ /repository.codehaus.org
// mavenRepohttp://download.java.net/maven/2/
// mavenRepohttp://repository.jboss.com/maven2/
}
依赖关系{
//在'构建','编译','运行时','测试'或'提供的'范围下指定依赖关系。
$ b // runtime'mysql:mysql-connector-java:5.1.16'
}

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

//取消注释这些(或添加新的)以启用额外的资源能力
//运行时:压缩资源:1.0
//运行时:cached-resources:1.0
//运行时:yui-minify-resources:0.1.4

build:tomcat:$ grailsVersion

}


解决方案

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

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


I am using Grails 2.0.1 and Neo4J 1.8, and would like to instantiate a Neo4j database in my spring resources file like this:

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;
}

My BuildConfig.groovy file has mavenLocal() enabled, and I have the Lucene 3.5 core library in my path.

When I run my application, I get the following messages as Neo4j is started:

| 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

I had been able to load this database from other applications yesterday. In searching for a solution to this problem, I came across this discussion on the Neo4j Google group. The implication there is that this problem should have already been solved in my version of Neo4j (1.8, downloaded last week.) What should I try next?

UPDATE

BuildConfig.groovy. Mostly stock; mavenLocal() uncommented; hibernate removed.

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"
    }
}

解决方案

add to your grails-app/conf/BuildConfig.groovy's dependency section:

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

这篇关于从grails应用程序加载Neo4j时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆