Getting java.lang.IllegalStateException: Service to port mapping has not been determined yet

Hii Guys,

I’m trying to mock the Amazon SimpleEmailService using localstack. I am running localstack as a testcontainer in my springboot application but i am getting IllegalStateException again and again. I don’t know what am I missing here can you guys please help me out. I have been stuck on this issue for almost 2 days.

TestContainer creation code:
public static final LocalStackContainer localStackContainer =
new LocalStackContainer(DockerImageName.parse(“localstack/localstack”).withTag(“0.14.2”))
.withEnv(“AWS_ACCESS_KEY_ID”, “accesskey”)
.withEnv(“AWS_SECRET_ACCESS_KEY”, “secretkey”);

AWS SeS Mock client creation code:

public MailSender localMailSender(AmazonSimpleEmailService amazonSimpleEmailService) {
  String someEndpoint= Localstack.INSTANCE.getEndpointSES();
  EndpointConfiguration endpoint = new EndpointConfiguration(someEndpoint, "eu-central-1");
  return new SimpleEmailServiceMailSender(AmazonSimpleEmailServiceClientBuilder
    .withCredentials(new AWSStaticCredentialsProvider(new AnonymousAWSCredentials()))