@SpringBootTest, server.port and "Port 8080 is already in use"

Hey!

We’re using the Camunda Spring Boot starter and everything works fine except integration tests. We want to create integration tests with the full Spring Boot context up and running (using the @SpringBootTest annotation) so that we can test the whole way from our own REST API through the process we modelled Camunda.

Running one of the integration tests in isolation works fine. But when running more than one integration test in the same Maven build, we always get the error “Port 8080 is already in use”. We get that error even when we set Spring Boot’s server.port property to another port.

My hypothesis is that Camunda configures the embedded Tomcat to ALWAYS listen on port 8080, regardless of the server.port property. And that Camunda is not properly shut down when the Spring context is re-started for the next integration test, thus causing the “8080 already in use” issue.

Has anyone had similar problems with @SpringBootTest tests? How can we shut down Camunda properly? Or is this caused by something different after all?

Any hints appreciated :).

Thanks,
Tom

Hm. Camunda does use the port you specify via server.port … could it be, that you have another service (or even a “zombie” version of your service) running on 8080? You can scan port consumption via lsof -i tcp:8080

1 Like

See: https://www.baeldung.com/spring-boot-change-port

In a default installation this is file
configuration/default.yml
and you include
server:
port : 8000
or any other value somewhere at the main level.