Repository navigation
Facing com.tngtech.keycloakmock.api.MockServerException after upgrading to spring boot 3.5.9 #45500
|
Replies: 1 comment 1 reply
|
This is a port binding issue - the KeycloakMock is trying to use a port that is already occupied. After upgrading Spring Boot, the test lifecycle timing changed. Try this:
KeycloakMock keycloakMock = new KeycloakMock(0); // 0 = random available port
@BeforeAll
static void beforeAll() {
if (keycloakMock != null) {
keycloakMock.stop();
}
keycloakMock = new KeycloakMock(8080);
keycloakMock.start();
}
@Isolated // JUnit 5 - prevents parallel executionThe root cause is likely Spring Boot 3.5.9 changing the test context caching behavior, causing multiple mock servers to attempt starting on the same port. |
This is a port binding issue - the KeycloakMock is trying to use a port that is already occupied. After upgrading Spring Boot, the test lifecycle timing changed.
Try this:
The root cause is likely Spr…