Cannot restart embedded server
I'm using OrientDB 1.5.1.
I'm working with embedded server (Object Database). My application starts the OServer and shutdown it. Everything works fine. But then it restarts it... and it fails:
Here is the code that shows the problem:
public static void main(String[] args) throws Exception {
for(int i = 0; i < 5; i++) {
System.out.println("Iteration " + i);
OServer server = OServerMain.create().startup().activate();
ODatabase database = new OObjectDatabaseTx("local:/home/cthiebault/projects/opal-home/opal-config-db");
if(!database.exists()) database.create();
database.close();
server.shutdown();
}
}
And the stacktrace:
Iteration 0
2013-09-06 16:25:35:860 INFO Loading configuration from: config/orientdb-server-config.xml... [OServerConfigurationLoaderXml]
2013-09-06 16:25:35:971 INFO OrientDB Server v1.5.1-SNAPSHOT is starting up... [OServer]
2013-09-06 16:25:36:003 SEVE Error on reading server configuration. [OServer]
2013-09-06 16:25:36:010 WARN [OVariableParser.resolveVariables] Error on resolving property: ORIENTDB_HOME [orientechnologies]
2013-09-06 16:25:36:022 INFO Listening binary connections on 127.0.0.1:2424 (protocol v.17) [OServerNetworkListener]
2013-09-06 16:25:36:022 INFO OrientDB Server v1.5.1-SNAPSHOT is active. [OServer]
2013-09-06 16:25:36:131 INFO OrientDB Server is shutting down... [OServer]
2013-09-06 16:25:36:132 INFO Shutting down storage: opal-config-db... [Orient]
Iteration 1
2013-09-06 16:25:36:135 INFO Orient Engine shutdown complete
[Orient]
2013-09-06 16:25:36:135 INFO Shutting down protocols [OServer]
2013-09-06 16:25:36:135 INFO Shutting down listeners: [OServer]
2013-09-06 16:25:36:135 INFO - ONetworkProtocolBinary /127.0.0.1:2424: [OServer]
2013-09-06 16:25:36:135 INFO OrientDB Server shutdown complete [OServer]
2013-09-06 16:25:36:135 INFO Loading configuration from: config/orientdb-server-config.xml... [OServerConfigurationLoaderXml]
2013-09-06 16:25:36:153 INFO OrientDB Server v1.5.1-SNAPSHOT is starting up... [OServer]
2013-09-06 16:25:36:191 SEVE Error on reading server configuration. [OServer]
2013-09-06 16:25:36:191 WARN [OVariableParser.resolveVariables] Error on resolving property: ORIENTDB_HOME [orientechnologies]Exception in thread "main" java.lang.NullPointerException
at com.orientechnologies.orient.server.OServer.startup(OServer.java:110)
at org.obiba.opal.core.cfg.OrientDbServiceImpl.main(OrientDbServiceImpl.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Exception in thread "Thread-7" java.lang.NullPointerException
at com.orientechnologies.orient.server.OServer.shutdown(OServer.java:216)
at com.orientechnologies.orient.server.OServerShutdownHook.run(OServerShutdownHook.java:35)
Hi,
- You should set ORIENTDB_HOME system property before server start, it simply does not know which directory to read.
- Why did you use local: url prefix if you start server ? You should use remote: in such cases.
Hi,
- Do I really need ORIENTDB_HOME system property with an embedded server?
- I want to use local engine, not remote.
Cedric
Hi Cedric,
- yes. Set it where OrientDB is installed or where OrientDB will use/create a folder "databases" where to store databases
- you can use local, OrientDB will coordinates the local and remote calls
I still have an exception even with ORIENTDB_HOME defined.
I use the same config xml as orientdb/orientdb/server/config/orientdb-server-config.xml
public static void main(String[] args) throws Exception {
System.setProperty("ORIENTDB_HOME", "/home/cthiebault/orientdb");
System.out.println("ORIENTDB_HOME: " + System.getProperty("ORIENTDB_HOME"));
for(int i = 0; i < 5; i++) {
System.out.println("Iteration " + i);
OServer server = OServerMain.create()
.startup(OrientDbServiceImpl.class.getResourceAsStream("/orientdb-server-config.xml")).activate();
// create database if does not exist
ODatabase database = new OObjectDatabaseTx("local:" + System.getProperty("ORIENTDB_HOME") + "/config-db");
if(!database.exists()) database.create();
database.close();
server.shutdown();
}
}
Stacktrace:
ORIENTDB_HOME: /home/cthiebault/orientdb
Iteration 0
2013-09-11 11:19:14:371 INFO Loading configuration from input stream [OServerConfigurationLoaderXml]
2013-09-11 11:19:14:496 INFO Profiler is recording metrics with configuration: 0,0,0 [OJVMProfiler]
2013-09-11 11:19:14:497 INFO OrientDB Server v1.5.1 is starting up... [OServer]
2013-09-11 11:19:14:528 INFO Port 0.0.0.0:2424 busy, trying the next available... [OServerNetworkListener]
2013-09-11 11:19:14:528 INFO Port 0.0.0.0:2425 busy, trying the next available... [OServerNetworkListener]
2013-09-11 11:19:14:528 INFO Port 0.0.0.0:2426 busy, trying the next available... [OServerNetworkListener]
2013-09-11 11:19:14:528 INFO Listening binary connections on 0.0.0.0:2427 (protocol v.17) [OServerNetworkListener]
2013-09-11 11:19:14:528 INFO Port 0.0.0.0:2480 busy, trying the next available... [OServerNetworkListener]
2013-09-11 11:19:14:529 INFO Port 0.0.0.0:2481 busy, trying the next available... [OServerNetworkListener]
2013-09-11 11:19:14:529 INFO Port 0.0.0.0:2482 busy, trying the next available... [OServerNetworkListener]
2013-09-11 11:19:14:529 INFO Listening http connections on 0.0.0.0:2483 (protocol v.10) [OServerNetworkListener]
2013-09-11 11:19:14:539 INFO Mail plugin installed and active. Loaded 1 profile(s): [default] [OMailPlugin]
2013-09-11 11:19:14:541 INFO OrientDB Server v1.5.1 is active. [OServer]
2013-09-11 11:19:14:647 INFO OrientDB Server is shutting down... [OServer]
2013-09-11 11:19:14:648 INFO Shutting down storage: config-db... [Orient]
Iteration 1
2013-09-11 11:19:14:651 INFO Orient Engine shutdown complete
[Orient]
2013-09-11 11:19:14:652 INFO Shutting down plugins: [OServer]
2013-09-11 11:19:14:652 INFO - script-interpreter [OServer]
2013-09-11 11:19:14:652 INFO - mail [OServer]
2013-09-11 11:19:14:652 INFO - jmx [OServer]
2013-09-11 11:19:14:652 INFO - automaticBackup [OServer]
2013-09-11 11:19:14:652 INFO Shutting down protocols [OServer]
2013-09-11 11:19:14:652 INFO Shutting down listeners: [OServer]
2013-09-11 11:19:14:652 INFO - ONetworkProtocolBinary /0.0.0.0:2427: [OServer]
2013-09-11 11:19:14:652 INFO - ONetworkProtocolHttpDb /0.0.0.0:2483: [OServer]
2013-09-11 11:19:14:652 INFO OrientDB Server shutdown complete [OServer]Exception in thread "main" java.lang.NullPointerException
at com.orientechnologies.orient.server.OServer.<init>(OServer.java:96)
at com.orientechnologies.orient.server.OServerMain.create(OServerMain.java:22)
at org.obiba.opal.core.cfg.OrientDbServiceImpl.main(OrientDbServiceImpl.java:55)
Can you try it against 1.6.0-SNAPSHOT?
Same error with 1.6.0-SNAPSHOT:
2013-09-11 11:58:28:675 INFO OrientDB Server shutdown complete [OServer]Exception in thread "main" java.lang.NullPointerException
at com.orientechnologies.orient.server.OServer.<init>(OServer.java:109)
at com.orientechnologies.orient.server.OServerMain.create(OServerMain.java:22)
at org.obiba.opal.core.cfg.OrientDbServiceImpl.main(OrientDbServiceImpl.java:55)
Please let me know if works ;-)
Hi, in our project we use:
Orient.instance().startup();
OGraphDatabase db = null;
db = new OGraphDatabase ( "local:" + dbPath) ) ;
if (!db.exists()) {
info("DB does not exist, a new one will be created");
db.create();
}
db.open(username,password);
Without setting the ORIENTDB_HOME variable Hope this can help
It woks now :) Thanks Luca for your help!
Great!
It does not work again :(
Now when I stop & restart server, I get java.lang.IllegalStateException: Timer already cancelled
I'm using latest 1.6.0-SNAPSHOT
Iteration 0
2013-09-30 14:26:19:330 INFO Loading configuration from input stream [OServerConfigurationLoaderXml]
2013-09-30 14:26:19:510 INFO Profiler is recording metrics with configuration: 0,0,0 [OJVMProfiler]
2013-09-30 14:26:19:511 INFO OrientDB Server v1.6.0-SNAPSHOT is starting up... [OServer]
2013-09-30 14:26:19:526 INFO Databases directory: /home/cthiebault/orientdb/databases [OServer]
2013-09-30 14:26:19:546 INFO Listening binary connections on 0.0.0.0:2424 (protocol v.18) [OServerNetworkListener]
2013-09-30 14:26:19:547 INFO Listening http connections on 0.0.0.0:2480 (protocol v.10) [OServerNetworkListener]
2013-09-30 14:26:19:561 INFO Mail plugin installed and active. Loaded 1 profile(s): [default] [OMailPlugin]
2013-09-30 14:26:19:563 INFO OrientDB Server v1.6.0-SNAPSHOT is active. [OServer]
2013-09-30 14:26:19:678 INFO OrientDB Server is shutting down... [OServer]
2013-09-30 14:26:19:679 INFO Shutting down storage: config-db... [Orient]
2013-09-30 14:26:19:682 INFO Orient Engine shutdown complete
[Orient]
2013-09-30 14:26:19:682 INFO Shutting down plugins: [OServer]
2013-09-30 14:26:19:682 INFO - automaticBackup [OServer]
2013-09-30 14:26:19:682 INFO - script-interpreter [OServer]
2013-09-30 14:26:19:682 INFO - mail [OServer]
2013-09-30 14:26:19:683 INFO - jmx [OServer]
2013-09-30 14:26:19:710 INFO Shutting down protocols [OServer]
2013-09-30 14:26:19:710 INFO Shutting down listeners: [OServer]
2013-09-30 14:26:19:710 INFO - ONetworkProtocolBinary /0.0.0.0:2424: [OServer]
2013-09-30 14:26:19:710 INFO - ONetworkProtocolHttpDb /0.0.0.0:2480: [OServer]
2013-09-30 14:26:19:710 INFO OrientDB Server shutdown complete [OServer]
2013-09-30 14:26:19:723 INFO Profiler is recording metrics with configuration: 0,0,0 [OJVMProfiler]
2013-09-30 14:26:19:723 INFO Loading configuration from input stream [OServerConfigurationLoaderXml]
Iteration 1
2013-09-30 14:26:19:770 INFO OrientDB Server v1.6.0-SNAPSHOT is starting up... [OServer]
2013-09-30 14:26:19:770 INFO Databases directory: /home/cthiebault/orientdb/databases [OServer]
2013-09-30 14:26:19:771 INFO Listening binary connections on 0.0.0.0:2424 (protocol v.18) [OServerNetworkListener]
2013-09-30 14:26:19:771 INFO Listening http connections on 0.0.0.0:2480 (protocol v.10) [OServerNetworkListener]Exception in thread "main" java.lang.IllegalStateException: Timer already cancelled.
at java.util.Timer.sched(Timer.java:397)
at java.util.Timer.schedule(Timer.java:248)
at com.orientechnologies.orient.server.plugin.OServerPluginManager.startup(OServerPluginManager.java:67)
at com.orientechnologies.orient.server.OServer.registerPlugins(OServer.java:633)
at com.orientechnologies.orient.server.OServer.activate(OServer.java:218)
at org.obiba.opal.core.cfg.OrientDbServiceImpl.main(OrientDbServiceImpl.java:181)
Fixed in 1519a506e443992f6e3e865dbf75508da548876f
I can restart server only if I don't open a connection. See #1873 for failing test.
Created a new issue #1876