Import fails with 'Cannot drop an index inside a transaction' in an embedded server

I am unable to import a database in an embedded server, I see below exception,

java.lang.IllegalStateException: Cannot drop an index inside a transaction
at com.orientechnologies.orient.core.index.OIndexManagerShared.dropIndex(
at com.orientechnologies.orient.core.index.OIndexManagerProxy.dropIndex(
at com.orientechnologies.orient.core.db.tool.ODatabaseImport.removeDefaultNonSecurityClasses(
at com.orientechnologies.orient.core.db.tool.ODatabaseImport.importDatabase(

Any export or import options to resolve this issue?

Usually if you create an embedded server you have something like:

            server = OServerMain.create();

you can then do something like:

 ODatabaseDocumentInternal db = server.openDatabase(dbName);
 ODatabaseImport dbImport = new ODatabaseImport(db, "config/schema.gz", listener);

You can also do this with a graph factory instance:

ODatabaseDocumentInternal db = (ODatabaseDocumentInternal) getFactory().getNoTx().getRawDatabase();

Thanks for the reply Jon, but my problem is different when I call dbImport.importDatabase(); I get an exception - java.lang.IllegalStateException: Cannot drop an index inside a transaction.

I want a resolution for this issue.

Can you post the code ? I think this may be related to how you open the db instance. Are you using a non-tx graph instance?

ODatabaseDocumentTx dbtx = m_orientGraph.getRawGraph();
    OCommandOutputListener listener = new OCommandOutputListener() {
        public void onMessage(String iText) {
    ODatabaseImport imprt = new ODatabaseImport(dbtx, sImportFilename, listener);

FYI, I am not using a non-tx graph instance.

hm looks fine. I highly assume, as you set “merge” to false your import overrides everything and therefore tries to drop the existing indexes which is obviously not allowed in a transaction. Have you tried using a non-tx graph once?

Thanks Jon, I tried setting the “Merge” flag as true and it stopped failing with the exception but now seeing another one

com.orientechnologies.orient.core.exception.ODatabaseException:  Impossible to remove the last cluster of class 'Group' drop the class instead
DB name="cachedb1"
at com.orientechnologies.orient.core.metadata.schema.OClassImpl.removeClusterId(
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.dropCluster(
at com.orientechnologies.orient.core.db.tool.ODatabaseImport.importClusters(
at com.orientechnologies.orient.core.db.tool.ODatabaseImport.importDatabase(

which orientdb version are you using?

2.2.34 Community edition.

I would recommend updating. Not only because 2.2.x is deprecated (3.1. recent GA) but it seems there was a bug causing your issue: