0
votes

There's an issue for the gradle-docker-plugin and SpringBootVersion 2.0.0.M4
M4 uses a newer jersey client and using the docker-plugin ends in an Exception:

ERROR com.github.dockerjava.core.async.ResultCallbackTemplate - Error during callback
java.lang.IllegalStateException: InjectionManagerFactory not found.
    at org.glassfish.jersey.internal.inject.Injections.lambda$lookupInjectionManagerFactory$0(Injections.java:98)
    at java.util.Optional.orElseThrow(Optional.java:290)
    at org.glassfish.jersey.internal.inject.Injections.lookupInjectionManagerFactory(Injections.java:98)
    at org.glassfish.jersey.internal.inject.Injections.createInjectionManager(Injections.java:68)
    at org.glassfish.jersey.client.ClientConfig$State.initRuntime(ClientConfig.java:432)
    at org.glassfish.jersey.internal.util.collection.Values$LazyValueImpl.get(Values.java:341)
    at org.glassfish.jersey.client.ClientConfig.getRuntime(ClientConfig.java:826)
    at org.glassfish.jersey.client.ClientRequest.getConfiguration(ClientRequest.java:285)
    at org.glassfish.jersey.client.JerseyInvocation.validateHttpMethodAndEntity(JerseyInvocation.java:143)
    at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:112)
    at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:108)
    at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:99)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:456)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:357)
    at com.github.dockerjava.jaxrs.async.POSTCallbackNotifier.response(POSTCallbackNotifier.java:29)
    at com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier.call(AbstractCallbackNotifier.java:50)
    at com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier.call(AbstractCallbackNotifier.java:24)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

My BuildScript in my main project:

buildscript {
    ext {
        springBootVersion = "2.0.0.M4"
    }

    repositories {
        maven { url "https://repo.spring.io/plugins-snapshot" }
        maven { url "https://plugins.gradle.org/m2/" }
    }

    dependencies {
        classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
    }
}
....

As you can see, we load the spring-boot-gradle-plugin version=2.0.0.M4 and all its dependencies.

My subproject build.gradle:

apply plugin: "org.springframework.boot"
apply from: "docker.gradle"
....

Most important the docker.gradle file in the same directory as the build.gradle of the subproject:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.bmuschko:gradle-docker-plugin:3.0.11'
    }
}

apply plugin: com.bmuschko.gradle.docker.DockerRemoteApiPlugin

import com.bmuschko.gradle.docker.tasks.image.*
...
task buildImage(type: DockerBuildImage, dependsOn: copyDockerFiles) {
    version.release = true
    dockerFile = file("${projectDir}/build/docker/Dockerfile")
    inputDir = file("${projectDir}/build/docker")
    tags = ['...']
}

My Questions: How do I know which Version of the jersey client loads SpringBoot 2.0.0.M4? How do I force gradle in docker.gradle to use a specific version of the jersey client? Adding to the classpath didnt work. I think gradle will just use the newest version, wich will be loaded by SpringBoot 2.0.0.M4

1

1 Answers

0
votes

You have to add the following in your build.gradle dependencies as pointed in: This Link

dockerJava 'com.nirima:docker-java-shaded:0.16.2'
dockerJava 'org.slf4j:slf4j-simple:1.7.5'
dockerJava 'cglib:cglib:3.2.0'

After that you have to separate "buildImage" and "tagImage" tasks as suggested in This link

I have tested this with: spring boot 2.0.0.M6