During the migration " java.sql.SQLException: Flyway migration error occurred"

68 views
Skip to first unread message

Mariyapillai Jayakananthan

unread,
Jun 12, 2025, 12:39:25 PM6/12/25
to DSpace Technical Support
Dear Team ,
During the migratio dspace 6 to dsapce 8 versuion it's showing following error. 
Please anyone suggest to your ideas. many thanks in advance.
JK

Database URL: jdbc:postgresql://localhost:5432/dspace
Migrating database to latest version AND running previously "Ignored" migrations... (Check logs for details)
Migration exception:
java.sql.SQLException: Flyway migration error occurred
        at org.dspace.storage.rdbms.DatabaseUtils.updateDatabase(DatabaseUtils.java:838)
        at org.dspace.storage.rdbms.DatabaseUtils.updateDatabase(DatabaseUtils.java:725)
        at org.dspace.storage.rdbms.DatabaseUtils.main(DatabaseUtils.java:205)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:569)
        at org.dspace.app.launcher.ScriptLauncher.runOneCommand(ScriptLauncher.java:283)
        at org.dspace.app.launcher.ScriptLauncher.handleScript(ScriptLauncher.java:134)
        at org.dspace.app.launcher.ScriptLauncher.main(ScriptLauncher.java:99)
Caused by: org.flywaydb.core.internal.exception.FlywayMigrateException: SQL State  : null
Error Code : 0
Message    : Flyway executeSql() error occurred

        at org.flywaydb.core.internal.command.DbMigrate.doMigrateGroup(DbMigrate.java:402)
        at org.flywaydb.core.internal.command.DbMigrate.lambda$applyMigrations$1(DbMigrate.java:283)
        at org.flywaydb.core.internal.jdbc.TransactionalExecutionTemplate.execute(TransactionalExecutionTemplate.java:59)
        at org.flywaydb.core.internal.command.DbMigrate.applyMigrations(DbMigrate.java:282)
        at org.flywaydb.core.internal.command.DbMigrate.migrateGroup(DbMigrate.java:255)
        at org.flywaydb.core.internal.command.DbMigrate.lambda$migrateAll$0(DbMigrate.java:153)
        at org.flywaydb.database.postgresql.PostgreSQLAdvisoryLockTemplate.execute(PostgreSQLAdvisoryLockTemplate.java:77)
        at org.flywaydb.database.postgresql.PostgreSQLAdvisoryLockTemplate.lambda$execute$0(PostgreSQLAdvisoryLockTemplate.java:60)
        at org.flywaydb.core.internal.jdbc.TransactionalExecutionTemplate.execute(TransactionalExecutionTemplate.java:59)
        at org.flywaydb.database.postgresql.PostgreSQLAdvisoryLockTemplate.execute(PostgreSQLAdvisoryLockTemplate.java:60)
        at org.flywaydb.database.postgresql.PostgreSQLConnection.lock(PostgreSQLConnection.java:105)
        at org.flywaydb.core.internal.schemahistory.JdbcTableSchemaHistory.lock(JdbcTableSchemaHistory.java:149)
        at org.flywaydb.core.internal.command.DbMigrate.migrateAll(DbMigrate.java:153)
        at org.flywaydb.core.internal.command.DbMigrate.migrate(DbMigrate.java:104)
        at org.flywaydb.core.Flyway.lambda$migrate$1(Flyway.java:231)
        at org.flywaydb.core.FlywayExecutor.execute(FlywayExecutor.java:213)
        at org.flywaydb.core.Flyway.migrate(Flyway.java:177)
        at org.dspace.storage.rdbms.DatabaseUtils.updateDatabase(DatabaseUtils.java:825)
        ... 9 more
