Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with starting embedded server #8285

Closed
hrstoyanov opened this issue May 23, 2018 · 6 comments
Closed

Issues with starting embedded server #8285

hrstoyanov opened this issue May 23, 2018 · 6 comments
Assignees
Milestone

Comments

@hrstoyanov
Copy link

hrstoyanov commented May 23, 2018

OrientDB Version: 3.0.0

Java Version: 1.8_172

OS: Windows 7 64-bit

I am trying to start an Embedded server (over a database that I have previously created with console.bat) with his piece of code:

        //....
        log.info(()->"ODB-JCA resource adapter starting ...");
        log.info(()->"ODB-JCA server configuration: " + getEmbeddedServerConfiguration());
        log.info(()->"ODB-JCA server home: " + getOrientdbHome());
        if (embeddedServerConfiguration != null) 
        try {
            embeddedServer = OServerMain.create(true);
            embeddedServer.startup(new File(embeddedServerConfiguration));
            embeddedServer.activate();

            log.info(()->"ODB-JCA database directory: " + embeddedServer.getDatabaseDirectory());
            log.info(()->"ODB-JCA server id: " + embeddedServer.getServerId());
            log.info(()->"ODB-JCA server activated: " + embeddedServer.isActive());

            Map<String, String> storageNames = embeddedServer.getAvailableStorageNames();
            if (storageNames != null) {
                storageNames.forEach((String k, String v) -> log.info(()->"ODB-JCA storage: " + k + ", " + v));
            }

            Map<String, Class<? extends ONetworkProtocol>> networkProtocols = embeddedServer.getNetworkProtocols();
            if (networkProtocols != null) {
                networkProtocols.forEach((String k, Class<? extends ONetworkProtocol> v) -> {
                    log.info(()->"ODB-JCA network protocol name: " + k + ", " + v.getSimpleName());
                    OServerNetworkListener l = embeddedServer.getListenerByProtocol(v);
                    log.info(()->"ODB-JCA protocol listener inbound addr: " + l.getInboundAddr() + ", active:" + l.isActive() + ", alive:" + l.isAlive());
                });
            }

            log.info(()->"ODB-JCA resource adapter successfully started");

        } catch (Exception e) {
            log.log(Level.SEVERE,"ODB-JCA resource adapter failed to start", e);
            throw new ResourceAdapterInternalException(e);
        }

Expected behavior

I expected the server to start with no issues.

Actual behavior

Instead, this call embeddedServer.activate(); bombs with the below exception - why is the server trying to create db system files when the database already exists? Also, looking at the database folder, I do see a lot of files, but not OSystem ?

Caused by: com.orientechnologies.orient.core.exception.OStorageExistsException: Cannot create new storage 'plocal:C:\temp\my.db/OSystem' because it already exists
        at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.create(OAbstractPaginatedStorage.java:456)
        at com.orientechnologies.orient.core.storage.impl.local.paginated.OLocalPaginatedStorage.create(OLocalPaginatedStorage.java:126)
        at com.orientechnologies.orient.core.db.OrientDBEmbedded.internalCreate(OrientDBEmbedded.java:251)
        at com.orientechnologies.orient.core.db.OrientDBEmbedded.create(OrientDBEmbedded.java:209)

When I comment out //embeddedServer.activate(); (although the ODB documentation clearly shows it is needed for embedded server) I get another exception:

Caused by: java.lang.NullPointerException
        at com.orientechnologies.orient.server.OServer.getServerId(OServer.java:249)

Do you guys inspect the codebase with something like FindBugs - such NPEs are pretty easy to catch?

Steps to reproduce

  1. Create an empty database
  2. Configure an embedded server for work with it
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<orient-server>
    <handlers>
        <handler class="com.orientechnologies.orient.server.handler.OServerSideScriptInterpreter">
            <parameters>
                <parameter value="true" name="enabled"/>
                <parameter value="SQL" name="allowedLanguages"/>
            </parameters>
        </handler>
    </handlers>
    <network>
        <protocols>
            <protocol
                    implementation="com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary"
                    name="binary"/>
        </protocols>
        <listeners>
            <listener protocol="binary" socket="default" port-range="3424-3430" ip-address="0.0.0.0"/>
        </listeners>
    </network>

    <users>
        <user resources="*" password="admin" name="admin"/>
    </users>

    <properties>
        <entry value="../../../../../../my.db" name="server.database.path"/>
        <entry value="1" name="db.pool.min"/>
        <entry value="50" name="db.pool.max"/>
        <entry value="true" name="profiler.enabled"/>
        <entry value="info" name="log.console.level"/>
        <entry value="info" name="log.file.level"/>
    </properties>

    <isAfterFirstTime>true</isAfterFirstTime>
  1. Start an embedded instance as described above
