After further investigations, truth revealed to not be in multiple calls to the EmbeddedGraphDatabase
constructor, but instead to multiple identicail IndexProvider
being loaded.
I use neo4j embedded in an open-source JCA connector.
In this connector, the org.neo4j.kernel.Service
class is replaced by a custom one which contains a workaround regarding service loading for JBoss non shared libraries.
Unfortunatly, in our context, this workaround implies loading twice the index provider :
- once using the EAR classloader
- once using the Glassfish library classloader.
Why ?
Because, as our neo4j instance is using for application data AND for authentication, neo4j connector jar is put in ${domain}/lib
. As a consequence, due to Classloader delegation in application server, the EAR classloader delegates to the Glassfish library classloader, and find this way the LuceneIndexProvider
. Then, the Glassfish library classloader is directly used to load the same LuceneIndexProvider
class.
This concludes by us having two LuceneIndexProvider
objects, both trying to migrate the lucene index. Which lead to the AssertionError
as the write.lock
file created by the first object should be deleted by the second one, which can't do that.
I've then changed slightly that very specific class to use JBoss workaround only when default loading mechanism do not return any class (seee commit here). This small change worked like a charm, so I think you can considered this issue as fixed.