H2 and flyway crush on tests after upgrade from gradle 4 to 6 - spring-boot

I am in the process of upgrading from gradle 4 to 6.
This forced me to upgrade many stuff like spring, h2, mySql connector, etc..
Now I have this problem:
on runtime, using MySQL all works fine.
but on tests, I get:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway' defined in com.bluerbn.wallet.infra.SpringTestConfiguration: Invocation of init method failed; nested exception is org.flywaydb.core.internal.command.DbMigrate$FlywayMigrateException:
Migration V9__fixIndex.sql failed
------------------------------------------------
SQL State : 42S22
Error Code : 42122
Message : Column "INDEX" not found; SQL statement:
ALTER TABLE table1 DROP INDEX ACC_INDEX [42122-200]
Location : db/migration/V9__fixIndex.sql (/Users/.../resources/db/migration/V9__fixIndex.sql)
Line : 1
Statement : ALTER TABLE table1 DROP INDEX ACC_INDEX
This is an old script that was working fine before the upgrade.
versions:
spring boot: 2.3.0
org.flywaydb:flyway-core:6.4.1 (though in gradle I put 6.4.2)
com.h2database:h2:1.4.200
mysql:mysql-connector-java:8.0.18
Any ideas?

H2 since the version 1.4.200 allows MySQL-style ALTER TABLE tableName DROP INDEX indexName only in MySQL compatibility mode. In 1.4.199 and older versions this invalid (for H2) command was incorrectly accepted in all modes.
You need to append ;MODE=MySQL to JDBC URL for H2.

Related

Spring JPA- DB2 ZOS - Observing -104 error during shut down of DB2 LPAR

We are seeing the db2 -104 issue during db2 lpar graceful down testing, And it looks to be "SELECT 1" query is being executed during the lpar testing and this is only observed in DB2 log.
SQLerror, DSNT408I SQLCODE = -104, ERROR: ILLEGAL SYMBOL
"".
Query Executed : SELECT 1
Spring version : 2.1.7
IBM Db2 Jar version : db2jcc4.jar
Dialect : org.hibernate.dialect.DB2390Dialect
Any lead on how to stop or override this query being fired? We run on liberty server and excluded tomcat related dependencies as well.

Unable to create a table from Hive CLI - ERROR 23502

I seem to be getting the below exception when I try to create a table using Hive client.
create table if not exists test (id int, name string) comment 'test table';
11:15:32.016 [HiveServer2-Background-Pool: Thread-34] ERROR org.apache.hadoop.hive.metastore.RetryingHMSHandler - Retrying HMSHandler after 2000 ms (attempt 1 of 10) with error: javax.jdo.JDODataStoreException: Insert of object "org.apache.hadoop.hive.metastore.model.MTable#784fafc2" using statement "INSERT INTO TBLS (TBL_ID,CREATE_TIME,DB_ID,LAST_ACCESS_TIME,OWNER,RETENTION,SD_ID,TBL_NAME,TBL_TYPE,VIEW_EXPANDED_TEXT,VIEW_ORIGINAL_TEXT) VALUES (?,?,?,?,?,?,?,?,?,?,?)" failed : Column 'IS_REWRITE_ENABLED' cannot accept a NULL value.
at org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:543)
at org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:720)
Caused by: ERROR 23502: Column 'IS_REWRITE_ENABLED' cannot accept a NULL value.
at org.apache.derby.client.am.ClientStatement.completeExecute(Unknown Source)
at org.apache.derby.client.net.NetStatementReply.parseEXCSQLSTTreply(Unknown Source)
I did search but couldn't find a satisfactory resolution.
Here is my set up:
Hive 2.1.0
OS: Windows
Hadoop: 2.9.2
Derby: 10.14.2.0
What am i missing?
Thanks.
Seems like a compatibility issue with derby. I moved back to a earlier version of derby 10.2.1.1 and the issue went away.

flyway upgrade from 4.X to 5.x runs the already ran migration scripts again