@hrstoyanov
Copy link
Author

image

Looking at the OAbstractPaginatedStorage.create(...) there seems to be some confusion as to what exists() checks - it only verifies the db root folder. Could this be the issue?

@hrstoyanov
Copy link
Author

hrstoyanov commented May 23, 2018

I just tested with OrientDB 3.0.1 - issue still there.

Caused by: com.orientechnologies.orient.core.exception.OStorageExistsException: Cannot create new storage 'plocal:C:\temp\my.db/OSystem' because it already exists
        at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.create(OAbstractPaginatedStorage.java:456)
        at com.orientechnologies.orient.core.storage.impl.local.paginated.OLocalPaginatedStorage.create(OLocalPaginatedStorage.java:127)
        at com.orientechnologies.orient.core.db.OrientDBEmbedded.internalCreate(OrientDBEmbedded.java:251)
        at com.orientechnologies.orient.core.db.OrientDBEmbedded.create(OrientDBEmbedded.java:209)
        at com.orientechnologies.orient.server.OServer.createDatabase(OServer.java:1226)
        at com.orientechnologies.orient.server.OSystemDatabase.init(OSystemDatabase.java:156)
        at com.orientechnologies.orient.server.OSystemDatabase.<init>(OSystemDatabase.java:45)
        at com.orientechnologies.orient.server.OServer.initSystemDatabase(OServer.java:1202)
        at com.orientechnologies.orient.server.OServer.activate(OServer.java:412)

@tglman
Copy link
Member

tglman commented May 23, 2018

Hi @hrstoyanov,

Are you giving a custom path for the "server.database.path" or are you using a custom storage path ? probably would be easier if you can share the orientdb-server-config.xml that you are using.

Another issue could be in the path management, could you try to replace \\ with / in the path, just to exclude a case.

Regards

@hrstoyanov
Copy link
Author

Hi @tglman. Indeed, I am using server.database.path i my server configuration file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<orient-server>
    <handlers>
        <handler class="com.orientechnologies.orient.server.handler.OServerSideScriptInterpreter">
            <parameters>
                <parameter value="true" name="enabled"/>
                <parameter value="SQL" name="allowedLanguages"/>
            </parameters>
        </handler>
    </handlers>
    <network>
        <protocols>
            <protocol
                    implementation="com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary"
                    name="binary"/>
        </protocols>
        <listeners>
            <listener protocol="binary" socket="default" port-range="3424-3430" ip-address="0.0.0.0"/>
        </listeners>
    </network>

    <users>
        <user resources="*" password="admin" name="admin"/>
    </users>

    <properties>
        <entry value="../../../../../../my.db" name="server.database.path"/>
        <entry value="1" name="db.pool.min"/>
        <entry value="50" name="db.pool.max"/>
        <entry value="true" name="profiler.enabled"/>
        <entry value="info" name="log.console.level"/>
        <entry value="info" name="log.file.level"/>
    </properties>

    <isAfterFirstTime>true</isAfterFirstTime>

@hrstoyanov
Copy link
Author

@tglman @Laa
If you look at the screenshot I posted above, just before the exception is thrown:

  1. The exists() returns TRUE because the storage root folder does exists.
  2. The getURL() however is for the OSysem file, which does not exist.

Looked at the debug watches I marked in the screenshot debug window. Does this look normal? This might be a clue as to what is wrong. I also traced in the debugger that the storage path picked from the XML server config file is correct.

tglman added a commit that referenced this issue Jun 1, 2018
@markodjurovic
Copy link
Contributor

@hrstoyanov Thank you for reporting this issue and on detailed explanation. Fix will be part of 3.0.2 version, also it is already merged into development branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants