fabric8io / docker-maven-plugin

Maven plugin for running and creating Docker images
https://dmp.fabric8.io
Apache License 2.0
1.88k stars 643 forks source link

Execution default-cli of goal io.fabric8:docker-maven-plugin:0.33.0:build failed: Expected a com.google.gson.JsonObject but was com.google.gson.JsonPrimitive #1542

Open ykmx opened 2 years ago

ykmx commented 2 years ago

Description

mvn install docker:build -e -X

Info

describe_log.zip

[INFO] [INFO] --- docker-maven-plugin:0.33.0:build (default-cli) @ backstage-upms-biz --- [DEBUG] Dependency collection stats {ConflictMarker.analyzeTime=86737, ConflictMarker.markTime=44446, ConflictMarker.nodeCount=186, ConflictIdSorter.graphTime=40428, ConflictIdSorter.topsortTime=39971, ConflictIdSorter.conflictIdCount=72, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=813447, ConflictResolver.conflictItemCount=170, DefaultDependencyCollector.collectTime=42746458, DefaultDependencyCollector.transformTime=1053765} [DEBUG] io.fabric8:docker-maven-plugin:jar:0.33.0 [DEBUG] org.apache.httpcomponents:httpclient:jar:4.5.5:compile [DEBUG] org.apache.httpcomponents:httpcore:jar:4.4.9:compile [DEBUG] commons-logging:commons-logging:jar:1.2:compile [DEBUG] commons-codec:commons-codec:jar:1.10:compile [DEBUG] com.github.jnr:jnr-unixsocket:jar:0.25:compile [DEBUG] com.github.jnr:jnr-ffi:jar:2.1.11:compile [DEBUG] com.github.jnr:jffi:jar:1.2.22:compile [DEBUG] com.github.jnr:jffi:jar:native:1.2.22:runtime [DEBUG] org.ow2.asm:asm:jar:7.1:compile [DEBUG] org.ow2.asm:asm-commons:jar:7.1:compile [DEBUG] org.ow2.asm:asm-analysis:jar:7.1:compile [DEBUG] org.ow2.asm:asm-tree:jar:7.1:compile [DEBUG] org.ow2.asm:asm-util:jar:7.1:compile [DEBUG] com.github.jnr:jnr-a64asm:jar:1.0.0:compile [DEBUG] com.github.jnr:jnr-x86asm:jar:1.0.2:compile [DEBUG] com.github.jnr:jnr-constants:jar:0.9.14:compile [DEBUG] com.github.jnr:jnr-enxio:jar:0.23:compile [DEBUG] com.github.jnr:jnr-posix:jar:3.0.51:compile [DEBUG] org.apache.commons:commons-lang3:jar:3.6:compile [DEBUG] org.apache.commons:commons-text:jar:1.1:compile [DEBUG] com.google.code.gson:gson:jar:2.8.5:compile [DEBUG] org.fusesource.jansi:jansi:jar:1.16:compile [DEBUG] org.bouncycastle:bcpkix-jdk15on:jar:1.57:compile [DEBUG] org.bouncycastle:bcprov-jdk15on:jar:1.57:compile [DEBUG] org.apache.maven.plugins:maven-assembly-plugin:jar:3.1.0:compile [DEBUG] org.apache.maven:maven-plugin-api:jar:3.0:compile [DEBUG] org.sonatype.sisu:sisu-inject-plexus:jar:1.4.2:compile [DEBUG] org.sonatype.sisu:sisu-inject-bean:jar:1.4.2:compile [DEBUG] org.sonatype.sisu:sisu-guice:jar:noaop:2.1.7:compile [DEBUG] org.apache.maven:maven-core:jar:3.0:compile [DEBUG] org.apache.maven:maven-settings:jar:3.0:compile [DEBUG] org.apache.maven:maven-settings-builder:jar:3.0:compile [DEBUG] org.apache.maven:maven-repository-metadata:jar:3.0:compile [DEBUG] org.apache.maven:maven-model-builder:jar:3.0:compile [DEBUG] org.apache.maven:maven-aether-provider:jar:3.0:runtime [DEBUG] org.sonatype.aether:aether-impl:jar:1.7:compile [DEBUG] org.sonatype.aether:aether-spi:jar:1.7:compile [DEBUG] org.sonatype.aether:aether-api:jar:1.7:compile [DEBUG] org.sonatype.aether:aether-util:jar:1.7:compile [DEBUG] org.codehaus.plexus:plexus-classworlds:jar:2.2.3:compile [DEBUG] org.codehaus.plexus:plexus-component-annotations:jar:1.5.5:compile [DEBUG] org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3:compile [DEBUG] org.sonatype.plexus:plexus-cipher:jar:1.4:compile [DEBUG] org.apache.maven:maven-artifact:jar:3.0:compile [DEBUG] org.apache.maven:maven-model:jar:3.0:compile [DEBUG] org.apache.maven.shared:maven-common-artifact-filters:jar:3.0.1:compile [DEBUG] org.apache.maven.shared:maven-shared-utils:jar:3.1.0:compile [DEBUG] org.apache.maven.shared:maven-artifact-transfer:jar:0.9.0:compile [DEBUG] org.slf4j:slf4j-api:jar:1.7.5:compile [DEBUG] org.codehaus.plexus:plexus-archiver:jar:3.5:compile [DEBUG] org.apache.commons:commons-compress:jar:1.14:compile [DEBUG] org.iq80.snappy:snappy:jar:0.4:compile [DEBUG] org.tukaani:xz:jar:1.6:runtime [DEBUG] org.apache.maven.shared:file-management:jar:3.0.0:compile [DEBUG] org.apache.maven.shared:maven-shared-io:jar:3.0.0:compile [DEBUG] org.apache.maven:maven-compat:jar:3.0:compile [DEBUG] org.apache.maven.wagon:wagon-provider-api:jar:2.10:compile [DEBUG] commons-io:commons-io:jar:2.5:compile [DEBUG] org.apache.maven.shared:maven-filtering:jar:3.1.1:compile [DEBUG] org.sonatype.plexus:plexus-build-api:jar:0.0.7:compile [DEBUG] org.codehaus.plexus:plexus-io:jar:3.0.0:compile [DEBUG] org.apache.maven:maven-archiver:jar:3.2.0:compile [DEBUG] org.codehaus.plexus:plexus-utils:jar:3.1.0:compile [DEBUG] joda-time:joda-time:jar:2.10.4:compile [DEBUG] org.yaml:snakeyaml:jar:1.18:compile [DEBUG] com.google.guava:guava:jar:23.0-android:compile [DEBUG] com.google.code.findbugs:jsr305:jar:1.3.9:compile [DEBUG] com.google.errorprone:error_prone_annotations:jar:2.0.18:compile [DEBUG] com.google.j2objc:j2objc-annotations:jar:1.1:compile [DEBUG] org.codehaus.mojo:animal-sniffer-annotations:jar:1.14:compile [DEBUG] org.codehaus.plexus:plexus-interpolation:jar:1.24:compile [DEBUG] Created new class realm plugin>io.fabric8:docker-maven-plugin:0.33.0 [DEBUG] Importing foreign packages into class realm plugin>io.fabric8:docker-maven-plugin:0.33.0 [DEBUG] Imported: < maven.api [DEBUG] Populating class realm plugin>io.fabric8:docker-maven-plugin:0.33.0 [DEBUG] Included: io.fabric8:docker-maven-plugin:jar:0.33.0 [DEBUG] Included: org.apache.httpcomponents:httpclient:jar:4.5.5 [DEBUG] Included: org.apache.httpcomponents:httpcore:jar:4.4.9 [DEBUG] Included: commons-logging:commons-logging:jar:1.2 [DEBUG] Included: commons-codec:commons-codec:jar:1.10 [DEBUG] Included: com.github.jnr:jnr-unixsocket:jar:0.25 [DEBUG] Included: com.github.jnr:jnr-ffi:jar:2.1.11 [DEBUG] Included: com.github.jnr:jffi:jar:1.2.22 [DEBUG] Included: com.github.jnr:jffi:jar:native:1.2.22 [DEBUG] Included: org.ow2.asm:asm:jar:7.1 [DEBUG] Included: org.ow2.asm:asm-commons:jar:7.1 [DEBUG] Included: org.ow2.asm:asm-analysis:jar:7.1 [DEBUG] Included: org.ow2.asm:asm-tree:jar:7.1 [DEBUG] Included: org.ow2.asm:asm-util:jar:7.1 [DEBUG] Included: com.github.jnr:jnr-a64asm:jar:1.0.0 [DEBUG] Included: com.github.jnr:jnr-x86asm:jar:1.0.2 [DEBUG] Included: com.github.jnr:jnr-constants:jar:0.9.14 [DEBUG] Included: com.github.jnr:jnr-enxio:jar:0.23 [DEBUG] Included: com.github.jnr:jnr-posix:jar:3.0.51 [DEBUG] Included: org.apache.commons:commons-lang3:jar:3.6 [DEBUG] Included: org.apache.commons:commons-text:jar:1.1 [DEBUG] Included: com.google.code.gson:gson:jar:2.8.5 [DEBUG] Included: org.bouncycastle:bcpkix-jdk15on:jar:1.57 [DEBUG] Included: org.bouncycastle:bcprov-jdk15on:jar:1.57 [DEBUG] Included: org.apache.maven.plugins:maven-assembly-plugin:jar:3.1.0 [DEBUG] Included: org.sonatype.sisu:sisu-inject-bean:jar:1.4.2 [DEBUG] Included: org.sonatype.sisu:sisu-guice:jar:noaop:2.1.7 [DEBUG] Included: org.sonatype.aether:aether-util:jar:1.7 [DEBUG] Included: org.codehaus.plexus:plexus-component-annotations:jar:1.5.5 [DEBUG] Included: org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3 [DEBUG] Included: org.sonatype.plexus:plexus-cipher:jar:1.4 [DEBUG] Included: org.apache.maven.shared:maven-common-artifact-filters:jar:3.0.1 [DEBUG] Included: org.apache.maven.shared:maven-shared-utils:jar:3.1.0 [DEBUG] Included: org.apache.maven.shared:maven-artifact-transfer:jar:0.9.0 [DEBUG] Included: org.codehaus.plexus:plexus-archiver:jar:3.5 [DEBUG] Included: org.apache.commons:commons-compress:jar:1.14 [DEBUG] Included: org.iq80.snappy:snappy:jar:0.4 [DEBUG] Included: org.tukaani:xz:jar:1.6 [DEBUG] Included: org.apache.maven.shared:file-management:jar:3.0.0 [DEBUG] Included: org.apache.maven.shared:maven-shared-io:jar:3.0.0 [DEBUG] Included: commons-io:commons-io:jar:2.5 [DEBUG] Included: org.apache.maven.shared:maven-filtering:jar:3.1.1 [DEBUG] Included: org.sonatype.plexus:plexus-build-api:jar:0.0.7 [DEBUG] Included: org.codehaus.plexus:plexus-io:jar:3.0.0 [DEBUG] Included: org.apache.maven:maven-archiver:jar:3.2.0 [DEBUG] Included: org.codehaus.plexus:plexus-utils:jar:3.1.0 [DEBUG] Included: joda-time:joda-time:jar:2.10.4 [DEBUG] Included: org.yaml:snakeyaml:jar:1.18 [DEBUG] Included: com.google.guava:guava:jar:23.0-android [DEBUG] Included: com.google.code.findbugs:jsr305:jar:1.3.9 [DEBUG] Included: com.google.errorprone:error_prone_annotations:jar:2.0.18 [DEBUG] Included: com.google.j2objc:j2objc-annotations:jar:1.1 [DEBUG] Included: org.codehaus.mojo:animal-sniffer-annotations:jar:1.14 [DEBUG] Included: org.codehaus.plexus:plexus-interpolation:jar:1.24 [DEBUG] Configuring mojo io.fabric8:docker-maven-plugin:0.33.0:build from plugin realm ClassRealm[plugin>io.fabric8:docker-maven-plugin:0.33.0, parent: sun.misc.Launcher$AppClassLoader@5c647e05] [DEBUG] Configuring mojo 'io.fabric8:docker-maven-plugin:0.33.0:build' with basic configurator --> [DEBUG] (f) push = {password=Harbor12345, username=admin} [DEBUG] (f) authConfig = io.fabric8.maven.docker.config.RegistryAuthConfiguration@3db65c0d [DEBUG] (f) buildArchiveOnly = false [DEBUG] (f) dockerHost = http://192.168.0.101:2375 [DEBUG] (f) execution = io.fabric8:docker-maven-plugin:0.33.0:build {execution: default-cli} [DEBUG] (s) name = 192.168.0.101/travel/backstage-upms-biz:4.3.0 [DEBUG] (f) dockerFile = /Users/fanjinjin/IdeaProjects/backstage/backstage-upms/backstage-upms-biz/Dockerfile [DEBUG] (f) build = io.fabric8.maven.docker.config.BuildImageConfiguration@7f27f59b [DEBUG] (f) images = [ImageConfiguration {name='192.168.0.101/travel/backstage-upms-biz:4.3.0', alias='null'}] [DEBUG] (f) keepContainer = false [DEBUG] (f) logStdout = false [DEBUG] (f) maxConnections = 100 [DEBUG] (f) outputDirectory = target/docker [DEBUG] (f) project = MavenProject: com.gzb:backstage-upms-biz:4.3.0 @ /Users/fanjinjin/IdeaProjects/backstage/backstage-upms/backstage-upms-biz/pom.xml [DEBUG] (f) reactorProjects = [MavenProject: com.gzb:backstage-upms-biz:4.3.0 @ /Users/fanjinjin/IdeaProjects/backstage/backstage-upms/backstage-upms-biz/pom.xml] [DEBUG] (f) registry = 192.168.0.101 [DEBUG] (f) removeVolumes = false [DEBUG] (f) session = org.apache.maven.execution.MavenSession@1ba05e38 [DEBUG] (f) settings = org.apache.maven.execution.SettingsAdapter@45801322 [DEBUG] (f) skip = false [DEBUG] (f) skipBuild = false [DEBUG] (f) skipExtendedAuth = false [DEBUG] (f) skipMachine = false [DEBUG] (f) skipTag = false [DEBUG] (f) sourceDirectory = src/main/docker [DEBUG] (f) useColor = true [DEBUG] -- end configuration -- [INFO] Building tar: /Users/fanjinjin/IdeaProjects/backstage/backstage-upms/backstage-upms-biz/target/docker/192.168.0.101/travel/backstage-upms-biz/4.3.0/tmp/docker-build.tar [INFO] DOCKER> [192.168.0.101/travel/backstage-upms-biz:4.3.0]: Created docker-build.tar in 851 milliseconds [DEBUG] DOCKER> Build args set {} [DEBUG] DOCKER> Build args set {} [DEBUG] DOCKER> Build args set {} [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.151 s [INFO] Finished at: 2022-04-12T23:30:33+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.33.0:build (default-cli) on project backstage-upms-biz: Execution default-cli of goal io.fabric8:docker-maven-plugin:0.33.0:build failed: Expected a com.google.gson.JsonObject but was com.google.gson.JsonPrimitive -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal io.fabric8:docker-maven-plugin:0.33.0:build (default-cli) on project backstage-upms-biz: Execution default-cli of goal io.fabric8:docker-maven-plugin:0.33.0:build failed: Expected a com.google.gson.JsonObject but was com.google.gson.JsonPrimitive at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215) 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 sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:498) 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) Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal io.fabric8:docker-maven-plugin:0.33.0:build failed: Expected a com.google.gson.JsonObject but was com.google.gson.JsonPrimitive at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148) 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 sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:498) 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) Caused by: com.google.gson.JsonSyntaxException: Expected a com.google.gson.JsonObject but was com.google.gson.JsonPrimitive at com.google.gson.internal.bind.TypeAdapters$35$1.read (TypeAdapters.java:897) at com.google.gson.Gson.fromJson (Gson.java:927) at com.google.gson.Gson.fromJson (Gson.java:892) at com.google.gson.Gson.fromJson (Gson.java:841) at com.google.gson.Gson.fromJson (Gson.java:813) at io.fabric8.maven.docker.util.JsonFactory.newJsonObject (JsonFactory.java:18) at io.fabric8.maven.docker.access.hc.DockerAccessWithHcClient.getImageId (DockerAccessWithHcClient.java:435) at io.fabric8.maven.docker.service.QueryService.getImageId (QueryService.java:135) at io.fabric8.maven.docker.service.BuildService.buildImage (BuildService.java:154) at io.fabric8.maven.docker.service.BuildService.buildImage (BuildService.java:71) at io.fabric8.maven.docker.BuildMojo.buildAndTag (BuildMojo.java:82) at io.fabric8.maven.docker.BuildMojo.processImageConfig (BuildMojo.java:135) at io.fabric8.maven.docker.BuildMojo.executeInternal (BuildMojo.java:67) at io.fabric8.maven.docker.AbstractDockerMojo.execute (AbstractDockerMojo.java:238) 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 sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:498) 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) [ERROR] [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/PluginExecutionException


* Docker version :20.10.12
* If it's a bug, how to reproduce :
* If it's a feature request, what is your use case :
* Sample project : *[GitHub Clone URL]*
rohanKanojia commented 2 years ago

This seems to be pretty old version. Do you face same issue with v0.39.1?

ykmx commented 2 years ago

I've tried all versions. from 0.33.0 to 0.39.1

rohanKanojia commented 2 years ago

Do you have some reproducer project which we can try?

ykmx commented 2 years ago

https://github.com/ykmx/demo.git thank you!

rhuss commented 2 years ago

Sorry, I can't reproduce it with the given repo, as it stops for me that the referenced Dockerfile does not exist (and indeed, is does not exist in the repo)

rhuss commented 2 years ago

Looking into the source it looks like that your Docker daemon returns some unusual response when listing images.

oriming commented 1 year ago

@rhuss @rohanKanojia I have the same problem, try importing this package in jar

<dependencies>
        <dependency>
            <groupId>com.github.binarywang</groupId>
            <artifactId>weixin-java-miniapp</artifactId>
        </dependency>
</dependencies>
rohanKanojia commented 1 year ago

@sny-boy : Which jar are you referring to?

oriming commented 1 year ago

@rohanKanojia The environment is

1. MacOS 13.0.1(arch: "aarch64")
2. Apache Maven 3.8.4 
3. Java version: 17.0.5, vendor: Azul Systems
4. IntelliJ IDEA 2022.2.2 (Ultimate Edition)
5. Docker version 20.10.13

