cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

LifecycleException with GraphDatabaseFactory.newEmbeddedDatabase in OSGI

Hello,
I am new to neo4j and I want to embedd neo4j in an OSGI server.

I have created a neo4j-api bundle which embedd all neo4j related libraries and have created a neo4j-store which use the neo4j-api bundle and create an embedded graph database.

I have this exception at start-up :

 java.lang.RuntimeException: Error starting org.neo4j.graphdb.facade.GraphDatabaseFacadeFactory, /storage/cydu/SSIM/Biotech/dev/rdf-server/rdf-server-distribution/target/rdf-server-distribution-1.0.0-bin/rdf-server-distribution-1.0.0/db/data
        at org.neo4j.graphdb.facade.GraphDatabaseFacadeFactory.initFacade(GraphDatabaseFacadeFactory.java:232)
        at org.neo4j.graphdb.facade.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:148)
        at org.neo4j.graphdb.factory.GraphDatabaseFactory.newDatabase(GraphDatabaseFactory.java:133)
        at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:122)
        at org.neo4j.graphdb.factory.GraphDatabaseFactory$EmbeddedDatabaseCreator.newDatabase(GraphDatabaseFactory.java:178)
        at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:210)
        at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:79)
        at org.hug.simed.rdf.store.neo4j.MyStore.start(MyStore.java:61)
        at org.hug.simed.rdf.store.neo4j.impl.Activator.try_register(Activator.java:47)
        at org.hug.simed.rdf.store.neo4j.impl.Activator.start(Activator.java:71)
        at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:698)
        at org.apache.felix.framework.Felix.activateBundle(Felix.java:2402)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:2308)
        at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1539)
        at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
        at java.lang.Thread.run(Thread.java:748)
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.NeoStoreDataSource@7a8d46db' was successfully initialized, but failed to start. Please see the attached cause exception "Unknown setting: dbms.tx_log.rotation.size".
        at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:473)
        at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:111)
        at org.neo4j.kernel.impl.transaction.state.DataSourceManager.start(DataSourceManager.java:116)
        at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:452)
        at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:111)
        at org.neo4j.graphdb.facade.GraphDatabaseFacadeFactory.initFacade(GraphDatabaseFacadeFactory.java:227)
        ... 15 more
Caused by: java.lang.IllegalArgumentException: Unknown setting: dbms.tx_log.rotation.size
        at org.neo4j.kernel.configuration.Config.verifyValidDynamicSetting(Config.java:668)
        at org.neo4j.kernel.configuration.Config.registerDynamicUpdateListener(Config.java:711)
        at org.neo4j.kernel.impl.transaction.log.files.LogFilesBuilder.getRotationThresholdAndRegisterForUpdates(LogFilesBuilder.java:260)
        at org.neo4j.kernel.impl.transaction.log.files.LogFilesBuilder.buildContext(LogFilesBuilder.java:239)
        at org.neo4j.kernel.impl.transaction.log.files.LogFilesBuilder.build(LogFilesBuilder.java:182)
        at org.neo4j.kernel.NeoStoreDataSource.start(NeoStoreDataSource.java:331)
        at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:452)
        ... 20 more

Any suggestion how to configure the config file ?

thanks
Cyrille

4 REPLIES 4

Neo4j uses JVM's ServiceLoader to register available config options. See https://github.com/neo4j/neo4j/blob/3.5/community/kernel/src/main/resources/META-INF/services/org.ne... which refers to org.neo4j.graphdb.factory.GraphDatabaseSettings which contains the setting mentioned in the stacktrace.

My suspicion is that repackaging for OSGI does not aggreate the service loader file. Double check your META-INF/services/org.neo4j.configuration.LoadableConfig file.`

I have packed my bundle with keeping META-INF/services files and used the service loader mediator (cf. https://blog.osgi.org/2013/02/javautilserviceloader-in-osgi.html).

I check that the spi services are indeed availables as osgi services

g! inspect capability service 20
org.hug.simed.rdf.neo4j-api [20] provides:

..
service; org.neo4j.configuration.LoadableConfig with properties:
.org.apache.aries.spifly.provider.implclass = org.neo4j.graphdb.factory.GraphDatabaseSettings
service.bundleid = 20
service.id = 59
service.scope = bundle
serviceloader.mediator = 4
service; org.neo4j.configuration.LoadableConfig with properties:
.org.apache.aries.spifly.provider.implclass = org.neo4j.kernel.configuration.ssl.LegacySslPolicyConfig
service.bundleid = 20
service.id = 60
service.scope = bundle
serviceloader.mediator = 4
service; org.neo4j.configuration.LoadableConfig with properties:
.org.apache.aries.spifly.provider.implclass = org.neo4j.kernel.configuration.ssl.SslPolicyConfig
service.bundleid = 20
service.id = 61
service.scope = bundle
serviceloader.mediator = 4
service; org.neo4j.configuration.LoadableConfig with properties:
.org.apache.aries.spifly.provider.implclass = org.neo4j.kernel.impl.index.schema.config.SpatialIndexSettings
service.bundleid = 20
service.id = 62
service.scope = bundle
serviceloader.mediator = 4
service; org.neo4j.configuration.LoadableConfig with properties:
.org.apache.aries.spifly.provider.implclass = org.neo4j.kernel.configuration.ssl.SslSystemSettings
service.bundleid = 20
service.id = 63
service.scope = bundle
serviceloader.mediator = 4

Here is in my client bundle activator test code :

System.out.println("starting neo4j bundle..");

 ServiceLoader<LoadableConfig> serviceLoader = ServiceLoader.load(LoadableConfig.class);
Iterator<LoadableConfig> it = serviceLoader.iterator();

while( it.hasNext() ) {
  final LoadableConfig config = it.next();
  System.out.println("-> "+config);
}

final File databaseDirectory = new File("./db/data/neo-db");

db = new GraphDatabaseFactory()
  .newEmbeddedDatabaseBuilder( databaseDirectory )
  .newGraphDatabase();

And the output :

starting neo4j bundle..
-> org.neo4j.graphdb.factory.GraphDatabaseSettings@24b173a5
-> org.neo4j.kernel.configuration.ssl.LegacySslPolicyConfig@40023c2f
-> org.neo4j.kernel.configuration.ssl.SslPolicyConfig@5aa16064
-> org.neo4j.kernel.impl.index.schema.config.SpatialIndexSettings@32604d
-> org.neo4j.kernel.configuration.ssl.SslSystemSettings@34d38e70
ERROR: Bundle test.neo4j [26] Error starting file:/storage/cydu/SSIM/Biotech/dev/rdf-server/rdf-server-distribution/target/rdf-server-distribution-1.0.0-bin/rdf-server-distribution-1.0.0/bundle/test-neo4j.jar (org.osgi.framework.BundleException: Activator start error in bundle test.neo4j [26].)
java.lang.RuntimeException: Error starting org.neo4j.graphdb.facade.GraphDatabaseFacadeFactory, /storage/cydu/SSIM/Biotech/dev/rdf-server/rdf-server-distribution/target/rdf-server-distribution-1.0.0-bin/rdf-server-distribution-1.0.0/db/data
at org.neo4j.graphdb.facade.GraphDatabaseFacadeFactory.initFacade(GraphDatabaseFacadeFactory.java:232)
at org.neo4j.graphdb.facade.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:148)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newDatabase(GraphDatabaseFactory.java:133)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:122)
at org.neo4j.graphdb.factory.GraphDatabaseFactory$EmbeddedDatabaseCreator.newDatabase(GraphDatabaseFactory.java:178)
at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:210)
at org.hug.simed.rdf.test.impl.Activator.start(Activator.java:67)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:698)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:2402)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2308)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1539)
at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.NeoStoreDataSource@678fef7e' was successfully initialized, but failed to start. Please see the attached cause exception "Unknown setting: dbms.tx_log.rotation.size".
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:473)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:111)
at org.neo4j.kernel.impl.transaction.state.DataSourceManager.start(DataSourceManager.java:116)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:452)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:111)
at org.neo4j.graphdb.facade.GraphDatabaseFacadeFactory.initFacade(GraphDatabaseFacadeFactory.java:227)
... 12 more
Caused by: java.lang.IllegalArgumentException: Unknown setting: dbms.tx_log.rotation.size
at org.neo4j.kernel.configuration.Config.verifyValidDynamicSetting(Config.java:668)
at org.neo4j.kernel.configuration.Config.registerDynamicUpdateListener(Config.java:711)
at org.neo4j.kernel.impl.transaction.log.files.LogFilesBuilder.getRotationThresholdAndRegisterForUpdates(LogFilesBuilder.java:260)
at org.neo4j.kernel.impl.transaction.log.files.LogFilesBuilder.buildContext(LogFilesBuilder.java:239)
at org.neo4j.kernel.impl.transaction.log.files.LogFilesBuilder.build(LogFilesBuilder.java:182)
at org.neo4j.kernel.NeoStoreDataSource.start(NeoStoreDataSource.java:331)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:452)
... 17 more

I'd probably continue with a step debugger to drill down.

It seems that my neo4j-api bundle which contains neo4j artifacts need also to "see" SPI services providers.

I have added : <SPI-Consumer>*</SPI-Consumer> and it works ok.

I still need to figure out why I need to add this thing. I was convinced that this should work in the first place

😉