gpt4 book ai didi

java - 在 Java Applet 中运行 OrientDB

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:13:04 25 4
gpt4 key购买 nike

编辑:找到了解决方案。在 Maven 构建过程中缩小代码是一个问题。在 Java Applet 中运行 OrientDB 是可能的。

我在 Java Applet 中启动内存中的 OrientDB 时遇到问题。我使用带有 OrientDB 版本 1.0.1 的签名 Applet。是否有人在 Applet 中实现了 OrientDB 并且可以验证这是可能的或者可以帮助我解决这个异常?

我得到的异常:

2012-06-20 11:22:24:734 INFO OrientDB Server v1.0.1 is starting up... [OServer]Exception in thread "thread applet-de.test.all.Applet-1" sun.misc.ServiceConfigurationError: com.orientechnologies.orient.core.sql.OCommandExecutorSQLFactory: Provider com.orientechnologies.orient.core.sql.ODefaultCommandExecutorSQLFactory not found
at sun.misc.Service.fail(Service.java:129)
at sun.misc.Service.access$000(Service.java:111)
at sun.misc.Service$LazyIterator.next(Service.java:273)
at com.orientechnologies.orient.core.sql.OSQLEngine.getCommandFactories(OSQLEngine.java:186)
at com.orientechnologies.orient.core.sql.OSQLEngine.getCommandNames(OSQLEngine.java:216)
at com.orientechnologies.orient.core.sql.OSQLEngine.getCommand(OSQLEngine.java:239)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.parse(OCommandExecutorSQLDelegate.java:41)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.parse(OCommandExecutorSQLDelegate.java:31)
at com.orientechnologies.orient.core.storage.OStorageEmbedded.command(OStorageEmbedded.java:62)
at com.orientechnologies.orient.core.command.OCommandRequestTextAbstract.execute(OCommandRequestTextAbstract.java:60)
at com.orientechnologies.orient.core.metadata.schema.OSchemaShared.createClass(OSchemaShared.java:218)
at com.orientechnologies.orient.core.metadata.schema.OSchemaShared.createClass(OSchemaShared.java:164)
at com.orientechnologies.orient.core.metadata.schema.OSchemaShared.createClass(OSchemaShared.java:145)
at com.orientechnologies.orient.core.metadata.schema.OSchemaShared.createClass(OSchemaShared.java:116)
at com.orientechnologies.orient.core.metadata.schema.OSchemaProxy.createClass(OSchemaProxy.java:65)
at com.orientechnologies.orient.core.metadata.security.OSecurityShared.createMetadata(OSecurityShared.java:259)
at com.orientechnologies.orient.core.metadata.security.OSecurityShared.create(OSecurityShared.java:202)
at com.orientechnologies.orient.core.metadata.security.OSecurityProxy.create(OSecurityProxy.java:37)
at com.orientechnologies.orient.core.metadata.OMetadata.create(OMetadata.java:68)
at com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.create(ODatabaseRecordAbstract.java:171)
at com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract.create(ODatabaseWrapperAbstract.java:53)
at com.orientechnologies.orient.core.db.ODatabaseRecordWrapperAbstract.create(ODatabaseRecordWrapperAbstract.java:54)
at com.orientechnologies.orient.server.OServer.loadStorages(OServer.java:451)
at com.orientechnologies.orient.server.OServer.loadConfiguration(OServer.java:394)
at com.orientechnologies.orient.server.OServer.startup(OServer.java:152)
at com.orientechnologies.orient.server.OServer.startup(OServer.java:143)
at com.orientechnologies.orient.server.OServer.startup(OServer.java:132)
at de.test.all.Applet$1.run(Applet.java:132)
at de.test.all.Applet$1.run(Applet.java:125)
at java.security.AccessController.doPrivileged(Native Method)
at de.test.all.Applet.init(Applet.java:124)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Plugin2Manager.java:1639)
at java.lang.Thread.run(Thread.java:680)

我启动数据库的小程序代码:

    public class Applet extends java.applet.Applet {

OrientDbConfigurationLoader configLoader = null;
OServer server = null;
ODatabaseDocumentTx db = null;

@Override
public void init() {
AccessController.doPrivileged(new
PrivilegedAction<OServer>() {

public OServer run() {
configLoader = new OrientDbConfigurationLoader("db/", "test");

try {
server = OServerMain.create();
server.startup(configLoader.loadDefaultConfig());
server.activate();
} catch (InstanceAlreadyExistsException e) {
server = OServerMain.server();
} catch (Exception e) {
System.out.println("Something went wrong while the server should start");
e.printStackTrace();
}

try {
db = new ODatabaseDocumentTx("memory:temp");
db = db.open(OrientDbConfigurationLoader.USERNAME, OrientDbConfigurationLoader.PASSWORD);
} catch (Exception e) {
System.out.println("Can't init the in-memory db.");
e.printStackTrace();
}
return null;
}
});
}
}

最佳答案

问题似乎是 Java Service Registry 的使用。看看:

OClassLoaderHelper.lookupProviderWithOrientClassLoader()

它调用:

ServiceRegistry.lookupProviders(clazz);

我刚刚在 SVN trunk (r5909) 中添加了这个检查:

 try {
factories.add(ite.next());
} catch (Exception e) {
OLogManager.instance().warn(null, "Cannot load OCommandExecutorSQLFactory instance from service registry", e);
}

以这种方式转储 WARN,但您可以根据需要继续配置自己的工厂。

关于java - 在 Java Applet 中运行 OrientDB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11116540/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com