英文:
JAVA SpringBoot : when inside a Docker the liquibase plugin runs with errors and does not execute changelogs
问题
I know that the same question was already asked but i have no way to ask the user if he solved it and his question is not complete enough to get help from other users
So I will include more info here to try and have this problem solved :
I have a springboot app running fine for several months on docker. I am in the process of adding the spring liquibase plugin to this app. This plugin works correctly on my local computer, but when I run it in the docker, I have the following errors (and the liquibase changelogs are not performed):
One example of the error is below, but about 400 of these appear in the log, one for each jar in the classpath. The example below is the last of those errors, and it refers to "jakarta.validation-api-2.0.2.jar" as the first line shows. However, the issue is not with this particular jar; something must be wrong in my implementation of Liquibase in the docker that runs this app.
2020-09-01 00:11:11.219 WARN 1 --- [ main] liquibase.resource : Cannot create filesystem for url jar:file:/opt/target/hov2.jar!/BOOT-INF/lib/jakarta.validation-api-2.0.2.jar!/: null
java.nio.file.FileSystemNotFoundException: null
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.getFileSystem(Unknown Source) ~[jdk.zipfs:na]
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.getPath(Unknown Source) ~[jdk.zipfs:na]
at java.base/java.nio.file.Path.of(Unknown Source) ~[na:na]
at java.base/java.nio.file.Paths.get(Unknown Source) ~[na:na]
at liquibase.resource.ClassLoaderResourceAccessor.loadRootPaths(ClassLoaderResourceAccessor.java:63) ~[liquibase-core-4.0.0.jar!/:na]
... (The log continues)
The pom.xml
to see the versions used:
<!-- The content of your pom.xml with dependency versions -->
The liquibase-dev.properties
:
<!-- The content of your liquibase-dev.properties -->
The Dockerfile
:
<!-- The content of your Dockerfile -->
And the result of the Docker build gives:
<!-- The content of the Docker build log -->
The dev.properties
for the Liquibase part:
<!-- The content of your dev.properties related to Liquibase -->
When starting the Docker (with the dev context), everything goes...
英文:
I know that the same question was already asked but i have no way to ask the user if he solved it and his question is not complete enough to get help from other users
So I will include more info here to try and have this problem solved :
I have a springboot app running fine for several month on docker, I am in process of adding to this app the spring liquibase plugin, this plugin works correctly on my local computer but when I run it in the docker I have the following errors (and the liquibase changelogs are not performed) :
One Exemple of the error is below but about 400 of these appear on the log, one for each jar in the classpath... the exemple below is the last of those errors and it refers to "jakarta.validation-api-2.0.2.jar" as the first line shows, but the issue is not with this particular jar, something must be wrong in my implementation of Liquibase in the docker that runs this app.
2020-09-01 00:11:11.219 WARN 1 --- [ main] liquibase.resource : Cannot create filesystem for url jar:file:/opt/target/hov2.jar!/BOOT-INF/lib/jakarta.validation-api-2.0.2.jar!/: null
java.nio.file.FileSystemNotFoundException: null
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.getFileSystem(Unknown Source) ~[jdk.zipfs:na]
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.getPath(Unknown Source) ~[jdk.zipfs:na]
at java.base/java.nio.file.Path.of(Unknown Source) ~[na:na]
at java.base/java.nio.file.Paths.get(Unknown Source) ~[na:na]
at liquibase.resource.ClassLoaderResourceAccessor.loadRootPaths(ClassLoaderResourceAccessor.java:63) ~[liquibase-core-4.0.0.jar!/:na]
at liquibase.resource.ClassLoaderResourceAccessor.init(ClassLoaderResourceAccessor.java:47) ~[liquibase-core-4.0.0.jar!/:na]
at liquibase.resource.ClassLoaderResourceAccessor.openStreams(ClassLoaderResourceAccessor.java:94) ~[liquibase-core-4.0.0.jar!/:na]
at liquibase.resource.CompositeResourceAccessor.openStreams(CompositeResourceAccessor.java:33) ~[liquibase-core-4.0.0.jar!/:na]
at liquibase.parser.core.xml.LiquibaseEntityResolver.resolveEntity(LiquibaseEntityResolver.java:40) ~[liquibase-core-4.0.0.jar!/:na]
at java.xml/com.sun.org.apache.xerces.internal.util.EntityResolver2Wrapper.resolveEntity(Unknown Source) ~[na:na]
at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source) ~[na:na]
at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) ~[na:na]
at liquibase.parser.core.xml.XMLChangeLogSAXParser.parseToNode(XMLChangeLogSAXParser.java:91) ~[liquibase-core-4.0.0.jar!/:na]
at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:15) ~[liquibase-core-4.0.0.jar!/:na]
at liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:223) ~[liquibase-core-4.0.0.jar!/:na]
at liquibase.Liquibase$1.run(Liquibase.java:194) ~[liquibase-core-4.0.0.jar!/:na]
at liquibase.Scope.lambda$child$0(Scope.java:159) ~[liquibase-core-4.0.0.jar!/:na]
at liquibase.Scope.child(Scope.java:170) ~[liquibase-core-4.0.0.jar!/:na]
at liquibase.Scope.child(Scope.java:158) ~[liquibase-core-4.0.0.jar!/:na]
at liquibase.Scope.child(Scope.java:137) ~[liquibase-core-4.0.0.jar!/:na]
at liquibase.Liquibase.runInScope(Liquibase.java:1790) ~[liquibase-core-4.0.0.jar!/:na]
at liquibase.Liquibase.update(Liquibase.java:183) ~[liquibase-core-4.0.0.jar!/:na]
at liquibase.Liquibase.update(Liquibase.java:179) ~[liquibase-core-4.0.0.jar!/:na]
at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:322) ~[liquibase-core-4.0.0.jar!/:na]
at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:270) ~[liquibase-core-4.0.0.jar!/:na]
at org.springframework.boot.autoconfigure.liquibase.DataSourceClosingSpringLiquibase.afterPropertiesSet(DataSourceClosingSpringLiquibase.java:46) ~[spring-boot-autoconfigure-2.3.1.RELEASE.jar!/:2.3.1.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans(ServletWebServerApplicationContext.java:255) ~[spring-boot-2.3.1.RELEASE.jar!/:2.3.1.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:229) ~[spring-boot-2.3.1.RELEASE.jar!/:2.3.1.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:53) ~[spring-boot-2.3.1.RELEASE.jar!/:2.3.1.RELEASE]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5128) ~[tomcat-embed-core-9.0.36.jar!/:9.0.36]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.36.jar!/:9.0.36]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) ~[tomcat-embed-core-9.0.36.jar!/:9.0.36]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) ~[tomcat-embed-core-9.0.36.jar!/:9.0.36]
at java.base/java.util.concurrent.FutureTask.run(Unknown Source) ~[na:na]
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[tomcat-embed-core-9.0.36.jar!/:9.0.36]
at java.base/java.util.concurrent.AbstractExecutorService.submit(Unknown Source) ~[na:na]
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) ~[tomcat-embed-core-9.0.36.jar!/:9.0.36]
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841) ~[tomcat-embed-core-9.0.36.jar!/:9.0.36]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.36.jar!/:9.0.36]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) ~[tomcat-embed-core-9.0.36.jar!/:9.0.36]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) ~[tomcat-embed-core-9.0.36.jar!/:9.0.36]
......
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) ~[spring-boot-2.3.1.RELEASE.jar!/:2.3.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.3.1.RELEASE.jar!/:2.3.1.RELEASE]
at com.vyv.hov2.MinimalApplication.main(MinimalApplication.java:74) ~[classes!/:2]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Unknown Source) ~[na:na]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[hov2.jar:2]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:109) ~[hov2.jar:2]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[hov2.jar:2]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) ~[hov2.jar:2]
the pom.xml to see the versions used :
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>xxxx</groupId>
<artifactId>xxxx</artifactId>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<spring-boot.version>2.3.1.RELEASE</spring-boot.version>
<hibernate.version>5.4.12.Final</hibernate.version>
<liquibase-core.version>4.0.0</liquibase-core.version>
<liquibase-maven-plugin.version>4.0.0</liquibase-maven-plugin.version>
<liquibase-hibernate5.version>4.0.0</liquibase-hibernate5.version>
<validation-api.version>2.0.1.Final</validation-api.version>
<javassist.version>3.27.0-GA</javassist.version>
<jaxb-api.version>2.4.0-b180830.0359</jaxb-api.version>
<maven.build.timestamp.format>yyyy-MM-dd'T'HH.mm.ss</maven.build.timestamp.format>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<scope>provided</scope>
</dependency>
<!-- JPA + Postgresql -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.2.Final</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${validation-api.version}</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>dev</id>
<properties>
<activatedProperties>dev</activatedProperties>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>prod</id>
<properties>
<activatedProperties>prod</activatedProperties>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase-maven-plugin.version}</version>
<configuration>
<propertyFile>src/main/resources/liquibase-${activatedProperties}.properties</propertyFile>
<outputChangeLogFile>src/main/resources/db/db.changelog-${activatedProperties}.xml</outputChangeLogFile>
<changeLogFile>src/main/resources/db/db.changelog-${activatedProperties}.xml</changeLogFile>
<diffChangeLogFile>src/main/resources/db/changelog/${activatedProperties}/${maven.build.timestamp}_changelog.xml</diffChangeLogFile>
<diffTypes>tables,columns,indexes,foreignkeys,primarykeys,uniqueconstraints</diffTypes>
<logging>info</logging>
</configuration>
<!-- Liquibase dependencies-->
<dependencies>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>${liquibase-core.version}</version>
</dependency>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate5</artifactId>
<version>${liquibase-hibernate5.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${validation-api.version}</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>${javassist.version}</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb-api.version}</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.12.0</version>
<executions>
<execution>
<id>pmd-scan</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
the liquibase-dev.properties :
url=jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_NAME}
username=xxxx
password=xxxx
driver=org.postgresql.Driver
#### Reference database properties
referenceUrl=hibernate:spring:com.vyv.hov2.domain?dialect=org.hibernate.dialect.PostgreSQLDialect
referenceDriver=liquibase.ext.hibernate.database.connection.HibernateDriver
referenceDefaultSchemaName=db
verbose=true
the dockerfile :
FROM maven:3.6.3-openjdk-11-slim as BUILD
WORKDIR /usr/src/app
COPY checkstyle.xml .
COPY checkstyle-supressions.xml .
COPY licenseheader.txt .
COPY pom.xml .
RUN mvn dependency:go-offline
COPY src src
COPY .git ./.git/
RUN mvn -B -e -C -T 1C package -Dmaven.test.skip=true
FROM openjdk:11.0.8-jre
EXPOSE 8081
COPY --from=BUILD /usr/src/app/target/*.jar /opt/target/hov2.jar
WORKDIR /opt/target
ENV TZ="America/Bogota"
ENV SPRING_PROFILES_ACTIVE="dev"
ENV APP_HTTP_THREADS="4"
ENV DB_MAX_POOL="4"
ENV DB_CONN_TIMEOUT="20000"
ENV DB_HOST="192.168.x.x"
ENV DB_PORT="xxxx"
ENV DB_NAME="yyyy"
ENV DB_USER="zzzz"
ENV DB_PASSWORD="zzzz"
RUN apt-get -y update && apt-get -y install apt-utils tzdata && apt-get -y clean
ENTRYPOINT exec java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar hov2.jar $JAR_OPTS
and the result of the docker build gives :
D:\GitLab\hov2-springboot>docker build -t xxxx/hov:spring .
Sending build context to Docker daemon 69.29MB
Step 1/27 : FROM maven:3.6.3-openjdk-11-slim as BUILD
---> 5f736c971204
Step 2/27 : MAINTAINER xxxxx
---> Using cache
---> 58e7bae3a780
Step 3/27 : WORKDIR /usr/src/app
---> Using cache
---> b790cb47ac8e
Step 4/27 : COPY checkstyle-GlobalRemises.xml .
---> Using cache
---> 105a291c538e
Step 5/27 : COPY checkstyle-supressions.xml .
---> Using cache
---> 59f933795b44
Step 6/27 : COPY licenseheader.txt .
---> Using cache
---> 227d608636c9
Step 7/27 : COPY pom.xml .
---> Using cache
---> 3de8cfcf50ce
Step 8/27 : RUN mvn -B dependency:resolve dependency:resolve-plugins
---> Using cache
---> 4505edb08bc0
Step 9/27 : COPY src src
---> 5580f85e37b0
Step 10/27 : COPY .git ./.git/
---> 9ffa9fdd1d6b
Step 11/27 : RUN mvn -B -e -C -T 1C package -Dmaven.test.skip=true
---> Running in db75577e3260
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] Using the MultiThreadedBuilder implementation with a thread count of 8
[INFO]
[INFO] --------------------< com.vyv.hov2:HOV2-SpringBoot >--------------------
[INFO] Building HerramientaOperativa 2
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ HOV2-SpringBoot ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO] Copying 994 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ HOV2-SpringBoot ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 536 source files to /usr/src/app/target/classes
[INFO] --- jacoco-maven-plugin:0.8.4:report (report) @ HOV2-SpringBoot ---
[INFO] Skipping JaCoCo execution due to missing execution data file.
[INFO]
[INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) @ HOV2-SpringBoot ---
[INFO] Building jar: /usr/src/app/target/HOV2-SpringBoot-2.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.3.1.RELEASE:repackage (repackage) @ HOV2-SpringBoot ---
[INFO] Replacing main artifact with repackaged archive
[INFO]
[INFO] --- spring-boot-maven-plugin:2.3.1.RELEASE:repackage (default) @ HOV2-SpringBoot ---
[INFO] Replacing main artifact with repackaged archive
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20.784 s (Wall Clock)
[INFO] Finished at: 2020-09-01T05:07:54Z
[INFO] ------------------------------------------------------------------------
Removing intermediate container db75577e3260
---> 419a981baa13
Step 12/27 : FROM openjdk:11.0.8-jre
---> 9cbf6d4bac44
Step 13/27 : EXPOSE 8081
---> Using cache
---> 48eec46f876c
Step 14/27 : COPY --from=BUILD /usr/src/app/target/*.jar /opt/target/hov2.jar
---> 13d80ab4c8a9
Step 15/27 : WORKDIR /opt/target
---> Running in f87f4fa28359
Removing intermediate container f87f4fa28359
---> c00e6df5a4a3
Step 16/27 : ENV TZ="America/Bogota"
---> Running in 09d317dc80d3
Removing intermediate container 09d317dc80d3
---> 57e64896eb41
Step 17/27 : ENV SPRING_PROFILES_ACTIVE=""
Step 26/27 : RUN apt-get -y update && apt-get -y install apt-utils tzdata && apt-get -y clean
---> Running in 180a8975bfa8
Get:1 http://deb.debian.org/debian buster InRelease [122 kB]
Get:2 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]
Get:4 http://security.debian.org/debian-security buster/updates/main amd64 Packages [224 kB]
Get:5 http://deb.debian.org/debian buster/main amd64 Packages [7906 kB]
Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages [7868 B]
Fetched 8378 kB in 4s (2176 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
tzdata is already the newest version (2020a-0+deb10u1).
tzdata set to manually installed.
The following NEW packages will be installed:
apt-utils libapt-inst2.0
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 624 kB of archives.
After this operation, 1650 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian buster/main amd64 libapt-inst2.0 amd64 1.8.2.1 [203 kB]
Get:2 http://deb.debian.org/debian buster/main amd64 apt-utils amd64 1.8.2.1 [421 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 624 kB in 1s (796 kB/s)
Selecting previously unselected package libapt-inst2.0:amd64.
(Reading database ... 7867 files and directories currently installed.)
Preparing to unpack .../libapt-inst2.0_1.8.2.1_amd64.deb ...
Unpacking libapt-inst2.0:amd64 (1.8.2.1) ...
Selecting previously unselected package apt-utils.
Preparing to unpack .../apt-utils_1.8.2.1_amd64.deb ...
Unpacking apt-utils (1.8.2.1) ...
Setting up libapt-inst2.0:amd64 (1.8.2.1) ...
Setting up apt-utils (1.8.2.1) ...
Processing triggers for libc-bin (2.28-10) ...
Removing intermediate container 180a8975bfa8
---> 6b67dd296d7e
Step 27/27 : ENTRYPOINT exec java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar hov2.jar $JAR_OPTS
---> Running in d8740b5c5e53
Removing intermediate container d8740b5c5e53
---> ca68efe70b02
Successfully built ca68efe70b02
Successfully tagged xxxx/hov:spring
SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It
is recommended to double check and reset permissions for sensitive files and directories.
the dev.properties for the liquibase part
# ************* liquibase for DEV
spring.liquibase.enabled=true
spring.liquibase.url=jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_NAME}
# Change log configuration path.
spring.liquibase.change-Log=classpath:/db/db.changelog-dev.xml
#spring.liquibase.contexts= # Comma-separated list of runtime contexts to use.
# Name of table to use for tracking concurrent Liquibase usage.
spring.liquibase.database-change-log-lock-table=DATABASECHANGELOGLOCK
# Name of table to use for tracking change history.
spring.liquibase.database-change-log-table=DATABASECHANGELOG
#spring.liquibase.default-schema=
# Whether to first drop the database schema.
spring.liquibase.drop-first=false
spring.liquibase.password=xxxx
spring.liquibase.user=xxxx
when starting the docker ( with the dev context) all goes fine untill liquibase pluggin starts,then thousands of error lines (one error for each Jar present in the classpath), then after those errors the app starts fine, the only issue is that the liquibase changlogs are, of course, not executed and therefore the plugin looses most of its utility...
here is the startup log witout the errors in case something usefull is here :
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.1.RELEASE)
2020-09-01 00:11:02.477 INFO 1 --- [ main] com.vyv.hov2.MinimalApplication : Starting MinimalApplication v2 on c795be63b326 with PID 1 (/opt/target/hov2.jar started by root in /opt/target)
2020-09-01 00:11:02.484 INFO 1 --- [ main] com.vyv.hov2.MinimalApplication : The following profiles are active: dev
2020-09-01 00:11:05.413 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-09-01 00:11:06.555 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 1120ms. Found 92 JPA repository interfaces.
2020-09-01 00:11:08.286 INFO 1 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler@2f40a43' of type [org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-09-01 00:11:08.298 INFO 1 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'methodSecurityMetadataSource' of type [org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-09-01 00:11:08.993 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8081 (https)
2020-09-01 00:11:09.013 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-09-01 00:11:09.013 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.36]
2020-09-01 00:11:09.136 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-09-01 00:11:09.137 INFO 1 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 6415 ms
2020-09-01 00:11:09.465 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-09-01 00:11:09.722 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-09-01 00:11:10.384 INFO 1 --- [ main] liquibase.lockservice : Successfully acquired change log lock
2020-09-01 00:11:10.435 WARN 1 --- [ main] liquibase.integration : Cannot create filesystem for url jar:file:/opt/target/hov2.jar!/BOOT-INF/classes!/: null
java.nio.file.FileSystemNotFoundException: null
Here come the hundreds of error ... then the rest is normal again:
2020-09-01 00:11:11.871 INFO 1 --- [ main] liquibase.changelog : Reading from public.databasechangelog
2020-09-01 00:11:11.925 INFO 1 --- [ main] liquibase.lockservice : Successfully released change log lock
2020-09-01 00:11:11.935 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2020-09-01 00:11:11.946 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2020-09-01 00:11:12.096 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Starting...
2020-09-01 00:11:12.134 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Start completed.
2020-09-01 00:11:12.312 INFO 1 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-09-01 00:11:12.467 INFO 1 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.12.Final
What did I do wrong ?
One of my ideas was that the path to the db-changelog-dev.xml indicated in the pom.xml would not be the same on my computer and in the docker, but this path is relative to the src folder, so I don't see how to change it...
I had this idea because in the log of the springboot startup we can see liquibase getting the locks on the database changlog tables, but nowhere can be seen the opening of the db-changelog-dev.xml by liquibase, and the errors are relative to filesystem errors, so it seemed conencted to me, but i did not managed to solve it.
Thanks for any idea that could put me on the right track.
thanks @shrom, the first liquibase method that throws the exception has the following javadocs :
/**
* The classloader search logic in {@link #list(String, String, boolean, boolean, boolean)} does not handle jar files well.
* This method is called by that method to populate {@link #rootPaths} with additional paths to search.
*/
I like the "does not handle jar files well" ! thats an understatement.
it looks like those WARNINGS are not at the origin of the issue I have with liquibase plugin not performing the DB updates. I must have another issue somewhere else, because based on the other post referenced above the other user had those errors but the DB was updated. and furthermore they are just warning not real errors... I will keep digging.
答案1
得分: 1
找到的原因:
为了摆脱这些错误,我不得不深度更改我的 pom.xml 文件。我删除了属性部分中所有已在引用的 springboot 父级(具体在 spring-boot-dependencies-2.3.1.RELEASE.pom 文件中)中具有值的硬编码版本号,并改为使用此文件的属性。因此,一些生成的版本较低,但我更相信 Spring 而不是我自己来指示插件的正确兼容版本。生成的 POM 如下:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<java.version>11</java.version>
<liquibase-hibernate5.version>3.10.1</liquibase-hibernate5.version>
<javassist.version>3.27.0-GA</javassist.version>
<maven.build.timestamp.format>yyyy-MM-dd'T'HH.mm.ss</maven.build.timestamp.format>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
</dependency>
...
<build>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase.version}</version>
<configuration>
<propertyFile>src/main/resources/liquibase-${activatedProperties}.properties</propertyFile>
<outputChangeLogFile>src/main/resources/db/db.changelog-${activatedProperties}.xml</outputChangeLogFile>
<changeLogFile>src/main/resources/db/db.changelog-${activatedProperties}.xml</changeLogFile>
<diffChangeLogFile>src/main/resources/db/changelog/${activatedProperties}/${maven.build.timestamp}_changelog.xml</diffChangeLogFile>
<diffTypes>tables,columns,indexes,foreignkeys,primarykeys,uniqueconstraints</diffTypes>
<!-- diffTypes=tables, views, columns, indexes, foreignkeys, primarykeys, uniqueconstraints, data -->
<logging>info</logging>
</configuration>
<!-- Liquibase dependencies-->
<dependencies>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>${liquibase.version}</version>
</dependency>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate5</artifactId>
<version>${liquibase-hibernate5.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${javax-validation.version}</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>${javassist.version}</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${javax-jaxb.version}</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
...
</build>
在这个 pom 文件的插件部分,你会看到版本号属性,这些值都继承自 SpringBoot 的 pom 文件,不再硬编码在我的 pom 文件中。
现在在 Docker 中正常运行!如果你遇到相同的问题,而我的答案不能帮助你解决它,请留下评论,我会添加我也进行的其他更改,但目前我怀疑它们是否产生了任何影响。
英文:
Reason found :
In order to get rid of those errors I had to deeply change my pom.xml.
I removed all the hardcoded version numbers in the properties section that already have a value in the referenced springboot parent ( specifically in the spring-boot-dependencies-2.3.1.RELEASE.pom ) and instead I used the properties of this file. As a result some of the resulting versions are lower, but I trust more spring than myself to indicate the right compatible version of the plugins. The resulting POM is as follows :
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<java.version>11</java.version>
<liquibase-hibernate5.version>3.10.1</liquibase-hibernate5.version>
<javassist.version>3.27.0-GA</javassist.version>
<maven.build.timestamp.format>yyyy-MM-dd'T'HH.mm.ss</maven.build.timestamp.format>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
</dependency>
...
<build>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase.version}</version>
<configuration>
<propertyFile>src/main/resources/liquibase-${activatedProperties}.properties</propertyFile>
<outputChangeLogFile>src/main/resources/db/db.changelog-${activatedProperties}.xml</outputChangeLogFile>
<changeLogFile>src/main/resources/db/db.changelog-${activatedProperties}.xml</changeLogFile>
<diffChangeLogFile>src/main/resources/db/changelog/${activatedProperties}/${maven.build.timestamp}_changelog.xml</diffChangeLogFile>
<diffTypes>tables,columns,indexes,foreignkeys,primarykeys,uniqueconstraints</diffTypes>
<!-- diffTypes=tables, views, columns, indexes, foreignkeys, primarykeys, uniqueconstraints, data -->
<logging>info</logging>
</configuration>
<!-- Liquibase dependencies-->
<dependencies>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>${liquibase.version}</version>
</dependency>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate5</artifactId>
<version>${liquibase-hibernate5.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${javax-validation.version}</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>${javassist.version}</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${javax-jaxb.version}</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
...
In this pom in the pluggin section you will see version numbers properties, the values are inherited from the SpringBoot pom, no more hard coded in my own pom.
Now running fine in Docker !
If you have the same issue and my answer does not allow you to solve it, drop a comment i will add the other changes i also made, that for the moment, I doubt had any impact.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论