Comments (11)
I'm going to re-open this, since #206 improves it and also updates the docs.
from docker.
by running the command as DEBUG log-leve, i'm seeing the JAR file is there (in the overall search path)
[2022-10-03 23:34:03] FINE [liquibase.resource] Overall search path:
- /liquibase/.
- /liquibase/changelog
- /liquibase/classpath/postgres-socket-factory-1.7.0.jar
- /liquibase/internal/lib
- /liquibase/internal/lib/commons-collections4.jar
- /liquibase/internal/lib/commons-lang3.jar
- /liquibase/internal/lib/commons-text.jar
- /liquibase/internal/lib/connector-api.jar
- /liquibase/internal/lib/h2.jar
- /liquibase/internal/lib/hsqldb.jar
- /liquibase/internal/lib/jaxb-api.jar
- /liquibase/internal/lib/jaxb-core.jar
- /liquibase/internal/lib/jaxb-runtime.jar
- /liquibase/internal/lib/jaybird.jar
- /liquibase/internal/lib/jcc.jar
- /liquibase/internal/lib/liquibase-commercial.jar
- /liquibase/internal/lib/liquibase-core.jar
- /liquibase/internal/lib/mariadb-java-client.jar
- /liquibase/internal/lib/mssql-jdbc.jar
- /liquibase/internal/lib/ojdbc8.jar
- /liquibase/internal/lib/opencsv.jar
- /liquibase/internal/lib/picocli.jar
- /liquibase/internal/lib/postgresql.jar
- /liquibase/internal/lib/snakeyaml.jar
- /liquibase/internal/lib/snowflake-jdbc.jar
- /liquibase/internal/lib/sqlite-jdbc.jar
- /liquibase/lib
But still getting theClassNotFoundException
from docker.
hey @luisospina-sealed,
I think I manage to figure your issue out, not sure if it's a bug in liquibase or it's not the recommended way, but here's what I did:
- I downloaded the postgres-socket-factory with dependencies from GCP Github releases: https://storage.googleapis.com/cloud-sql-java-connector/v1.7.2/postgres-socket-factory-1.7.2-jar-with-dependencies.jar
- Then it was a bit of massaging the parameters. TL;DR instead of adding on
/changelog
, I've added them on/lib
, resulting in something like this:
docker run -it -v $(pwd)/src/main/resources:/liquibase/changelog -v $(pwd)/build/libs:/liquibase/lib liquibase/liquibase \
--classpath="/liquibase/lib:/liquibase/lib/postgres-socket-factory-1.7.2-jar-with-dependencies.jar" \
--changelog-file=/liquibase/changelog/db/liquibase-changelog.xml \
--url="jdbc:postgresql:///<DATABASE_NAME>?cloudSqlInstance=dbInstance&socketFactory=com.google.cloud.sql.postgres.SocketFactory&user=user&password=pwd" \
--log-level=DEBUG \
update
Now the error that I'm getting is:
Caused by: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to jdbc:postgresql:///<DATABASE_NAME>?cloudSqlInstance=dbInstance&socketFactory=com.google.cloud.sql.postgres.SocketFactory&user=*****&password=***** with driver org.postgresql.Driver. Something unusual has occurred to cause the driver to fail. Please report this exception.
at liquibase.database.ConnectionServiceFactory.create(ConnectionServiceFactory.java:35)
at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:217)
... 36 more
Caused by: liquibase.exception.DatabaseException: Connection could not be created to jdbc:postgresql:///<DATABASE_NAME>?cloudSqlInstance=dbInstance&socketFactory=com.google.cloud.sql.postgres.SocketFactory&user=*****&password=***** with driver org.postgresql.Driver. Something unusual has occurred to cause the driver to fail. Please report this exception.
at liquibase.database.jvm.JdbcConnection.open(JdbcConnection.java:91)
at com.datical.liquibase.ext.database.jvm.ProJdbcConnection.open(Unknown Source)
at liquibase.database.ConnectionServiceFactory.create(ConnectionServiceFactory.java:32)
... 37 more
Caused by: org.postgresql.util.PSQLException: Something unusual has occurred to cause the driver to fail. Please report this exception.
at org.postgresql.Driver.connect(Driver.java:314)
at liquibase.database.jvm.JdbcConnection.open(JdbcConnection.java:83)
... 39 more
Caused by: java.lang.RuntimeException: Unable to obtain credentials to communicate with the Cloud SQL API
at com.google.cloud.sql.core.CoreSocketFactory$ApplicationDefaultCredentialFactory.create(CoreSocketFactory.java:390)
at com.google.cloud.sql.core.CoreSocketFactory.getInstance(CoreSocketFactory.java:140)
at com.google.cloud.sql.core.CoreSocketFactory.connect(CoreSocketFactory.java:265)
at com.google.cloud.sql.postgres.SocketFactory.createSocket(SocketFactory.java:76)
at org.postgresql.core.PGStream.createSocket(PGStream.java:229)
at org.postgresql.core.PGStream.<init>(PGStream.java:98)
at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:109)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:235)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:247)
at org.postgresql.Driver.makeConnection(Driver.java:434)
at org.postgresql.Driver.connect(Driver.java:291)
... 40 more
Caused by: java.io.IOException: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.
at com.google.auth.oauth2.DefaultCredentialsProvider.getDefaultCredentials(DefaultCredentialsProvider.java:134)
at com.google.auth.oauth2.GoogleCredentials.getApplicationDefault(GoogleCredentials.java:125)
at com.google.auth.oauth2.GoogleCredentials.getApplicationDefault(GoogleCredentials.java:97)
at com.google.cloud.sql.core.CoreSocketFactory$ApplicationDefaultCredentialFactory.create(CoreSocketFactory.java:388)
... 51 more
But this is normal, since I don't have access to GCP.
Hope it helps :)
from docker.
I have a similar issue, but when creating an extended docker image with the neo4j plugin jar:
I'm using the dockerfile
FROM liquibase/liquibase:4.19
USER root
WORKDIR /liquibase/internal/lib/
RUN curl -o liquibase-neo4j.jar https://repo1.maven.org/maven2/org/liquibase/ext/liquibase-neo4j/4.20.0/liquibase-neo4j-4.20.0-full.jar
RUN chown liquibase: liquibase-neo4j.jar
WORKDIR /liquibase
USER liquibase
and when the image starts the following error occurs:
Unexpected error running Liquibase: Driver class was not specified and could not be determined from the url (jdbc:neo4j:bolt://localhost:54225)
I've confirmed that the url is correctly set and also I've tried placing the jar on /liquibase/internal/lib/
and /liquibase/lib/
with similar results.
Could we have another directory, besides the one to mount /liquibase/classpath
to mount the plugin jars?
from docker.
Hello,
I may have a related issue.
I am using "includeAll" with a specific "resourceComparator".
The resourceComparator is in a JAR listed at the container startup (located in /liquibase/lib), but the class is not found, giving the message "no resourceComparator defined - taking default implementation".
If I put a class like java.lang.String or a class from liquibase-core, the class is found.
But classes from an external JAR are not.
from docker.
Short answer:
You can add -v /path/to/your/lib/dir:/liquibase/lib
and it should work.
Longer answer:
Yes, the "classpath" setting in the docs and what gets exposed in the docker container doesn't work with extensions. The base problem is that "classpath" isn't really setting the classpath, it's a backwards-compatible name for the search-path which is only for changelog files.
For what to include in the classpath, liquibase ONLY looks in:
- /liquibase/internal/lib (for jars shipped with liquibase, so not where extensions/drivers get added)
- /liquibase/lib (for "global" jars to be used by all users of liquibase)
- ${PWD}/liquibase_libs (for "project" jars which may be different depending on your project)
I'm going to open a PR with a better volume mapping for /liquibase/lib
and improve the docs
from docker.
Hi @nvoxland,
The above suggestion fixed the issue.Steps I followed are:
- Changed my docker command to mount jar files folder to /liquibase/lib (and not /liquibase/classpath)
docker run --rm -v /path/to/my-project:/liquibase/changelog -v /path/to/my-project/lib:/liquibase/lib liquibase/liquibase:4.21.1 --defaultsFile=/liquibase/changelog/liquibase.properties update - Changed my classpath property in liquibase.properties file accordingly:
classpath=/liquibase/changelog:/liquibase/lib/redshift-jdbc42-2.1.0.9.jar:/liquibase/lib/liquibase-redshift-4.21.1.jar
The ’ Drivers and Extensions’ section of Liquibase docker page (https://hub.docker.com/r/liquibase/liquibase) needs to be changed.
Thanks.
from docker.
This forum post is also about this issue: https://forum.liquibase.org/t/unable-to-recognise-jar-file-for-liquibase-extension-to-redshift-via-classpath-property/8234
from docker.
I would suggest that anyone who has an issue putting their desired jar into /liquibase/lib
try instead to put it into /liquibase/liquibase_libs
instead using the following working dir:
WORKDIR "/liquibase"
we have a gradle task that pulls down our desired dependency and was putting it into lib
relative to the build (effectively putting it at /liquibase/lib
. This was working for months, then all of a sudden stopped working recently (turns out we were using the latest
tag - UH OH).
I tried quite a few different things (for some reason pinning the liquibase/liquibase
image to an older version was causing mismatch checksums on migrations that have previously run??
I ended up pulling the dependencies into liquibase_libs
relative to the build (which puts them into /liquibase/liquibase_libs
and this worked.
Thanks @nvoxland for adding all the paths so that I could try them all to see what ended up working.
from docker.
reopening issues as the fix applied in #206 broke something with lpm. Had to revert in #210.
from docker.
Users can also use LPM and we have this documented. Additionally users have expressed workarounds in this issue, so closing for now. Please feel free to re-open if the issue persists.
from docker.
Related Issues (20)
- Docker image vulnerabilities HOT 1
- Vulnerability libksba 1.3.5-2 CVE-2022-3515 HOT 4
- Vulnerbility commons-text (CVE-2022-42889) HOT 2
- can not execute `lpm` when using arm image HOT 4
- liquibase/liquibase:4.21.0 seems to contain liquibase 4.20.0 HOT 3
- JAVA_HOME not found on 4.18 and above HOT 6
- Security Vulnerabilities related to go version 1.19.3 HOT 3
- Ability to use extensions without creating a new image HOT 7
- rm -rf /var/lib/apt/lists/* HOT 5
- Liquibase 4.22.0 avalaible but not the docker image HOT 2
- Dockerfile.alpine.sqlplus how run sqlplus? HOT 1
- Vulnerabilities detected in the latest Alpine image HOT 2
- Wrong versions in docker images 4.23.1 / 4.23.2 HOT 1
- Rebuild of Dockerfile? HOT 1
- Postgres example filenames are switched
- HIGH severity CVEs found in Docker images HOT 3
- LPM is unable to create directory liquibase_libs on 4.26.0 HOT 1
- Postgres JDBC driver need to be updraded (CVE-2024-1597)
- New release needed with fix for postgres CVE HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docker.