Project

General

Profile

Actions

Task #1013

closed

Application startup fails due to Flyway bug

Added by Alena Peterová almost 7 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Radek Tomiška
Category:
Release
Target version:
Start date:
03/06/2018
Due date:
% Done:

100%

Estimated time:
Owner:

Description

Affected version: 7.8.3 when updated from 7.8.2

Tomcat server fails to start with the following exception:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayCore' defined in class path resource [eu/bcvsolutions/idm/core/config/flyway/CoreFlywayConfig.class]: 
Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: Comparison method violates its general contract!

As Ondra advised, this is probably a bug in Flyway and can be resolved by adding -Djava.util.Arrays.useLegacyMergeSort=true to JAVA_OPTS.
If there is no other solution, please add this information to the release notes for 7.8.3 and to the guide for installation CzechIdM.


Related issues

Related to IdStory Identity Manager - Task #2167: Remove "useLegacyMergeSort=true" from Tomcat unit configurationClosedLuděk Urban03/31/2020

Actions
Actions #1

Updated by Alena Peterová almost 7 years ago

This happened on the following environment:
OS: Fedora release 26 (Twenty Six)
Tomcat: apache-tomcat-8.5.27
Java: OpenJDK Runtime Environment (build 1.8.0_161-b14)

IdM was installed according to our standard tutorial: https://wiki.czechidm.com/tutorial/adm/czechidm_installation

Actions #3

Updated by Alena Peterová almost 7 years ago

The same behaviour for Windows when upgraded from 7.8.1 to 7.8.3.
Java version: Oracle JDK 1.8.0_152

Resolved by adding -Djava.util.Arrays.useLegacyMergeSort=true to Tomcat configuration (C:\Program Files\Apache Software Foundation\Tomcat 8.5\bin\Tomcat8w.exe)

Actions #4

Updated by Marcel Poul almost 7 years ago

  • Priority changed from Normal to High
Actions #5

Updated by Radek Tomiška almost 7 years ago

  • Priority changed from High to Normal
  • % Done changed from 0 to 10

I've added note about this workaround into configuration and release notes:
- https://github.com/bcvsolutions/CzechIdMng/tree/develop/Realization/backend#known-issues
- https://wiki.czechidm.com/devel/documentation/application_configuration/backend#environment_properties
- https://wiki.czechidm.com/tutorial/adm/czechidm_installation#configure_environment_properties_select_application_profile
- https://github.com/bcvsolutions/CzechIdMng/releases/tag/7.8.3

I tried to find, how to fix it another way, i was not successful (i can set this property programmatically). We are using flyway 4.0, maybe new version will help, but i don't find an info about this bug in release notes. I leave this ticket open, if we will have some time to update flyway version (or this workaround will be configured programmatically).

Note: cannot be reproduced on environment:
Fedora 24
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)

Actions #6

Updated by Alena Peterová almost 7 years ago

Note: After all the flyway scripts were executed, I can start the application correctly without that added Java option. It looks like the problem exists only when the flyway script is applied during the first startup (after upgrade).
Since the problem didn't occur during previous upgrades, there could be some connection with the name/numbering of the 2 scripts added in the version 7.8.3.

Actions #7

Updated by Radek Tomiška almost 7 years ago

I checked syntax for all scripts and they seem to be correct:
https://flywaydb.org/documentation/migrations#naming-1

Actions #8

Updated by Radek Tomiška almost 7 years ago

I see it now:
...
V7_08_003__add-login-count-and-date-nullable.sql
V8_00_004__eav-short-text-type-indexes.sql
...
This could make this problems, i overlooked it.

Actions #9

Updated by Radek Tomiška almost 7 years ago

  • % Done changed from 10 to 50

I've added missing scripts V8_00_001 - V8_00_003 (just empty files). Files are ignored when installed version is higher than 7.8.0 (=> V8_00_004 and higher is applied), but this should help for future versions, when app is installed.

Actions #10

Updated by Ondřej Kopr almost 7 years ago

  • Status changed from New to In Progress

I checked this behavior on my local clean environment without setting property: -Djava.util.Arrays.useLegacyMergeSort=true and also on clean installation windows server 2016 and both cases works well! Thank you.

This ticket can be probably closed.

Actions #11

Updated by Ondřej Kopr almost 7 years ago

Yesterday I try upgrade docker image with IdM in version 7.7.0 and I received same error as above Comparison method violates its general contract! with property useLegacyMergeSort IdM starts correctly :(

Actions #12

Updated by Radek Tomiška almost 7 years ago

New script into versio 8 was added (V8_00_007), else script were aplied -> and now startup fails on my machine too, it's strange. So adding missing scripts didn't help.

Actions #13

Updated by Radek Tomiška almost 7 years ago

  • Status changed from In Progress to New
Actions #14

Updated by Alena Peterová over 6 years ago

Where to add -Djava.util.Arrays.useLegacyMergeSort=true (= where is JAVA_OPTS in our standard installation):

CentOS:
/etc/systemd/system/tomcat.service

Debian:
/etc/default/tomcat8

Windows:
C:\Program Files\Apache Software Foundation\Tomcat 8.5\bin\Tomcat8w.exe

Actions #15

Updated by Radek Tomiška over 4 years ago

  • Related to Task #2167: Remove "useLegacyMergeSort=true" from Tomcat unit configuration added
Actions #16

Updated by Radek Tomiška over 4 years ago

  • Status changed from New to Closed
  • Target version set to 10.4.0
  • % Done changed from 50 to 100

This issue not occus after Flyway was updated in CzechIdM version 10.x.

Actions

Also available in: Atom PDF