The tested versions of io.fabric8 are 0.33.0, 0.39.0, 0.40.0, 0.40.1, 0.40.2

All report the same problem when executing build: Expected a com.google.gson.JsonObject but was com.google.gson.JsonPrimitive

pom.xml is configured as follows:

<properties>
  <app.name>starter</app.name>
  <maven.compiler.source>17</maven.compiler.source>
  <maven.compiler.target>17</maven.compiler.target>
</properties>

<dependencies>
  <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
      <version>2.7.5</version>
  </dependency>
</dependencies>

<build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <version>2.7.3</version>
        <executions>
            <execution>
                <id>repackage</id>
                <goals>
                    <goal>repackage</goal>
                </goals>
            </execution>
        </executions>
      </plugin>
      <plugin>
          <groupId>io.fabric8</groupId>
          <artifactId>docker-maven-plugin</artifactId>
          <version>0.39.0</version>
          <configuration>
            <dockerHost>https://harbor.xxx.com</dockerHost>
            <registry>harbor.xxx.com</registry>
            <authConfig>
                <push>
                    <username>testharbor</username>
                    <password>harbor123</password>
                </push>
            </authConfig>
            <images>
                <image>
                    <name>${app.name}</name>
                    <build>
                        <dockerFile>${project.basedir}/Dockerfile</dockerFile>
                    </build>
                </image>
            </images>
        </configuration>
      </plugin>
    </plugins>