I was upgrading springboot 2 from 1.5. For that, I upgraded the flyway from 4.X to 5.24. When I run the springboot application after that, it's executing scripts which were already executed. Below is the logs I am seeing. removing project specific names as I am not allowed to post it:
myproject INFO 2019-03-11T16:08:11-0400 main [org.flywaydb.core.internal.schemahistory.JdbcTableSchemaHistory] Creating Schema History table: "PUBLIC"."flyway_schema_history"
myproject INFO 2019-03-11T16:08:11-0400 main [org.flywaydb.core.internal.command.DbMigrate] Current version of schema "PUBLIC": << Empty Schema >>
myproject INFO 2019-03-11T16:08:11-0400 main [org.flywaydb.core.internal.command.DbMigrate] Migrating schema "PUBLIC" to version 1 - CREATE mything
myproject ERROR 2019-03-11T16:08:11-0400 main [org.flywaydb.core.internal.command.DbMigrate] Migration of schema "PUBLIC" to version 1 - CREATE mything failed! Please restore backups and roll back database and code!
myproject WARN 2019-03-11T16:08:11-0400 main [org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.command.DbMigrate$FlywayMigrateException:
Migration V1__CREATE_mything.sql failed
---------------------------------------
SQL State : 42509
Error Code : -5509
Message : type not found or user lacks privilege: SERIAL
I guess You are using default value for parameter table.name, which changed in v. 5.0.0.
Refer to https://flywaydb.org/documentation/releaseNotes
Issue 1848 The default for flyway.table has been changed from schema_version to flyway_schema_history

How do I find out which schema script spring-boot is running?

I have an application based on spring-boot 1.4 with spring-jdbc.
I've added Flyway, which works in the application itself, but I get errors for my JdbcDAO test cases.
Question: I know spring-boot overrides 'dataSource' to embedded HSQLDB datasource, but I have no idea where it finds the SQL scripts to populate the empty database when I run tests.
Documentation says that it looks for 'schema.sql' or 'data.sql' in classpath, but I've renamed all of the script files in both main and test resource paths, but I still get this error:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed;
nested exception is org.flywaydb.core.api.FlywayException: Found non-empty schema(s) "PUBLIC" without schema history table! Use baseline() or set baselineOnMigrate to true to initialize the schema history table.
This error leads me to believe that Spring-boot had created a schema definition BEFORE Flyway scripts were applied.
UPDATE: I'm getting a different error now, this is a Bad SQL error:
org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [INSERT INTO BLUECOST_SSCDATA (SSCDATAID,PROCESSGROUPID,COSTINGAMOUNT,CHRG_TYP_CD,CONTROL_GROUP_CD,ACCOUNT_ID,CHRGHS_END_DT,ORIG_LOC_CD,SERVICE_TYP_CD,SERVICE_CD,SERVICE_GROUP_ID,SERVICE_ENV_CD,SERVICE_ADDER_CD,SERVICE_RESTYP_CD,RATECLAS_CD,PRICELST_UP_AMT,CHRGHS_USAGE_QTY,EMP_FA_CD,EMP_DIV_CD,EMP_DPT_CD,EMP_COUNTRY_CD,EMP_COMPANY_CD,EMP_NUM,EMP_INITS,EMP_LASTNAME,USER_ID,ADJUSTMENT_ID,CUST_REFERENCE_ID,ORIG_DIV_CD,ORIG_DPT_ID,ORIG_COUNTRY_CD,ORIG_COMPANY_CD,LOCAL_FIELD_1,LOCAL_FIELD_2,LOCAL_FIELD_3,LOCAL_FIELD_4,LOCAL_FIELD_5,LOCAL_FIELD_6,CREATETIME,PROCESSTIME,LAST_ALTER_TMS,TRX_TYP_CD,FILENAME) VALUES (100,null,368.60,'CTA','EMEA ','D286148 ','2018-03-19','SLR','SLR','SLIC','BASE',null,null,null,'OGS',null,null,null,null,null,null,null,null,null,'IBM SLIC BV',null,null,null,null,null,'653','SOFTLAYR','INVCE ID','X91927','ACCNT ID','FILENAME1.XLS',null,null,{ts '2018-04-22 01:30:21.437000'},null,{ts '2018-03-22 01:32:21.437000'},'I','FILENAME1.XLS')]; nested exception is java.sql.SQLSyntaxErrorException: requires either DEFAULT keyword or OVERRIDING clause
at com.ibm.cio.cloud.cost.spreadsheet.dao.UTJdbcBluecostSSCDataDAOTest.testDeleteBluecostSSCDataByLocalField2AndLocalField4(UTJdbcBluecostSSCDataDAOTest.java:265)
Caused by: java.sql.SQLSyntaxErrorException: requires either DEFAULT keyword or OVERRIDING clause
at com.ibm.cio.cloud.cost.spreadsheet.dao.UTJdbcBluecostSSCDataDAOTest.testDeleteBluecostSSCDataByLocalField2AndLocalField4(UTJdbcBluecostSSCDataDAOTest.java:265)
Caused by: org.hsqldb.HsqlException: requires either DEFAULT keyword or OVERRIDING clause
at com.ibm.cio.cloud.cost.spreadsheet.dao.UTJdbcBluecostSSCDataDAOTest.testDeleteBluecostSSCDataByLocalField2AndLocalField4(UTJdbcBluecostSSCDataDAOTest.java:265)
This gives me a clue: looks like my latest Flyway script is not applied to the schema when running the 'mvn test' goal.
How do I turn on the debugging to see what is happening with Flyway when running mvn test goal?
Fixed - retracting this question now.
<logger name="org.flywaydb" level="DEBUG">
<appender-ref ref="STDOUT"/>
</logger>

Worklight 6.2 migration tool error

I am working on migrating data from WL 5.0.6.2 to 6.2. While doing that I encountered problems running data migration tool.
Background:
Approach:
we export the WRKLGHT table from 5062 DB to an intermediate DB for data migration so the running DB is not affected.
DBs:
1. schema: proj
its storing 5062 runtime data, upgrade-worklight-506-60-oracle.sql, upgrade-worklight-60-61-oracle.sql upgrade sql are executed.
2. schema: proj6
its blank DB at first, "create-worklightadmin-oracle.sql" is executed to prepare WLADMIN tables.
WL Project existing:
1. wlProj
its the app running on 5062 WL server
2. wlProj6
its the target project running on 6.2 WL, and data will be migrated to be used by this project
Steps:
1. recreate proj6 schema
1.1 SQLPlus -> connect as SYSTEM -> "drop user proj6 cascade"
1.2. -> "create user proj6 identified by {password}" -> "grant all privileges to proj6"
2. execute "create-worklightadmin-oracle.sql" on proj6 schema
2.1 SQLDeveloper -> connect as user proj6
2.2 run #"{ WL server install dir}/databases/create-worklightadmin-oracle.sql";
2.3 commit
3. Open cmd and run the following command
java -cp ojdbc6.jar;worklight-ant-deployer.jar com.ibm.worklight.config.dbmigration62.MigrationTool -p /wlProj -sourceurl jdbc:oracle:thin:#//192.168.0.**:1521/xe -sourcedriver oracle.jdbc.driver.OracleDriver -sourceuser proj -sourcepassword *** -targeturl jdbc:oracle:thin:#//192.168.0.***:1521/xe -targetdriver oracle.jdbc.driver.OracleDriver -targetuser proj6 -targetpassword *** 2>out.txt
'migrating wlProj-{ios,android}' & 'migrating access data record for wlProj-.....' are shown in cmd.
And in out.txt, the following error is shown.
15 WorklightManagementPU-oracle INFO [main] openjpa.Runtime - Starting OpenJPA 1.2.2
15 WorklightManagementPU-oracle INFO [main] openjpa.jdbc.JDBC - Using dictionary class "org.apache.openjpa.jdbc.sql.OracleDictionary".
com.ibm.worklight.config.dbmigration62.exceptions.MigrationException: FWLSE3406E: The applications migration failed with error The field "description" of instance "ApplicationEntity[id=51, name=wlProj, displayName=, description=null, thumbnail=null, platformVersion=null]" contained a null value; the metadata for this field specifies that nulls are illegal..
at com.ibm.worklight.config.dbmigration62.MigrationTool.run(MigrationTool.java:195)
at com.ibm.worklight.config.dbmigration62.MigrationTool.main(MigrationTool.java:128)
Caused by: <openjpa-1.2.2-r422266:898935 fatal user error> org.apache.openjpa.persistence.InvalidStateException: The field "description" of instance "ApplicationEntity[id=51, name=wlProj, displayName=, description=null, thumbnail=null, platformVersion=null]" contained a null value; the metadata for this field specifies that nulls are illegal.
at org.apache.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:540)
at org.apache.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:478)
at org.apache.openjpa.kernel.StateManagerImpl.preFlush(StateManagerImpl.java:2829)
at org.apache.openjpa.kernel.PNewState.beforeFlush(PNewState.java:39)
at org.apache.openjpa.kernel.StateManagerImpl.beforeFlush(StateManagerImpl.java:960)
at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1967)
at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1927)
at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1845)
at org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime.java:81)
at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1369)
at org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:877)
at org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:512)
at com.ibm.worklight.config.dbmigration62.ApplicationMigration.migrateApplication(ApplicationMigration.java:138)
at com.ibm.worklight.config.dbmigration62.ApplicationMigration.migrate(ApplicationMigration.java:63)
at com.ibm.worklight.config.dbmigration62.AbstractMigration.run(AbstractMigration.java:66)
at com.ibm.worklight.config.dbmigration62.MigrationTool.run(MigrationTool.java:183)
... 1 more
ERROR 20 : FWLSE3406E: The applications migration failed with error The field "description" of instance "ApplicationEntity[id=51, name=wlProj, displayName=, description=null, thumbnail=null, platformVersion=null]" contained a null value; the metadata for this field specifies that nulls are illegal..
This is recorded as IBM PMR #77138,999,738, and was identified as a defect that is currently being worked on.
There is no local fix to do other than wait for a fix via the support ticket.

Resources