2014-09-18 25 views
5

Tôi muốn kết hợp Neo4j 2.1.3 và Grails 2.4.2, tốt nhất là sử dụng plugin GORM neo4j hoặc sử dụng Spring4Data-Neo4j.để tìm kiếm cấu hình neo4j và grails đang hoạt động

Tôi đã cố gắng tự khai thác thông qua tài liệu plugin neo4j: 2.0.0-M02 và ví dụ được lưu trữ tại blog Stefan Armbrusters.

Tôi muốn sử dụng kết nối kiểu REST cho cá thể cơ sở dữ liệu NEO4J. Ví dụ cơ sở dữ liệu đang chạy trên máy chủ cục bộ, tôi có thể truy vấn nó bằng giao diện web.

Tôi đang tìm cấu hình hoạt động của cả hai sản phẩm, để tôi có thể thực sự khám phá việc sử dụng neo4j và đồ thị.

Sau nhiều lần thử và lỗi, tôi đã sửa đổi một cấu hình Grails đang hoạt động, với các gợi ý mà tôi tìm thấy trong tài liệu và ví dụ. Than ôi - nó không.

Tôi đã đăng cấu hình Grails của mình bên dưới. Nó thực sự khó khăn để tìm ra những tùy chọn cấu hình hiện đang thực sự cần thiết cho một biến thể kết nối cụ thể (nhúng, phần còn lại, vv) - ví dụ và tài liệu dường như không phù hợp với nhau. Ví dụ. ví dụ BuildConfig.groovy không bao gồm neo4j GORM plugin, vì dòng tương ứng là nhận xét ra:

// compile ":neo4j:2.0.0-M02" 

Lưu ý: Tôi không muốn rên rỉ và than phiền - Tôi chỉ nêu kinh nghiệm của tôi như một người mới bắt đầu trong miền neo4j và grails - trạng thái hiện tại của tài liệu/ví dụ liên quan đến trình điều khiển này làm cho nó khá khó và không hấp dẫn để "cho nó chỉ là một thử nhanh và xem nếu điều này thực sự là một số công cụ mát mẻ".

Cấu hình Grails được đưa ra dưới đây là kết quả của vài giờ dùng thử và lỗi - có thể chứa các tùy chọn không cần thiết (cài đặt trình điều khiển JDBC ?, tôi có cần url JDBC không nếu tôi sử dụng biến thể kết nối "nghỉ ngơi". vẫn còn đúng cách để cấu hình một kết nối kiểu REST hoặc bây giờ tôi phải sử dụng một URL JDBC cụ thể) - xin lỗi vì sự lộn xộn này.

Nếu tôi khởi động ứng dụng Grails tôi nhận được lỗi sau:

Loading Grails 2.4.2 
|Configuring classpathSep 14, 2014 5:23:55 PM java.util.prefs.WindowsPreferences <init> 
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5. 

