用java远程连接到rexter
问题描述:
我想从我的本地机器上运行的java应用程序连接到泰坦数据库。我的Titan + Cassandra + Rexter安装在远程机器上运行。用java远程连接到rexter
我试图做这样
RexsterClient client = RexsterClientFactory.open("192.168.30.62");
List<Map<String, Object>> results = client.execute("g.v(1).map");
Map<String, Object> map = results.get(0);
System.out.println(map);
但trowing此异常
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:293)
at java.lang.Thread.run(Thread.java:744)
Caused by: com.tinkerpop.rexster.client.RexProException: An error occurred while processing the script for language [groovy]. All transactions across all graphs in the session have been concluded with failure: javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: g for class: Script4
at com.tinkerpop.rexster.client.RexsterClient.execute(RexsterClient.java:220)
at com.tinkerpop.rexster.client.RexsterClient.execute(RexsterClient.java:148)
at Titan.Titan.App.main(App.java:27)
... 6 more
[WARNING] thread Thread[Grizzly(1) SelectorRunner,5,Titan.Titan.App] was interrupted but is still alive after waiting at least 14993msecs
[WARNING] thread Thread[Grizzly(1) SelectorRunner,5,Titan.Titan.App] will linger despite being asked to die via interruption
[WARNING] thread Thread[Grizzly(2) SelectorRunner,5,Titan.Titan.App] will linger despite being asked to die via interruption
[WARNING] thread Thread[Grizzly(3) SelectorRunner,5,Titan.Titan.App] will linger despite being asked to die via interruption
[WARNING] thread Thread[Grizzly(4) SelectorRunner,5,Titan.Titan.App] will linger despite being asked to die via interruption
[WARNING] thread Thread[Grizzly(1),5,Titan.Titan.App] will linger despite being asked to die via interruption
[WARNING] NOTE: 5 thread(s) did not finish despite being asked to via interruption. This is not a problem with exec:java, it is a problem with the running code. Although not serious, it should be remedied.
[WARNING] Couldn't destroy threadgroup org.codehaus.mojo.exec.ExecJavaMojo$IsolatedThreadGroup[name=Titan.Titan.App,maxpri=10]
java.lang.IllegalThreadStateException
at java.lang.ThreadGroup.destroy(ThreadGroup.java:775)
at org.codehaus.mojo.exec.ExecJavaMojo.execute(ExecJavaMojo.java:328)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
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:108)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
此外,当我尝试使用Grimlin在rexter控制台,它抛出
An error occurred while processing the script for language [groovy]. All transactions across all graphs in the session have been concluded with failure: java.util.concurrent.ExecutionException: javax.script.ScriptException: javax.script.ScriptExcepion" groovy.lang.MissingpropertyException: No such property: g for class: Script1
我究竟做错了什么?
答
由于从我answer在小鬼用户邮件列表这个问题采取:
“G”需要绑定作为脚本引擎的可变莫名其妙:
List<Map<String, Object>> results =
client.execute("g=rexster.getGraph(\\"tinkergraph\\");g.v(1).map");
Map<String, Object> map = results.get(0);
System.out.println(map.get("name"));
通过向RexsterClientFactory传递一个附加的 参数,可以自动将图形绑定到“g”:
RexsterClient client = RexsterClientFactory.open("localhost","my-titan-graph")
其中在上述情况中,“G”,将在rexster.xml绑定到名为图形 “我的 - 钛 - 图”。
+0
谢谢,这看起来更好现在,但仍然抛出java.lang.IllegalThreadStateException – lilin 2015-02-24 09:04:25
看起来像你缺少groovy ...它是否需要作为依赖? – 2015-02-23 12:59:25
@tim_yates unfornutaly,加入 \t \t \t com.tinkerpop.gremlin \t \t \t 小鬼,常规 \t \t \t 2.6.0 \t \t 没有任何改变 –
lilin
2015-02-23 13:58:55