Java OCommandExecutorNotFoundException通过jar文件创建OrientDB数据库
我们想在Linux系统上导入数据。我们有两个Java文件用于导入。一个(OrientDBMain.java)用于创建完成所有工作的对象。另一个(OrientDB.java)包含所有数据库功能,如设置索引等。第二个文件以以下内容开头:Java OCommandExecutorNotFoundException通过jar文件创建OrientDB数据库,java,linux,eclipse,maven,orientdb,Java,Linux,Eclipse,Maven,Orientdb,我们想在Linux系统上导入数据。我们有两个Java文件用于导入。一个(OrientDBMain.java)用于创建完成所有工作的对象。另一个(OrientDB.java)包含所有数据库功能,如设置索引等。第二个文件以以下内容开头: public class OrientDB { private OrientGraphFactory factoryGraph; private ODatabaseDocumentTx db; private String csvPath;
public class OrientDB {
private OrientGraphFactory factoryGraph;
private ODatabaseDocumentTx db;
private String csvPath;
@SuppressWarnings("resource")
public OrientDB(String dbPath) {
OGlobalConfiguration.STORAGE_KEEP_OPEN.setValue(true);
OGlobalConfiguration.ENVIRONMENT_CONCURRENT.setValue(false);
db = new ODatabaseDocumentTx(dbPath).create();
}
...
在Windows和MAC上的Eclipse中运行此功能效果良好。没有错误,数据已正确导入
但是现在我们想在我们的Linux系统上运行它。因此,我们设置了一个Maven项目(m2e),并导出了一个包含所有依赖项的Jar文件:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>mapegy</groupId>
<artifactId>orientdbcsv</artifactId>
<version>0.0.2-SNAPSHOT</version>
<packaging>jar</packaging>
<name>orientdbcsv</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-graphdb</artifactId>
<version>2.0-M1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>mapegy.orientdbcsv.OrientDBMain</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
4.0.0
马佩吉
定向DBCSV
0.0.2-快照
罐子
定向DBCSV
http://maven.apache.org
UTF-8
朱尼特
朱尼特
3.8.1
测试
面向对象技术
定向数据库图形
2.0-M1
maven汇编插件
mapegy.orientdbcsv.OrientDBMain
带有依赖项的jar
组装
包裹
单一的
org.apache.maven.plugins
maven编译器插件
2.3.2
${jdk.version}
${jdk.version}
但是如果我们现在运行这个Jar,我们会得到一些错误。他们说抛出了一些OCommandExecutorNotFoundException。但如果它直接在Eclipse中运行得很好,那怎么可能呢?我们有2个参数{pathtoimportdata,pathtodestinationdb}
C:\eclipse-workspace\orientdbcsv\target>java -jar orientdbcsv-0.0.2-SNAPSHOT-jar
-with-dependencies.jar "C:\data" "C:\orientdb-community-2.0-M1\databases\test"
Exception in thread "main" com.orientechnologies.orient.core.exception.ODatabase
Exception: Cannot create database
at com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.c
reate(ODatabaseRecordAbstract.java:289)
at com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract.create(
ODatabaseWrapperAbstract.java:61)
at com.orientechnologies.orient.core.db.ODatabaseRecordWrapperAbstract.c
reate(ODatabaseRecordWrapperAbstract.java:72)
at com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract.create(
ODatabaseWrapperAbstract.java:56)
at com.orientechnologies.orient.core.db.ODatabaseRecordWrapperAbstract.c
reate(ODatabaseRecordWrapperAbstract.java:66)
at mapegy.orientdbcsv.OrientDB.<init>(OrientDB.java:36)
at mapegy.orientdbcsv.OrientDBMain.main(OrientDBMain.java:6)
Caused by: com.orientechnologies.orient.core.command.OCommandExecutorNotFoundExc
eption: Cannot find a command executor for the command request: sql.select count
(*) from ORole where name.type() not in ["STRING"] and name is not null
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.par
se(OCommandExecutorSQLDelegate.java:48)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.par
se(OCommandExecutorSQLDelegate.java:33)
at com.orientechnologies.orient.core.storage.OStorageEmbedded.command(OS
torageEmbedded.java:69)
at com.orientechnologies.orient.core.command.OCommandRequestTextAbstract
.execute(OCommandRequestTextAbstract.java:59)
at com.orientechnologies.orient.core.metadata.schema.OClassImpl.checkPer
sistentPropertyType(OClassImpl.java:1597)
at com.orientechnologies.orient.core.metadata.schema.OClassImpl.addPrope
rty(OClassImpl.java:1911)
at com.orientechnologies.orient.core.metadata.schema.OClassImpl.createPr
operty(OClassImpl.java:580)
at com.orientechnologies.orient.core.metadata.security.OSecurityShared.c
reateMetadata(OSecurityShared.java:350)
at com.orientechnologies.orient.core.metadata.security.OSecurityShared.c
reate(OSecurityShared.java:282)
at com.orientechnologies.orient.core.metadata.security.OSecurityProxy.cr
eate(OSecurityProxy.java:70)
at com.orientechnologies.orient.core.metadata.OMetadataDefault.create(OM
etadataDefault.java:84)
at com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.c
reate(ODatabaseRecordAbstract.java:269)
... 6 more
C:\eclipseworkspace\orientdbcsv\target>java-jar-orientdbcsv-0.0.2-SNAPSHOT-jar
-with-dependencies.jar“C:\data”C:\orientdb-community-2.0-M1\databases\test
线程“main”com.orientechnologies.orient.core.Exception.ODatabase中出现异常
异常:无法创建数据库
在com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.c
reate(ODatabaseRecordAbstract.java:289)
在com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract.create上(
ODatabaseWrapperAbstract.java:61)
在com.orientechnologies.orient.core.db.ODatabaseRecordWrapperAbstract.c上
创建(ODatabaseRecordWrapperAbstract.java:72)
在com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract.create上(
ODatabaseWrapperAbstract.java:56)
在com.orientechnologies.orient.core.db.ODatabaseRecordWrapperAbstract.c上
创建(ODatabaseRecordWrapperAbstract.java:66)
在mapegy.orientdbcsv.OrientDB.(OrientDB.java:36)
位于mapegy.orientdbcsv.OrientDBMain.main(OrientDBMain.java:6)
原因:com.orientechnologies.orient.core.command.OCommandExecutorNotFoundExc
eption:找不到命令请求的命令执行器:sql.select count
(*)来自ORole,其中name.type()不在[“STRING”]中,且name不为null
在.OrnEngutix.Orth.C.S.L.OrthRealExcutoSql
se(OCommandExecutorSQLDelegate.java:48)
在.OrnEngutix.Orth.C.S.L.OrthRealExcutoSql
se(OCommandExecutorSQLDelegate.java:33)
在com.orientechnologies.orient.core.storage.OStorageEmbedded.command(OS
torageEmbedded.java:69)
在com.orientechnologies.orient.core.command.OCommandRequestTextAbstract上
.execute(OCommandRequestTextAbstract.java:59)
位于com.orientechnologies.orient.core.metadata.schema.OClassImpl.checkPer
sistentPropertyType(OClassImpl.java:1597)
位于com.orientechnologies.orient.core.metadata.schema.OClassImpl.addPrope
rty(OClassImpl.java:1911)
位于com.orientechnologies.orient.core.metadata.schema.OClassImpl.createPr
不动产(OClassImpl.java:580)
在com.orientechnologies.orient.core.metadata.security.OSecurityShared.c上
reateMetadata(OSecurityShared.java:350)
在com.orientechnologies.orient.core.metadata.security.OSecurityShared.c上
创建(OSecurityShared.java:282)
位于com.orientechnologies.orient.core.metadata.security.OSecurityProxy.cr
eate(OSecurityProxy.java:70)
在com.orientechnologies.orient.core.metadata.ometadadefault.create(OM)上
etadataDefault.java:84)
在com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.c
reate(ODatabaseRecordAbstract.java:269)
... 还有6个
所以问题是现在。为什么它会抛出这个错误,为什么它能在Eclipse中正常工作。也许您知道另一种方法,可以轻松地为OrientDB编译导入脚本,而不需要花费太多精力
多谢各位 这是因为某些文件在不同的jar中重复,因此某些配置丢失 这些文件是: META-INF/services/com.orientechnologies.orient.core.sql.functions.OSQLFunctionFactory META-INF/services/com.orientechnologies.orient.core.sql.OCommandExecutorSQLFactory 使用shade插件尝试下一个pom,并使用生成的shade-jar.jar进行尝试:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<configuration>
<finalName>shaded-jar</finalName>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/services/com.orientechnologies.orient.core.sql.functions.OSQLFunctionFactory</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/services/com.orientechnologies.orient.core.sql.OCommandExecutorSQLFactory</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>mapegy.orientdbcsv.OrientDBMain</mainClass>
</transformer>
</transformers>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
org.apache.maven.plugins
maven阴影插件
2.3
荫罩罐
META-INF/services/com.orientechnologies.orient.core.sql.functions.OSQLFunctionFactory
META-INF/services/com.orientechnologies.orient.core.sql.OCommandExecutorSQLFactory
mapegy.orientdbcsv.OrientDBMain
包裹
阴凉处
我给弗兰发了一封电子邮件解释这一点。。。明天早上和他核实一下!很高兴认识你。同样是我的朋友,谢谢你的快速回复。我现在就试试,否则我睡不着。=)《与弗兰交谈》现在也在尝试。我们已经尝试过了,但是在Maven安装中收到了很多警告。这是当前的pom.xml:。这是我在cmd控制台中得到的:C:\eclipse workspace\orientdbcsv\target>java