. 
|Environment set to development 
................................. 
|Packaging Grails application 
................................. 
|Running Grails application 
Sep 14, 2014 5:24:11 PM org.restlet.ext.httpclient.HttpClientHelper start 
INFO: Starting the Apache HTTP client 
Sep 14, 2014 5:24:12 PM org.restlet.ext.httpclient.HttpClientHelper start 
INFO: Starting the Apache HTTP client 
Sep 14, 2014 5:24:12 PM org.restlet.ext.httpclient.HttpClientHelper start 
INFO: Starting the Apache HTTP client 
Sep 14, 2014 5:24:12 PM org.restlet.ext.httpclient.HttpClientHelper start 
INFO: Starting the Apache HTTP client 
Sep 14, 2014 5:24:12 PM org.restlet.ext.httpclient.HttpClientHelper start 
INFO: Starting the Apache HTTP client 
Sep 14, 2014 5:24:12 PM org.restlet.ext.httpclient.HttpClientHelper start 
INFO: Starting the Apache HTTP client 
Sep 14, 2014 5:24:12 PM org.restlet.ext.httpclient.HttpClientHelper start 
INFO: Starting the Apache HTTP client 
Sep 14, 2014 5:24:12 PM org.restlet.ext.httpclient.HttpClientHelper start 
INFO: Starting the Apache HTTP client 
Sep 14, 2014 5:24:12 PM org.restlet.ext.httpclient.HttpClientHelper start 
INFO: Starting the Apache HTTP client 
Sep 14, 2014 5:24:12 PM org.restlet.ext.httpclient.HttpClientHelper start 
INFO: Starting the Apache HTTP client 
Sep 14, 2014 5:24:12 PM org.restlet.ext.httpclient.HttpClientHelper stop 
INFO: Stopping the HTTP client 
Sep 14, 2014 5:24:12 PM org.restlet.ext.httpclient.HttpClientHelper stop 
INFO: Stopping the HTTP client 
Sep 14, 2014 5:24:12 PM org.restlet.ext.httpclient.HttpClientHelper stop 
INFO: Stopping the HTTP client 
Sep 14, 2014 5:24:12 PM org.restlet.ext.httpclient.HttpClientHelper stop 
INFO: Stopping the HTTP client 
Sep 14, 2014 5:24:12 PM org.restlet.ext.httpclient.HttpClientHelper stop 
INFO: Stopping the HTTP client 
Sep 14, 2014 5:24:12 PM org.restlet.ext.httpclient.HttpClientHelper stop 
INFO: Stopping the HTTP client 
Sep 14, 2014 5:24:12 PM org.restlet.ext.httpclient.HttpClientHelper stop 
INFO: Stopping the HTTP client 
Sep 14, 2014 5:24:12 PM org.restlet.ext.httpclient.HttpClientHelper stop 
INFO: Stopping the HTTP client 
Sep 14, 2014 5:24:12 PM org.restlet.ext.httpclient.HttpClientHelper stop 
INFO: Stopping the HTTP client 
Sep 14, 2014 5:24:12 PM org.restlet.ext.httpclient.HttpClientHelper stop 
INFO: Stopping the HTTP client 
Sep 14, 2014 5:24:13 PM org.restlet.ext.httpclient.HttpClientHelper start 
INFO: Starting the Apache HTTP client 
Error | 
2014-09-14 17:24:13,065 [localhost-startStop-1] ERROR context.GrailsContextLoaderListener - Error initializing the application: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'neo4jTransactionManager': Cannot resolve reference to bean 'neo4jDatastore' while setting bean property 'datastore'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'neo4jDatastore': FactoryBean threw exception on object creation; nested exception is java.lang.RuntimeException: java.sql.SQLException: Commit called on auto-committed connection 
Message: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'neo4jTransactionManager': Cannot resolve reference to bean 'neo4jDatastore' while setting bean property 'datastore'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'neo4jDatastore': FactoryBean threw exception on object creation; nested exception is java.lang.RuntimeException: java.sql.SQLException: Commit called on auto-committed connection 
    Line | Method 
->> 262 | run  in java.util.concurrent.FutureTask 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor 
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker 
^ 745 | run  in java.lang.Thread 
Caused by BeanCreationException: Error creating bean with name 'neo4jTransactionManager': Cannot resolve reference to bean 'neo4jDatastore' while setting bean property 'datastore'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'neo4jDatastore': FactoryBean threw exception on object creation; nested exception is java.lang.RuntimeException: java.sql.SQLException: Commit called on auto-committed connection 
->> 262 | run  in java.util.concurrent.FutureTask 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor 
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker 
^ 745 | run  in java.lang.Thread 
Caused by BeanCreationException: Error creating bean with name 'neo4jDatastore': FactoryBean threw exception on object creation; nested exception is java.lang.RuntimeException: java.sql.SQLException: Commit called on auto-committed connection 
->> 262 | run  in java.util.concurrent.FutureTask 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor 
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker 
^ 745 | run  in java.lang.Thread 
Caused by RuntimeException: java.sql.SQLException: Commit called on auto-committed connection 
->> 100 | commit in org.grails.datastore.gorm.neo4j.engine.JdbcCypherEngine 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|  91 | setupIndexing in org.grails.datastore.gorm.neo4j.Neo4jDatastore 
|  67 | afterPropertiesSet in  '' 
|  50 | getObject in org.grails.datastore.gorm.neo4j.bean.factory.Neo4jDatastoreFactoryBean 
| 262 | run . . . in java.util.concurrent.FutureTask 
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor 
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker 
^ 745 | run  in java.lang.Thread 
Caused by SQLException: Commit called on auto-committed connection 
->> 200 | commit in org.neo4j.jdbc.internal.Neo4jConnection 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|  97 | commit in org.grails.datastore.gorm.neo4j.engine.JdbcCypherEngine 
|  91 | setupIndexing in org.grails.datastore.gorm.neo4j.Neo4jDatastore 
|  67 | afterPropertiesSet in  '' 
|  50 | getObject in org.grails.datastore.gorm.neo4j.bean.factory.Neo4jDatastoreFactoryBean 
| 262 | run  in java.util.concurrent.FutureTask 
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor 
| 615 | run  in java.util.concurrent.ThreadPoolExecutor$Worker 
^ 745 | run . . . in java.lang.Thread 
Error | 
Forked Grails VM exited with error 

BuildConfig.groovy ----------------------- -----------------------------

grails.servlet.version = "3.0" // 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.work.dir = "target/work" 
grails.project.target.level = 1.6 
grails.project.source.level = 1.6 
//grails.project.war.file = "target/${appName}-${appVersion}.war" 

