简体   繁体   English

在Java Applet中运行OrientDB

[英]Run OrientDB in a Java Applet

EDIT: Found the solution. 编辑:找到解决方案。 It was a problem with minifing the code while maven build process. 在maven构建过程中使用minifing代码是一个问题。 Run the OrientDB in a Java Applet is possible. 可以在Java Applet中运行OrientDB。

I have problems starting the inmemory OrientDB in a Java Applet. 我在Java Applet中启动内存OrientDB时遇到问题。 I use a signed Applet with OrientDB version 1.0.1. 我使用带有OrientDB版本1.0.1的签名Applet。 Did someone implemented the OrientDB in a Applet and can verify that this is possible or could help me with this exception? 有人在Applet中实现了OrientDB并且可以验证这是可能的还是可以帮助我解决这个异常?

The exception I get: 我得到的例外:

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)

My Applet code to start the DB: 我的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;
            }
        });
    }
}

the problem seems the usage of Java Service Registry. 问题似乎是Java Service Registry的用法。 Look at: 看着:

OClassLoaderHelper.lookupProviderWithOrientClassLoader()

it calls: 它叫:

ServiceRegistry.lookupProviders(clazz);

I've just added in SVN trunk (r5909) this check: 我刚刚在SVN trunk(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. 通过这种方式转储WARN,但如果需要,您可以继续配置自己的工厂。

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

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