Skip to content

Docker build failed: Mockito cannot mock this class #334

@DaBonse

Description

@DaBonse

Plugin Version 6.0.2 and 6.1.0

Keycloak Version: 26.1.2-2

Docker Base Image from https://quay.io/repository/keycloak/keycloak?tab=tags

Docker Build of Keycloak failed, because Plugin Tests failed with error:

`
[...]
44.74 [ERROR] HttpClientTest.postShouldThrowIfRequestThrows:264 Mockito
44.74 Mockito cannot mock this class: class org.apache.http.impl.client.HttpClientBuilder.
44.74
44.74 If you're not sure why you're getting this error, please open an issue on GitHub.
44.74
44.74
44.74 Java : 25
44.74 JVM vendor name : Eclipse Adoptium
44.74 JVM vendor version : 25+36-LTS
44.74 JVM name : OpenJDK 64-Bit Server VM
44.74 JVM version : 25+36-LTS
44.74 JVM info : mixed mode, sharing
44.74 OS name : Linux
44.74 OS version : 6.10.14-linuxkit
44.74
44.74
44.74 You are seeing this disclaimer because Mockito is configured to create inlined mocks.
44.74 You can learn about inline mocks and their limitations under item #39 of the Mockito class javadoc.
44.74
44.74 Underlying exception : org.mockito.exceptions.base.MockitoException: Could not modify all classes [class org.apache.http.impl.client.HttpClientBuilder, class java.lang.Object]
44.74 [INFO]
44.74 [ERROR] Tests run: 109, Failures: 0, Errors: 76, Skipped: 0
44.74 [INFO]
44.74 [INFO] ------------------------------------------------------------------------
44.74 [INFO] BUILD FAILURE
44.74 [INFO] ------------------------------------------------------------------------
44.74 [INFO] Total time: 42.887 s
44.74 [INFO] Finished at: 2025-09-30T00:56:53Z
44.74 [INFO] ------------------------------------------------------------------------
44.75 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.5.3:test (default-test) on project keycloak-rest-provider:
44.75 [ERROR]
44.75 [ERROR] See /tmp/target/surefire-reports for the individual test results.
44.75 [ERROR] See dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
44.75 [ERROR] -> [Help 1]
44.75 [ERROR]
44.75 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
44.75 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
44.75 [ERROR]
44.75 [ERROR] For more information about the errors and possible solutions, please read the following articles:
44.75 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

`

This is one example error, picked from the Docker logs. All errors have the same form

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions