jeudi 25 janvier 2018

Testing: Unable to register MBean instance already exists

We have a few integration tests but recently we have faced a problem when a @ManagedResource is in the way:

Unable to register MBean [com.api.configuration.ApiConfiguration@63fde7ca] with key 'apiConfiguration'; nested exception is javax.management.InstanceAlreadyExistsException: api:name=ApiConfiguration

And the offending bean looks like this:

@Component
@ManagedResource(objectName = "api:name=ApiConfiguration")
public class ApiConfiguration {

    @ManagedOperation   
    public void reloadConfiguration() {
        // do something
    }

}

We have tried adding a @DirtiesContext on every integration test without success. The error only appears when running all tests from Maven or IntelliJ. If we run only one of the failing tests it works.

Aucun commentaire:

Enregistrer un commentaire