Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to resolve properties file #1723

Closed
bennypi opened this issue Feb 26, 2021 · 5 comments · Fixed by #1744
Closed

Failed to resolve properties file #1723

bennypi opened this issue Feb 26, 2021 · 5 comments · Fixed by #1744

Comments

@bennypi
Copy link

bennypi commented Feb 26, 2021

Environment

Liquibase Version: 4.1.0 (it still doesn't work with 4.3.1, but with a different error message)

Liquibase Integration & Version: maven 4.1.0 (it still doesn't work with 4.3.1, but with a different error message)

Liquibase Extension(s) & Version: none

Database Vendor & Version: MySQL 8

Operating System Type & Version: Linux Mint Cinnamon, Azul JDK 11.0.10, Maven 3.6.3

Description

When running updateSQL from the maven plugin, the plugin seems to be having issues loading the liquibase.properties file. Although the file exists, liquibase cannot read it's contents and aborts the execution. The same setup works on Windows 10 machines with Java 11.

Steps To Reproduce

Clone this repo: https://github.com/bennypi/liquibase-test
Configure the liquibase.properties to use with an available MySQL 8 database
mvn clean package in the root of the project
cd db-module
mvn clean process-resources -Pgenerate-sql

Actual Behavior

See this maven output:

prangeGOVNTB279L ~/workspace/liquibase-test/db-module # mvn clean process-resources -Pgenerate-sql
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< org.example:db-module >------------------------
[INFO] Building db-module 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ db-module ---
[INFO] Deleting /home/boskg.local/prange/workspace/liquibase-test/db-module/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ db-module ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- liquibase-maven-plugin:4.1.0:updateSQL (default) @ db-module ---
[INFO] ------------------------------------------------------------------------
[project, pluginDescriptor]
[INFO] Parsing Liquibase Properties File
[INFO] File: /home/boskg.local/prange/workspace/liquibase-test/db-module/liquibase.properties
[WARNING] Cannot create filesystem for url file:/home/boskg.local/prange/workspace/liquibase-test/db-module/target/test-classes: /home/boskg.local/prange/workspace/liquibase-test/db-module/target/test-classes
java.nio.file.FileSystemNotFoundException: /home/boskg.local/prange/workspace/liquibase-test/db-module/target/test-classes
at jdk.nio.zipfs.ZipFileSystem. (ZipFileSystem.java:118)
at jdk.nio.zipfs.ZipFileSystemProvider.newFileSystem (ZipFileSystemProvider.java:136)
at java.nio.file.FileSystems.newFileSystem (FileSystems.java:406)
at liquibase.resource.ClassLoaderResourceAccessor.loadRootPaths (ClassLoaderResourceAccessor.java:63)
at liquibase.resource.ClassLoaderResourceAccessor.loadRootPaths (ClassLoaderResourceAccessor.java:79)
at liquibase.resource.ClassLoaderResourceAccessor.init (ClassLoaderResourceAccessor.java:47)
at liquibase.resource.ClassLoaderResourceAccessor.openStreams (ClassLoaderResourceAccessor.java:94)
at org.liquibase.maven.plugins.MavenResourceAccessor.openStreams (MavenResourceAccessor.java:21)
at liquibase.resource.CompositeResourceAccessor.openStreams (CompositeResourceAccessor.java:33)
at liquibase.resource.AbstractResourceAccessor.openStream (AbstractResourceAccessor.java:17)
at org.liquibase.maven.plugins.AbstractLiquibaseMojo.handlePropertyFileInputStream (AbstractLiquibaseMojo.java:560)
at org.liquibase.maven.plugins.AbstractLiquibaseMojo.configureFieldsAndValues (AbstractLiquibaseMojo.java:530)
at org.liquibase.maven.plugins.AbstractLiquibaseMojo.lambda$null$0 (AbstractLiquibaseMojo.java:374)
at liquibase.Scope.lambda$child$0 (Scope.java:160)
at liquibase.Scope.child (Scope.java:169)
at liquibase.Scope.child (Scope.java:159)
at liquibase.Scope.child (Scope.java:138)
at org.liquibase.maven.plugins.AbstractLiquibaseMojo.lambda$execute$1 (AbstractLiquibaseMojo.java:372)
at liquibase.Scope.lambda$child$0 (Scope.java:160)
at liquibase.Scope.child (Scope.java:169)
at liquibase.Scope.child (Scope.java:159)
at liquibase.Scope.child (Scope.java:138)
at liquibase.Scope.child (Scope.java:222)
at liquibase.Scope.child (Scope.java:226)
at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute (AbstractLiquibaseMojo.java:306)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.672 s
[INFO] Finished at: 2021-02-26T12:27:30+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:4.1.0:updateSQL (default) on project db-module: Failed to resolve the properties file. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

The liquibase.properties file does exist (the path is copied from the INFO logging from the maven output):

ls -al /home/boskg.local/prange/workspace/liquibase-test/db-module/liquibase.properties
-rw-r--r-- 1 prange domänen-benutzer 203 Feb 26 12:26 /home/boskg.local/prange/workspace/liquibase-test/db-module/liquibase.properties

Expected/Desired Behavior

The liquibase-maven-plugin performs the generateSQL goal and the SQL file is created.

Aditional Context

When using liquibase 4.3.1, the maven error is this one:

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:4.3.1:updateSQL (default) on project db-module: Properties file InputStream is null. -> [Help 1]

If necessary, I can provider the full stack trace for the 4.3.1 version using -X in the mvn command.

@molivasdat
Copy link
Contributor

Thanks @bennypi for adding this issue. I think this may be a configuration issue but I'm not a maven expert.
Take a look at this while I search internally for help.
https://stackoverflow.com/questions/35702756/how-to-make-test-class-read-data-from-target-and-not-target-test-classes-java

nvoxland added a commit that referenced this issue Mar 3, 2021
- Better handle file lookups in linux with FileSystemResourceAccessor

LB-1294
#1723
@nvoxland
Copy link
Contributor

nvoxland commented Mar 3, 2021

The issue is coming from how we handle our file lookup. I have a fix for it at #1744 which will probably go out in 4.4.0.

In the meantime, you should be able to work around the problem by making your <propertyFile> setting be simply <propertyFile>liquibase.properties</propertyFile> without the ${project.basedir} making it absolute.

Liquibase usually works best with paths that are relative to one of the configured resource root directories. For maven, ${project.basedir} is one of those, so you just have to specify liquibase.properties and the full path that project.basedir adds can get in the way.

@bennypi
Copy link
Author

bennypi commented Mar 4, 2021

Hi everyone,

thanks for the help.
The workaround by @nvoxland is working fine, after I removed ${project.basedir}/ from the <propertyFile> and ${project.basedir}/src/main/resources/ from <changeLogFile> it is working again.

@sync-by-unito
Copy link

sync-by-unito bot commented Mar 26, 2021

➤ Erzsebet Carmean commented:

Tested Liquibase 4.3.2-LB-1294-SNAPSHOT #3Issue reproduced on Mac with Liquibase 4.1.0. Thank you, Benny, for the example Git project. It was extremely helpful!Verify no null pointer exception is thrown when generate-sources profile runs. PASS
{NOFORMAT}
[project, pluginDescriptor]
[INFO] Parsing Liquibase Properties File
[INFO] File: /Users/erzsebet/Documents/workgit/liquibase-test/db-module/liquibase.properties
[INFO] Configured classpath location file:/Users/erzsebet/Documents/workgit/liquibase-test/db-module/target/test-classes does not exist
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO]
[INFO] Liquibase Community 4.3.2-LB-1294-SNAPSHOT by Datical
[INFO] ####################################################

1. _     _             _ _                      ##
2. | |   (_)           (_) |                     ##
3. | |    _  __ _ _   _ | |_   __ _ ___  ___   ##
4. | |   | |/ ` | | | | | ' \ / ` / |/  \  ##
5. | |___| | (_| | |_| | | |_) | (_| \__ \  __/  ##
6. \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___|  ##
7. | |                               ##
8. |_|                               ##

1. Get documentation at docs.liquibase.com       ##
2. Get certified courses at learn.liquibase.com  ## 
3. Free schema change activity reports at        ##
4. https://hub.liquibase.com                 ##
5. ##

####################################################
Starting Liquibase at 14:29:08 (version 4.3.2-LB-1294-SNAPSHOT #3 built at 2021-03-26 15:52+0000)
Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class is com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
[INFO] Char encoding not set! The created file will be system dependent!
[INFO] Output SQL Migration File: /Users/erzsebet/Documents/workgit/liquibase-test/db-module/target/sql/migrate-database-1.0-SNAPSHOT.sql
[INFO] Parsing Liquibase Properties File /Users/erzsebet/Documents/workgit/liquibase-test/db-module/liquibase.properties for changeLog parameters
[INFO] Executing on Database: jdbc:mysql://localhost:3306/mysql
[INFO] Successfully acquired change log lock
[INFO] Creating database history table with name: DATABASECHANGELOG
[WARNING] liquibase.statement.core.CreateSequenceStatement is not supported on mysql, but createSequence will still execute
[INFO] Sequence hibernate_sequence created
[INFO] Table TESTTABLE created
[INFO] ChangeSet Users/erzsebet/Documents/workgit/liquibase-test/db-module/src/main/resources/setup.xml::0-setup-tables::bennypi ran successfully in 13ms
[INFO] Successfully released change log lock
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
{NOFORMAT}
Verify the updateSQL command outputs the generated SQL. PASS
[^migrate-database-1.0-SNAPSHOT.sql]

Everything in manual testing looks good. Expect the fix for this bug in Liquibase v4.4.0.

@sync-by-unito
Copy link

sync-by-unito bot commented Mar 30, 2021

➤ Erzsebet Carmean commented:

Moving this ticket to ready to merge. Will release with Liquibase v4.4.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants