3

编辑:找到解决方案。在 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)

我启动数据库的 Applet 代码:

    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;
            }
        });
    }
}
4

1 回答 1

1

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

OClassLoaderHelper.lookupProviderWithOrientClassLoader()

它调用:

ServiceRegistry.lookupProviders(clazz);

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

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

In this way a WARN is dumped but you can continue to configure your own factories if needed.

于 2012-06-20T14:39:14.057 回答