grails.project.fork = [ 
    // configure settings for compilation JVM, note that if you alter the Groovy version forked compilation is required 
    // compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true], 

    // configure settings for the test-app JVM, uses the daemon by default 
    test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true], 
    // configure settings for the run-app JVM 
    run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false], 
    // configure settings for the run-war JVM 
    war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false], 
    // configure settings for the Console UI JVM 
    console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256] 
] 

grails.project.dependency.resolver = "maven" // or ivy 
grails.project.dependency.resolution = { 
    // inherit Grails' default dependencies 
    inherits("global") { 

     excludes 'xml-apis', 'netty', 'stax-api', 'slf4j-jdk14','log4j-over-slf4j', 'logback-classic' 

     // specify dependency exclusions here; for example, uncomment this 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 
    legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility 

    repositories { 
     inherits true // Whether to inherit repository definitions from plugins 

     grailsPlugins() 
     grailsHome() 
     mavenLocal() 
     grailsCentral() 
     mavenCentral() 
     // uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories 
     //mavenRepo "http://repository.codehaus.org" 
     //mavenRepo "http://download.java.net/maven/2/" 
     //mavenRepo "http://repository.jboss.com/maven2/" 
     // mavenRepo "http://repo2.maven.org/maven2/" 

     mavenRepo 'http://m2.neo4j.org/content/repositories/releases/' 

    } 

    neo4jVersion="2.1.3" 

    dependencies { 
     // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g. 
     // runtime 'mysql:mysql-connector-java:5.1.29' 
     // runtime 'org.postgresql:postgresql:9.3-1101-jdbc41' 


     // test "org.grails:grails-datastore-test-support:1.0-grails-2.4" 

     compile("org.neo4j:neo4j-community:$neo4jVersion") 


     // add graphviz capabilities 
     compile(group:"org.neo4j", name:"neo4j-graphviz", version: neo4jVersion) 
     runtime (group:"org.neo4j", name:"neo4j-shell", version: neo4jVersion) 

     // uncomment following line if type=rest is used in DataSource.groovy 
     // runtime "org.neo4j:neo4j-rest-graphdb:1.9" 
     runtime "org.neo4j:neo4j-rest-graphdb:2.0.1" 

    } 

    plugins { 
     // plugins for the build system only 
     build ":tomcat:7.0.54" 

     // plugins for the compile step 
     compile ":scaffolding:2.1.2" 
     // compile ':cache:1.1.7' 
     compile ":asset-pipeline:1.8.11" 

     // plugins needed at runtime but not for compilation 
     // runtime ":hibernate4:4.3.5.4" // or ":hibernate:3.6.10.16" 
     // runtime ":database-migration:1.4.0" 
     runtime ":jquery:1.11.1" 

     compile ":neo4j:2.0.0-M02" 


     // Uncomment these to enable additional asset-pipeline capabilities 
     //compile ":sass-asset-pipeline:1.7.4" 
     //compile ":less-asset-pipeline:1.7.0" 
     //compile ":coffee-asset-pipeline:1.7.0" 
     //compile ":handlebars-asset-pipeline:1.3.0.3" 
    } 
} 

DataSource.groovy --------- ------------------------------------

dataSource { 
    pooled = true 
    // jmxExport = true 
    // driverClassName = "org.h2.Driver" 
    driverClassName = "org.neo4j.jdbc.Driver" 
    // username = "sa" 
    // password = "" 
    url = 'jdbc:neo4j://localhost:7474' 
} 


hibernate { 
    cache.use_second_level_cache = true 
    cache.use_query_cache = false 
// cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' // Hibernate 3 
    cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4 
    singleSession = true // configure OSIV singleSession mode 
} 


neo4j { 
    // url = "jdbc:neo4j:instance:dummy" 
    // type = "rest" 
    type="rest" 
    location = "http://localhost:7474/db/data/" 
    //url = "jdbc:neo4j://localhost:7474" 
    // url = 'jdbc:neo4j:instance://localhost:7474' 
} 

Cảm ơn bạn đã giúp đỡ!

+0

Bạn đã bao giờ quản lý để giải quyết vấn đề này @ bernd-h? –

+0

Thật không may, không. –

+0

@BerndH - Còn bây giờ thì sao ...? Đang cố gắng để bắt đầu một dự án mới là tốt, điều này thực sự gây phiền nhiễu ... – bdparrish

Trả lời

0

Tôi đang sử dụng Grails 2.3.9, nhưng tôi đã từ bỏ việc này và kết thúc bằng cách viết một dịch vụ bằng cách sử dụng một thể hiện của HttpBuilder để tương tác với giao diện REST API của nó. Vui vẻ chia sẻ một số nguồn.

Các vấn đề liên quan