SQL File not found when running liquibase update from sqlcl

1.4k views Asked by At

The problem is simple: liquibase fails to find my changeset sqlfile to run it against my db.

Paths are as follows:

  • SqlCl: C:\Oracle\sqlcl
  • No CLASSPATH is defined in user env variables
  • Main changelog file: C:\repos\odb\db-scripts\main.yaml
  • Changeset sqlfile: C:\repos\odb\db-scripts\test.sql

main.yaml contains:

databaseChangeLog:

  - changeSet:
      id: 1
      author: some_author
      changes:
        - sqlFile:
            path: test.sql
            splitStatements: true
            endDelimiter: /
            stripComments: true

test.sql contains:

create or replace view asdas
as
select 1 val from dual
/

What I get when I run liquibase update via sqlcl:

C:\repos\odb\db-scripts>sql stat_adm@dev-odb1
Picked up JAVA_TOOL_OPTIONS: -Duser.language=en

SQLcl: Release 20.4 Production on Tue May 25 18:03:50 2021

Copyright (c) 1982, 2021, Oracle.  All rights reserved.

Password? (**********?) ********
Last Successful login time: Tue May 25 2021 18:03:55 +03:00

Connected to:
Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production
Version 19.7.0.0.0


SQL> lb update -changelog main.yaml

Processing has failed for your request.
liquibase.exception.UnexpectedLiquibaseException: java.io.IOException: The file test.sql was not found in
    - C:\Oracle\jdbc\lib\ojdbc8.jar
    - C:\Oracle\jlib\orai18n-mapping.jar
    - C:\Oracle\jlib\orai18n-utility.jar
    - C:\Oracle\jlib\orai18n.jar
    - C:\Oracle\lib\ojdbc8.jar
    - C:\Oracle\modules\oracle.xdk\xmlparserv2.jar
    - C:\Oracle\rdbms\jlib\xdb6.jar
    - C:\Oracle\sqlcl\lib
    - C:\Oracle\sqlcl\lib\ST4.jar
    - C:\Oracle\sqlcl\lib\antlr-runtime.jar
    - C:\Oracle\sqlcl\lib\commons-codec.jar
    - C:\Oracle\sqlcl\lib\commons-logging.jar
    - C:\Oracle\sqlcl\lib\dbtools-common.jar
    - C:\Oracle\sqlcl\lib\dbtools-data.jar
    - C:\Oracle\sqlcl\lib\dbtools-http.jar
    - C:\Oracle\sqlcl\lib\dbtools-net.jar
    - C:\Oracle\sqlcl\lib\dbtools-sqlcl.jar
    - C:\Oracle\sqlcl\lib\ext
    - C:\Oracle\sqlcl\lib\ext\dbtools-liquibase.jar
    - C:\Oracle\sqlcl\lib\ext\dbtools-modeler-cli-ext.jar
    - C:\Oracle\sqlcl\lib\ext\dbtools-modeler-common.jar
    - C:\Oracle\sqlcl\lib\ext\liquibase-core.jar
    - C:\Oracle\sqlcl\lib\ext\migration-core.jar
    - C:\Oracle\sqlcl\lib\ext\migration-postgres.jar
    - C:\Oracle\sqlcl\lib\ext\snakeyaml-1.12.jar
    - C:\Oracle\sqlcl\lib\guava.jar
    - C:\Oracle\sqlcl\lib\httpclient.jar
    - C:\Oracle\sqlcl\lib\httpcore.jar
    - C:\Oracle\sqlcl\lib\httpmime.jar
    - C:\Oracle\sqlcl\lib\jackson-annotations.jar
    - C:\Oracle\sqlcl\lib\jackson-core.jar
    - C:\Oracle\sqlcl\lib\jackson-jr-objects.jar
    - C:\Oracle\sqlcl\lib\jackson-jr-stree.jar
    - C:\Oracle\sqlcl\lib\jansi.jar
    - C:\Oracle\sqlcl\lib\javax.json.jar
    - C:\Oracle\sqlcl\lib\jdbcrest.jar
    - C:\Oracle\sqlcl\lib\jline.jar
    - C:\Oracle\sqlcl\lib\ojdbc8.jar
    - C:\Oracle\sqlcl\lib\oraclepki.jar
    - C:\Oracle\sqlcl\lib\orai18n-collation.jar
    - C:\Oracle\sqlcl\lib\orai18n-mapping.jar
    - C:\Oracle\sqlcl\lib\orai18n-servlet.jar
    - C:\Oracle\sqlcl\lib\orai18n-utility.jar
    - C:\Oracle\sqlcl\lib\orai18n.jar
    - C:\Oracle\sqlcl\lib\orajsoda.jar
    - C:\Oracle\sqlcl\lib\osdt_cert.jar
    - C:\Oracle\sqlcl\lib\osdt_core.jar
    - C:\Oracle\sqlcl\lib\slf4j-api.jar
    - C:\Oracle\sqlcl\lib\slf4j-jdk14.jar
    - C:\Oracle\sqlcl\lib\sshd-common.jar
    - C:\Oracle\sqlcl\lib\sshd-contrib.jar
    - C:\Oracle\sqlcl\lib\sshd-core.jar
    - C:\Oracle\sqlcl\lib\xdb6.jar
    - C:\Oracle\sqlcl\lib\xmlparserv2-sans-jaxp-services.jar
    - C:\Oracle\sqlcl\lib\xmlparserv2.jar
    - C:\Program Files\Java\jre1.8.0_271\lib\ext\access-bridge-64.jar
    - C:\Program Files\Java\jre1.8.0_271\lib\ext\cldrdata.jar
    - C:\Program Files\Java\jre1.8.0_271\lib\ext\dnsns.jar
    - C:\Program Files\Java\jre1.8.0_271\lib\ext\jaccess.jar
    - C:\Program Files\Java\jre1.8.0_271\lib\ext\jfxrt.jar
    - C:\Program Files\Java\jre1.8.0_271\lib\ext\localedata.jar
    - C:\Program Files\Java\jre1.8.0_271\lib\ext\nashorn.jar
    - C:\Program Files\Java\jre1.8.0_271\lib\ext\sunec.jar
    - C:\Program Files\Java\jre1.8.0_271\lib\ext\sunjce_provider.jar
    - C:\Program Files\Java\jre1.8.0_271\lib\ext\sunmscapi.jar
    - C:\Program Files\Java\jre1.8.0_271\lib\ext\sunpkcs11.jar
    - C:\Program Files\Java\jre1.8.0_271\lib\ext\zipfs.jar
    - C:\jdbc\lib\ojdbc8.jar
    - C:\jlib\orai18n-mapping.jar
    - C:\jlib\orai18n-utility.jar
    - C:\jlib\orai18n.jar
    - C:\rdbms\jlib\xdb6.jar
    - C:\repos\odb\db-scripts\ST4-4.3.1.jar
    - C:\repos\odb\db-scripts\antlr-runtime-3.5.2.jar
    - C:\repos\odb\db-scripts\commons-codec-1.15.jar
    - C:\repos\odb\db-scripts\commons-logging-1.2.0.0.1.jar
    - C:\repos\odb\db-scripts\dbtools-common-20.4.1.jar
    - C:\repos\odb\db-scripts\dbtools-data-20.4.1.jar
    - C:\repos\odb\db-scripts\dbtools-http-20.4.1.jar
    - C:\repos\odb\db-scripts\dbtools-net-20.4.1.jar
    - C:\repos\odb\db-scripts\dbtools-sqlcl-20.4.1.jar
    - C:\repos\odb\db-scripts\guava-30.0-jre.jar
    - C:\repos\odb\db-scripts\httpclient-4.5.13.jar
    - C:\repos\odb\db-scripts\httpcore-4.4.13.jar
    - C:\repos\odb\db-scripts\httpmime-4.5.13.jar
    - C:\repos\odb\db-scripts\jackson-annotations-2.11.3.jar
    - C:\repos\odb\db-scripts\jackson-core-2.11.3.jar
    - C:\repos\odb\db-scripts\jackson-jr-objects-2.11.3.jar
    - C:\repos\odb\db-scripts\jackson-jr-stree-2.11.3.jar
    - C:\repos\odb\db-scripts\jansi-1.18.jar
    - C:\repos\odb\db-scripts\javax.activation-api-1.2.0.jar
    - C:\repos\odb\db-scripts\javax.json-1.1.4.jar
    - C:\repos\odb\db-scripts\jaxb-api-2.4.0-b180830.0359.jar
    - C:\repos\odb\db-scripts\jdbcrest-20.4.1.jar
    - C:\repos\odb\db-scripts\jline-2.14.6.jar
    - C:\repos\odb\db-scripts\low-level-api-13.0.0.jar
    - C:\repos\odb\db-scripts\ojdbc8-21.0.0.jar
    - C:\repos\odb\db-scripts\oraclepki-21.0.0.jar
    - C:\repos\odb\db-scripts\orai18n-21.0.0.jar
    - C:\repos\odb\db-scripts\orai18n-mapping-21.0.0.jar
    - C:\repos\odb\db-scripts\orai18n-utility-21.0.0.jar
    - C:\repos\odb\db-scripts\orajsoda-1.1.3.jar
    - C:\repos\odb\db-scripts\osdt_cert-21.0.0.jar
    - C:\repos\odb\db-scripts\osdt_core-21.0.0.jar
    - C:\repos\odb\db-scripts\slf4j-api-1.7.30.jar
    - C:\repos\odb\db-scripts\slf4j-jdk14-1.7.30.jar
    - C:\repos\odb\db-scripts\sshd-common-2.5.0.jar
    - C:\repos\odb\db-scripts\sshd-contrib-2.5.0.jar
    - C:\repos\odb\db-scripts\sshd-core-2.5.0.jar
    - C:\repos\odb\db-scripts\sshd-scp-2.5.0.jar
    - C:\repos\odb\db-scripts\sshd-sftp-2.5.0.jar
    - C:\repos\odb\db-scripts\ucp-21.0.0.jar
    - C:\repos\odb\db-scripts\xdb6-21.0.0.jar
Specifying files by absolute path was removed in Liquibase 4.0. Please use a relative path or add '/' to the classpath parameter.

SQL>

Somehow it picks up C:\repos\odb\db-scripts\ path but there are just imaginary jar that don't persist there. By the way paths C:\jdbc\lib\, C:\jlib\, C:\rdbms\jlib\xdb6.jar don't even exist on my machine.

Adding relativeToChangelogFile: true to main.yaml doesn't help.

How should I tell sqlcl to pick up test.sql file from the current directory or at least provide a full path?

EDIT:

I decided to run it using liquibase itself. I downloaded liquibase installation zip archive and took liquibase.bat from it and put it into sqlcl installation path. Then I added this path to my PATH variable so that I can call it from command line.

Also I created in C:\repos\odb\db-scripts\ file liquibase.properties with the following contents:

changeLogFile: main.yaml
driver: oracle.jdbc.OracleDriver
url: jdbc:oracle:thin:@mega-db-host:1521/odb1
username: usr
password: pwd

Note that C:\repos\odb\db-scripts\ is the same dir for test.sql and main.yaml. After that I've run liquibase:

C:\repos\odb\db-scripts>liquibase update
Picked up JAVA_TOOL_OPTIONS: -Duser.language=en
####################################################
##   _     _             _ _                      ##
##  | |   (_)           (_) |                     ##
##  | |    _  __ _ _   _ _| |__   __ _ ___  ___   ##
##  | |   | |/ _` | | | | | '_ \ / _` / __|/ _ \  ##
##  | |___| | (_| | |_| | | |_) | (_| \__ \  __/  ##
##  \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___|  ##
##              | |                               ##
##              |_|                               ##
##                                                ##
##  Get documentation at docs.liquibase.com       ##
##  Get certified courses at learn.liquibase.com  ##
##  Get advanced features and support at          ##
##      liquibase.com/support                     ##
##                                                ##
####################################################
Starting Liquibase at 10:11:50 (version 4.1.1 #0 built at 2020-11-02 16:02+0000)
ScriptRunner Executing: create or replace view asdas
as
select 1 val from dualLiquibase Executed:create or replace view asdas
as
select 1 val from dual
Liquibase: Update has been successful.

See: no errors. After that I decided to set non-existing path to sql file and guess what I've got:

C:\repos\odb\db-scripts>liquibase update
Picked up JAVA_TOOL_OPTIONS: -Duser.language=en
####################################################
##   _     _             _ _                      ##
##  | |   (_)           (_) |                     ##
##  | |    _  __ _ _   _ _| |__   __ _ ___  ___   ##
##  | |   | |/ _` | | | | | '_ \ / _` / __|/ _ \  ##
##  | |___| | (_| | |_| | | |_) | (_| \__ \  __/  ##
##  \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___|  ##
##              | |                               ##
##              |_|                               ##
##                                                ##
##  Get documentation at docs.liquibase.com       ##
##  Get certified courses at learn.liquibase.com  ##
##  Get advanced features and support at          ##
##      liquibase.com/support                     ##
##                                                ##
####################################################
Starting Liquibase at 10:12:44 (version 4.1.1 #0 built at 2020-11-02 16:02+0000)
Unexpected error running Liquibase: java.io.IOException: The file not_exists.sql was not found in
    - C:\Oracle\sqlcl\lib
    - C:\Oracle\sqlcl\lib\ST4.jar
    - C:\Oracle\sqlcl\lib\antlr-runtime.jar
    - C:\Oracle\sqlcl\lib\commons-codec.jar
    - C:\Oracle\sqlcl\lib\commons-logging.jar
    - C:\Oracle\sqlcl\lib\dbtools-common.jar
    - C:\Oracle\sqlcl\lib\dbtools-data.jar
    - C:\Oracle\sqlcl\lib\dbtools-http.jar
    - C:\Oracle\sqlcl\lib\dbtools-net.jar
    - C:\Oracle\sqlcl\lib\dbtools-sqlcl.jar
    - C:\Oracle\sqlcl\lib\ext\dbtools-liquibase.jar
    - C:\Oracle\sqlcl\lib\ext\dbtools-modeler-cli-ext.jar
    - C:\Oracle\sqlcl\lib\ext\dbtools-modeler-common.jar
    - C:\Oracle\sqlcl\lib\ext\liquibase-core.jar
    - C:\Oracle\sqlcl\lib\ext\migration-core.jar
    - C:\Oracle\sqlcl\lib\ext\migration-postgres.jar
    - C:\Oracle\sqlcl\lib\ext\snakeyaml-1.12.jar
    - C:\Oracle\sqlcl\lib\guava.jar
    - C:\Oracle\sqlcl\lib\httpclient.jar
    - C:\Oracle\sqlcl\lib\httpcore.jar
    - C:\Oracle\sqlcl\lib\httpmime.jar
    - C:\Oracle\sqlcl\lib\jackson-annotations.jar
    - C:\Oracle\sqlcl\lib\jackson-core.jar
    - C:\Oracle\sqlcl\lib\jackson-jr-objects.jar
    - C:\Oracle\sqlcl\lib\jackson-jr-stree.jar
    - C:\Oracle\sqlcl\lib\jansi.jar
    - C:\Oracle\sqlcl\lib\javax.activation-api.jar
    - C:\Oracle\sqlcl\lib\javax.json.jar
    - C:\Oracle\sqlcl\lib\jaxb-api.jar
    - C:\Oracle\sqlcl\lib\jdbcrest.jar
    - C:\Oracle\sqlcl\lib\jline.jar
    - C:\Oracle\sqlcl\lib\low-level-api.jar
    - C:\Oracle\sqlcl\lib\ojdbc8.jar
    - C:\Oracle\sqlcl\lib\oraclepki.jar
    - C:\Oracle\sqlcl\lib\orai18n-mapping.jar
    - C:\Oracle\sqlcl\lib\orai18n-utility.jar
    - C:\Oracle\sqlcl\lib\orai18n.jar
    - C:\Oracle\sqlcl\lib\orajsoda.jar
    - C:\Oracle\sqlcl\lib\osdt_cert.jar
    - C:\Oracle\sqlcl\lib\osdt_core.jar
    - C:\Oracle\sqlcl\lib\slf4j-api.jar
    - C:\Oracle\sqlcl\lib\slf4j-jdk14.jar
    - C:\Oracle\sqlcl\lib\snakeyaml-1.12.jar
    - C:\Oracle\sqlcl\lib\sshd-common.jar
    - C:\Oracle\sqlcl\lib\sshd-contrib.jar
    - C:\Oracle\sqlcl\lib\sshd-core.jar
    - C:\Oracle\sqlcl\lib\sshd-scp.jar
    - C:\Oracle\sqlcl\lib\sshd-sftp.jar
    - C:\Oracle\sqlcl\lib\ucp.jar
    - C:\Oracle\sqlcl\lib\xdb6.jar
    - C:\Oracle\sqlcl\lib\xmlparserv2-sans-jaxp-services.jar
    - C:\Program Files\Java\jre1.8.0_271\lib\ext\access-bridge-64.jar
    - C:\Program Files\Java\jre1.8.0_271\lib\ext\cldrdata.jar
    - C:\Program Files\Java\jre1.8.0_271\lib\ext\dnsns.jar
    - C:\Program Files\Java\jre1.8.0_271\lib\ext\jaccess.jar
    - C:\Program Files\Java\jre1.8.0_271\lib\ext\jfxrt.jar
    - C:\Program Files\Java\jre1.8.0_271\lib\ext\localedata.jar
    - C:\Program Files\Java\jre1.8.0_271\lib\ext\nashorn.jar
    - C:\Program Files\Java\jre1.8.0_271\lib\ext\sunec.jar
    - C:\Program Files\Java\jre1.8.0_271\lib\ext\sunjce_provider.jar
    - C:\Program Files\Java\jre1.8.0_271\lib\ext\sunmscapi.jar
    - C:\Program Files\Java\jre1.8.0_271\lib\ext\sunpkcs11.jar
    - C:\Program Files\Java\jre1.8.0_271\lib\ext\zipfs.jar
    - C:\repos\odb\db-scripts
    - C:\repos\odb\db-scripts\.
Specifying files by absolute path was removed in Liquibase 4.0. Please use a relative path or add '/' to the classpath parameter.
For more information, please use the --logLevel flag

Note that liquibase added the current directory on the lookup list. And that's why it managed to find my test.sql file. Looks like sqlcl is the one who fails to use the current path for SQL files.

0

There are 0 answers