Caused by: java.sql.SQLException: Flyway executeSql() error occurred
        at org.dspace.storage.rdbms.DatabaseUtils.executeSql(DatabaseUtils.java:1253)
        at org.dspace.storage.rdbms.xmlworkflow.V6_0_2015_09_01__DS_2701_Enable_XMLWorkflow_Migration.migrate(V6_0_2015_09_01__DS_2701_Enable_XMLWorkflow_Migration.java:66)
        at org.flywaydb.core.internal.resolver.java.JavaMigrationExecutor.executeOnce(JavaMigrationExecutor.java:71)
        at org.flywaydb.core.internal.resolver.java.JavaMigrationExecutor.lambda$execute$0(JavaMigrationExecutor.java:61)
        at org.flywaydb.core.internal.database.DefaultExecutionStrategy.execute(DefaultExecutionStrategy.java:31)
        at org.flywaydb.core.internal.resolver.java.JavaMigrationExecutor.execute(JavaMigrationExecutor.java:60)
        at org.flywaydb.core.internal.command.DbMigrate.doMigrateGroup(DbMigrate.java:391)
        ... 26 more
Caused by: org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [--
-- The contents of this file are subject to the license and copyright
-- detailed in the LICENSE and NOTICE files at the root of the source
-- tree and available online at
--
-- http://www.dspace.org/license/
--

----------------------------------------------------
-- Database Schema Update for XML/Configurable Workflow
--
-- This file will automatically create/update your
-- DSpace Database tables to support XML/Configurable workflows.
-- However, it does NOT migrate your existing classic
-- workflows. That step is performed by the corresponding
-- "data_workflow_migration.sql" script.
--
-- This script is called automatically by the following
-- Flyway Java migration class:
-- org.dspace.storage.rdbms.xmlworkflow.V6_0_2015_09_01__DS_2701_Enable_XMLWorkflow_Migration
----------------------------------------------------

CREATE SEQUENCE cwf_workflowitem_seq;
CREATE SEQUENCE cwf_collectionrole_seq;

Mariyapillai Jayakananthan

unread,
Jun 13, 2025, 5:12:18 AM6/13/25
to DSpace Technical Support
Hi Team,
I used database skip version to make it success of the mirartion. After the this process when I am running indexing again getting error as follows:
Please anyone suggest some ideas to rectify this. 

@dspace:/dspace/bin# ./dspace index-discovery -b
usage: index-discovery
 -b,--build          (re)build index, wiping out current one if it exists
 -c,--clean          clean existing index removing any documents that no
                     longer exist in the db
 -d,--delete         delete all records from existing index
 -f,--force          if updating existing index, force each handle to be
                     reindexed even if uptodate
 -h,--help           print this help message
 -i,--index <arg>    add or update an Item, Collection or Community based
                     on its handle or uuid
 -r,--remove <arg>   remove an Item, Collection or Community from index
                     based on its handle
 -s,--spellchecker   Rebuild the spellchecker, can be combined with -b and
                     -f.
 -t,--type <arg>     reindex only specific type of (re)indexable objects;
                     options: [ClaimedTask, Collection, Community, Item,
                     PoolTask, XmlWorkflowItem, WorkspaceItem,
                     MetadataField, LDNMessageEntity]
org.apache.commons.cli.ParseException: Unable to create a new DSpace Context: Cannot invoke "org.dspace.core.DBConnection.setConnectionMode(boolean, boolean)" because "this.dbConnection" is null
        at org.dspace.discovery.IndexClient.setup(IndexClient.java:184)
        at org.dspace.scripts.DSpaceRunnable.parse(DSpaceRunnable.java:122)
        at org.dspace.scripts.DSpaceRunnable.initialize(DSpaceRunnable.java:95)
        at org.dspace.app.launcher.ScriptLauncher.executeScript(ScriptLauncher.java:149)
        at org.dspace.app.launcher.ScriptLauncher.handleScript(ScriptLauncher.java:132)
        at org.dspace.app.launcher.ScriptLauncher.main(ScriptLauncher.java:99)

DSpace Technical Support

unread,
Jul 16, 2025, 11:05:22 AM7/16/25
to DSpace Technical Support
Hi, 

If you are still encountering this issue, it seems to be saying that DSpace is unable to connect to your database.  It's possible your Database configurations in your "local.cfg" are incorrect.  However, more information may also be found in your dspace.log (it might give more information about the error).  See our troubleshooting guide for locating errors in logs: https://wiki.lyrasis.org/display/DSPACE/Troubleshoot+an+error#Troubleshootanerror-DSpace7.x(orabove)

Tim

Reply all
Reply to author
Forward
0 new messages