</build>

Dockerfile is

FROM openjdk:17-alpine

ENV JAVA_OPTS="-Xms100m -Xmx100m -Djava.security.egd=file:/dev/./urandom"

ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar

RUN addgroup -S spring \
    && adduser -S spring -G spring \
    && ln -sf /usr /share/zoneinfo/Asia/Shanghai /etc/localtime \
    && echo "Asia/Shanghai" > /etc/timezone \
    && touch /app.jar

USER spring:spring

EXPOSE 3000
ENTRYPOINT ["sh", "-c", "java ${JAVA_OPTS} -jar /app.jar ${0} ${@}"]
oriming commented 1 year ago

@sny-boy : Which jar are you referring to?

@rohanKanojia After testing, even if the com.github.binarywang dependencies are removed, an error is still reported later. Specific environmental information is shown above.

oriming commented 1 year ago

@rohanKanojia Is it consistent with the problem described by google/gson issues, derived from unit test

kk-fan commented 1 year ago

@3bluebird 貌似docker.host配置错误 它应该配置为docker的远程操控的端口; 而且很巧的是你docker.host配置的是 harbor 地址,harbor会返回一个400的页面。

docker-maven-plugin 在docker.host配置错误后没有对异常结果处理 image

schnieders commented 1 year ago

I ran into the same issue and was able to solve it on my own.

My mistake was, that I used another build-arg to refer to a base image via FROM as used in my pom.xml. The effect was, that the plugin resolved the FROM-base image to an empty String. When the plugin requests the Docker-API to get the images, it used the URI /v1.42/images/ instead of /v1.42/images/<FROM_IMAGE>. As seen in the error message, the response was a JsonArray (containing all local images) instead of a JsonObject.

A check to control, that a FROM base-image in the Dockerfile name is not empty, could be an improvement.

jamo3 commented 8 months ago

I'm seeing a very similar problem with 0.44.0 (but not 0.43.x releases) The error I see is: Expected a com.google.gson.JsonObject but was com.google.gson.JsonArray

My docker file contains:

ARG JDK_IMAGE=${docker.registry.host}/${docker.jdk.base.image} FROM $JDK_IMAGE as jre

Not clear on how to resolve or if this is a bug with 0.44.0

rohanKanojia commented 8 months ago

@jamo3 : Do you think it's the one reported in https://github.com/fabric8io/docker-maven-plugin/issues/1756 ?

rohanKanojia commented 8 months ago

@jamo3 : I've merged changes that are supposed to fix this issue. Could you please try out Docker Maven Plugin Snapshots and see if it fixes your issue.

jamo3 commented 8 months ago

Sorry, on vacation last week. Tried the snapshot version today, but it's still failing. Here's the debug info: ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.45-SNAPSHOT:build (docker-build) on project kafka-comm-docker: Execution docker-build of goal io.fabric8:docker-maven-plugin:0.45-SNAPSHOT:build failed: Expected a com.google.gson.JsonObject but was com.google.gson.JsonArray -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal io.fabric8:docker-maven-plugin:0.45-SNAPSHOT:build (docker-build) on project kafka-comm-docker: Execution docker-build of goal io.fabric8:docker-maven-plugin:0.45-SNAPSHOT:build failed: Expected a com.google.gson.JsonObject but was com.google.gson.JsonArray at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:333) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174) at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75) at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162) at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283) at org.apache.maven.cli.MavenCli.main (MavenCli.java:206) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:568) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348) Caused by: org.apache.maven.plugin.PluginExecutionException: Execution docker-build of goal io.fabric8:docker-maven-plugin:0.45-SNAPSHOT:build failed: Expected a com.google.gson.JsonObject but was com.google.gson.JsonArray at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:133) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174) at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75) at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162) at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283) at org.apache.maven.cli.MavenCli.main (MavenCli.java:206) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:568) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348) Caused by: com.google.gson.JsonSyntaxException: Expected a com.google.gson.JsonObject but was com.google.gson.JsonArray at com.google.gson.internal.bind.TypeAdapters$33$1.read (TypeAdapters.java:869) at com.google.gson.Gson.fromJson (Gson.java:963) at com.google.gson.Gson.fromJson (Gson.java:928) at com.google.gson.Gson.fromJson (Gson.java:877) at com.google.gson.Gson.fromJson (Gson.java:848) at io.fabric8.maven.docker.util.JsonFactory.newJsonObject (JsonFactory.java:18) at io.fabric8.maven.docker.access.hc.DockerAccessWithHcClient.getImageId (DockerAccessWithHcClient.java:478) at io.fabric8.maven.docker.service.QueryService.getImageId (QueryService.java:135) at io.fabric8.maven.docker.service.BuildService.autoPullBaseImage (BuildService.java:385) at io.fabric8.maven.docker.service.BuildService.buildImage (BuildService.java:69) at io.fabric8.maven.docker.BuildMojo.proceedWithDockerBuild (BuildMojo.java:106) at io.fabric8.maven.docker.BuildMojo.proceedWithBuildProcess (BuildMojo.java:89) at io.fabric8.maven.docker.BuildMojo.buildAndTag (BuildMojo.java:82) at io.fabric8.maven.docker.BuildMojo.processImageConfig (BuildMojo.java:159) at io.fabric8.maven.docker.BuildMojo.executeInternal (BuildMojo.java:71) at io.fabric8.maven.docker.AbstractDockerMojo.execute (AbstractDockerMojo.java:295) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174) at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75) at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162) at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283) at org.apache.maven.cli.MavenCli.main (MavenCli.java:206) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:568) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348) [ERROR]

rohanKanojia commented 8 months ago

@jamo3 : Strange, Is it possible to share a reproducer project? I think I had added an integration test for the #1756 in https://github.com/fabric8io/docker-maven-plugin/blob/master/it/dockerfile-base-as-arg-buildconfig/pom.xml

jamo3 commented 8 months ago

No, sorry can't do that, I can share the docker file or other parts if that would help, but not our actual projects (AFIK we get this issue on all 20 something of our projects).

rohanKanojia commented 8 months ago

@jamo3 : You don't have to share your private projects. You just need to create some simple project in which you're able to reproduce the problem.

I was able to reproduce #1756 on https://github.com/fabric8io/docker-maven-plugin/blob/master/it/dockerfile-base-as-arg-buildconfig . Are you able to reproduce this issue there?