Open landryb opened 5 years ago
It also seems the first part of the error is because the WEB-INF/config-db/database_migration.xml
is looking for a org.fao.geonet.api.records.attachments.MetadataResourceDatabaseMigration
java class when doing the 3.1.0 migration, but the actual class is org.fao.geonet.MetadataResourceDatabaseMigration
after ea102cf21b49bd5bfdc95de70e07ebdd24c361fd - i think the migration config should be amended.
Fixing the class name in the database migration xml config file still fails at runtime, blows with:
Caused by: java.lang.NullPointerException
at org.fao.geonet.MetadataResourceDatabaseMigration.update(MetadataResourceDatabaseMigration.java:143)
... 29 more
which points to https://github.com/georchestra/geonetwork/blob/georchestra-gn3.4-18.06/core/src/main/java/org/fao/geonet/MetadataResourceDatabaseMigration.java#L143 and i have no idea why this would trigger an NPE. @fxprunayre any idea ?
@fxprunayre any idea ?
Sorry for late reply @landryb but I fear that the migration process may be triggered by spring before the SettingManager is initialized ? If this is the case, I would suggest to start without the Java migration step on startup and call it with the API after startup.
Something in this taste maybe (not tested, just an idea) ?
diff --git a/web/src/main/webResources/WEB-INF/config-db/database_migration.xml b/web/src/main/webResources/WEB-INF/config-db/database_migration.xml
index fd28fad..b2df2e6 100644
--- a/web/src/main/webResources/WEB-INF/config-db/database_migration.xml
+++ b/web/src/main/webResources/WEB-INF/config-db/database_migration.xml
@@ -30,7 +30,7 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
">
- <bean id="database-migration-bean" class="org.fao.geonet.DatabaseMigration">
+ <bean id="database-migration-bean" class="org.fao.geonet.DatabaseMigration" depends-on="SettingManager">
<property name="migration" ref="migrationMap"/>
<property name="initAfter" value="javax.sql.DataSource"/>
</bean>
Hi,
After investigating I found out that adding a explicit dependency on the SettingManager
bean is not enough, as the migration runs before this:
https://github.com/geonetwork/core-geonetwork/blob/07ad618e213df7090034f7356ab50d7d5f473e0a/web/src/main/java/org/fao/geonet/Geonetwork.java#L137-L140
As such, ApplicationContextHolder.get()
returns null
which causes all kinds of RTE.
The migration must somehow run as soon as the application context is available, but this goes beyond my skills in Java. If anyone has a clue, please help fix this as having a broken migration system really is a pain.
ui/config
should be migrated using JsonMigration now - see https://github.com/geonetwork/core-geonetwork/pull/3378. The default value is not part of the db creation/migration script anymore.
Still, that doesnt fix the case when someone upgrades from 3.0 to 3.4, and afaict 3.4 is still the stable branch...
Upgrading a database from 3.0.4 to 3.4.1 blows:
indeed, both v330 & v340 migrations try to set this key, with slightly different values...