Question on how to use OrientDB in JavaFX with thread issues

92 views
Skip to first unread message

thejon...@gmail.com

unread,
Jul 25, 2016, 6:20:47 PM7/25/16
to orient-...@googlegroups.com
I'm trying to use OrientDB in an JavaFX desktop app by connecting to a remote server.

I tried some code snippets first without JavaFX. They worked. I could connect, qurey and it print.out over console.

But inside of an JavaFX app there seems to be some issues related to the way threads are handeled.

I read the chapter about Multy-Threading for OrientDB but I don't seem to understand.

An example on how to use orientDB in a JavaFX would be very helpful!

In my last try I used a backgrooud Thread, here is the example:

 @FXML
   
private void abfragenButtonClick(ActionEvent event) {
                   
       
//Create a Runnable
       
Runnable task = () -> queryOrientDB();

       
//Run the task in a background thread
       
Thread backgroundThread = new Thread(task);

       
//Terminate the running thread if the application exits
        backgroundThread
.setDaemon(true);

       
//Start the thread
        backgroundThread
.start();
   
}

   
public void queryOrientDB() {

       
OrientGraphFactory factory = new OrientGraphFactory("remote:127.0.0.1:2424/Database", "admin", "admin").setupPool(1, 10);

       
OrientGraph graph = factory.getTx();
       
try {

           
for (Vertex v : (Iterable<Vertex>) graph.command(new OCommandSQL(
                   
"SELECT FROM v LIMIT 10"
           
)).execute()) {
               
System.out.println(v.toString());
           
}

       
} finally {
            graph
.shutdown();
       
}
   
}



Exception in thread "Thread-4" com.orientechnologies.orient.core.exception.ODatabaseException: Error on opening database 'remote:127.0.0.1:2424/Database'
    at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.<init>(ODatabaseDocumentTx.java:187)
    at com.orientechnologies.orient.core.db.OPartitionedDatabasePool$DatabaseDocumentTxPolled.<init>(OPartitionedDatabasePool.java:118)
    at com.orientechnologies.orient.core.db.OPartitionedDatabasePool$DatabaseDocumentTxPolled.<init>(OPartitionedDatabasePool.java:114)
    at com.orientechnologies.orient.core.db.OPartitionedDatabasePool.initQueue(OPartitionedDatabasePool.java:442)
    at com.orientechnologies.orient.core.db.OPartitionedDatabasePool.<init>(OPartitionedDatabasePool.java:217)
    at com.tinkerpop.blueprints.impls.orient.OrientGraphFactory.<init>(OrientGraphFactory.java:78)
    at com.tinkerpop.blueprints.impls.orient.OrientGraphFactory.<init>(OrientGraphFactory.java:55)
    at com.mycompany.dmtest.FXMLController.queryOrientDB(FXMLController.java:48)
    at com.mycompany.dmtest.FXMLController.lambda$abfragenButtonClick$0(FXMLController.java:34)
    at java.lang.Thread.run(Thread.java:745)
Caused by: com.orientechnologies.orient.core.exception.OConfigurationException: Error on opening database: the engine 'remote' was not found. URL was: remote:127.0.0.1:2424/Database. Registered engines are: [memory, plocal]
    DB name="remote:127.0.0.1:2424/Database"
    at com.orientechnologies.orient.core.Orient.loadStorage(Orient.java:476)
    at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.<init>(ODatabaseDocumentTx.java:167)
    ... 9 more



Thanks

Oleksandr Gubchenko

unread,
Jul 26, 2016, 10:40:31 AM7/26/16
to OrientDB
In your code the DB name is Database and in your exception the DB name is TrumpfMarktplatz.

Can you check and post the correct code ore exception?

Thanks.
Exception in thread "Thread-4" com.orientechnologies.orient.core.exception.ODatabaseException: Error on opening database 'remote:127.0.0.1:2424/TrumpfMarktplatz'

    at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.<init>(ODatabaseDocumentTx.java:187)
    at com.orientechnologies.orient.core.db.OPartitionedDatabasePool$DatabaseDocumentTxPolled.<init>(OPartitionedDatabasePool.java:118)
    at com.orientechnologies.orient.core.db.OPartitionedDatabasePool$DatabaseDocumentTxPolled.<init>(OPartitionedDatabasePool.java:114)
    at com.orientechnologies.orient.core.db.OPartitionedDatabasePool.initQueue(OPartitionedDatabasePool.java:442)
    at com.orientechnologies.orient.core.db.OPartitionedDatabasePool.<init>(OPartitionedDatabasePool.java:217)
    at com.tinkerpop.blueprints.impls.orient.OrientGraphFactory.<init>(OrientGraphFactory.java:78)
    at com.tinkerpop.blueprints.impls.orient.OrientGraphFactory.<init>(OrientGraphFactory.java:55)
    at com.mycompany.dmtest.FXMLController.queryOrientDB(FXMLController.java:48)
    at com.mycompany.dmtest.FXMLController.lambda$abfragenButtonClick$0(FXMLController.java:34)
    at java.lang.Thread.run(Thread.java:745)
Caused by: com.orientechnologies.orient.core.exception.OConfigurationException: Error on opening database: the engine 'remote' was not found. URL was: remote:127.0.0.1:2424/TrumpfMarktplatz. Registered engines are: [memory, plocal]
    DB name="remote:127.0.0.1:2424/TrumpfMarktplatz"

thejon...@gmail.com

unread,
Jul 26, 2016, 4:21:28 PM7/26/16
to OrientDB
Yes code and exception belong together.
I just changed it to Database to make it more readable.

I made an edit to the exception to correct it too!

Sahand Delta

unread,
Jul 28, 2016, 6:31:58 PM7/28/16
to OrientDB
To make the issue clear, here a little Table

           |    JavaFX   |   plain Java  |

plocal   |   works     |   works        |
remote |    fails       |   works        |


I have no idea what could be the reason behind this?

Does someone else have any idea or successfully tried the combination of OrientDB remote connection withhin JavaFX?
Reply all
Reply to author
Forward
0 new messages