简体   繁体   English

通过Java连接Titan db-引发异常

[英]Connecting Titan db through Java - throws an exception

I have a java code snippet 我有一个Java代码段

 TitanGraph g = TitanFactory.open("titan-all-0.4.4/conf/titan-berkeleydb.properties"); 

where titan-berkeleydb .properties is the in build config file that comes with Titan db installation. 其中titan-berkeleydb .properties是Titan db安装随附的内置配置文件。

On execution, it throws an exception 在执行时,它将引发异常

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.commons.lang.StringUtils.isNotBlank(Ljava/lang/String;)Z

at com.thinkaurelius.titan.graphdb.configuration.KCVSConfiguration.<init>(KCVSConfiguration.java:40)
at com.thinkaurelius.titan.diskstorage.Backend.initialize(Backend.java:273)
at com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration.getBackend(GraphDatabaseConfiguration.java:1174)
at com.thinkaurelius.titan.graphdb.database.StandardTitanGraph.<init>(StandardTitanGraph.java:75)
at com.thinkaurelius.titan.core.TitanFactory.open(TitanFactory.java:40)
at com.thinkaurelius.titan.core.TitanFactory.open(TitanFactory.java:29)

Is there a way to resolve this issue? 有没有办法解决这个问题?

If you're using a web application with Tomcat , you have to add the jar file into WEB-INF/lib folder of the application (or into $TOMCAT_HOME/lib folder, if you have more webapps using it). 如果您将Web应用程序与Tomcat ,则必须将jar文件添加到应用程序的WEB-INF/lib文件夹中(如果使用的Web应用程序更多,则将其添加到$ TOMCAT_HOME / lib文件夹中)。

Either create a library with this jar and add it to the project class path. 使用此jar创建一个库,然后将其添加到项目类路径。

If you done all this and it still not working, you can change the jar extension to zip or rar and open it to see if the requested classes you need are inside. 如果完成所有这些操作后仍无法正常工作,则可以将jar扩展名更改为ziprar然后将其打开以查看所需的所需类是否在其中。

Check your classpath for another commons-lang-*.jar. 检查您的类路径是否有另一个commons-lang-*。jar。 According to the Apache Commons documentation, the isBlank() method is new since 2.0. 根据Apache Commons文档,isBlank()方法自2.0以来是新的。 https://commons.apache.org/proper/commons-lang/javadocs/api-2.5/org/apache/commons/lang/StringUtils.html#isBlank%28java.lang.String%29 https://commons.apache.org/proper/commons-lang/javadocs/api-2.5/org/apache/commons/lang/StringUtils.html#isBlank%28java.lang.String%29

Titan 0.4.4 ships with commons-lang-2.5.jar in the lib directory. Titan 0.4.4随附lib目录中的commons-lang-2.5.jar。 Your original post didn't mention anything else about the runtime environment. 您的原始文章没有提及任何有关运行时环境的内容。 I would suspect that if you had, for example, commons-lang-1.0.1.jar on the classpath, it would be picked up before commons-lang-2.5.jar and you would see the error. 我怀疑如果您在类路径上有commons-lang-1.0.1.jar,它将在commons-lang-2.5.jar之前被拾取,并且您会看到错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM