title: Throwing java.lang.IllegalAccessException module java.base does not open java.util.concurrent when running Corretto on Java
body: <p>I have 2 microservices: serviceBFF, serviceCore.</p>
  <h2>Stack</h2>
  <ul>
  <li>Spring Boot 2.6.6</li>
  <li>Amazon Corretto 17 (Docker)</li>
  <li>OpenJDK 17 (local)</li>
  <li>Docker (latest)</li>
  </ul>
  <p>serviceBFF calls a REST service in serviceCore that returns a CompletableFuture. When running the 2 services as standalone Java applications in IntelliJ, the request succeed without any issue.</p>
  <p>But when I containerized the 2 services, run them in a compose file, and make a request I got:</p>
  <pre><code>2022-04-22 00:34:40.652 ERROR [service-be,6cee3eed8fdff76a,6cee3eed8fdff76a] 1 --- [nio-8000-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dis
  patcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class java.util.c
  oncurrent.CompletableFuture: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.IllegalAccessException--&gt;module java.base does not open java.util.concurrent to unnamed module @449b2d27] with root cause
  </code></pre>
  <p>Here are my docker related files:</p>
  <h2>Dockerfile</h2>
  <pre><code>FROM amazoncorretto:17-alpine-jdk
  
  ENV TZ=&quot;UTC&quot;
  
  ADD app/target/*.jar /application/
  ADD docker/docker-entrypoint.sh ./
  
  RUN set -xe; \
      adduser -D -u 2001 app.user; \
      chmod a+x /docker-entrypoint.sh
  
  USER app.user
  
  EXPOSE 8001
  
  ENTRYPOINT [ &quot;/docker-entrypoint.sh&quot; ]
  </code></pre>
  <h2>docker-entrypoint</h2>
  <pre><code>#!/bin/sh -e
  
  cd /application
  
  JMX_OPTS=&quot;&quot;
  JMX_PORT=9875
  
  JAVA_OPTS=&quot;${JAVA_OPTS} ${JMX_OPTS}&quot;
  
  exec java -jar $JAVA_OPTS *.jar &quot;$@&quot;
  </code></pre>
  <p>Drilling down, I found the error on serviceBFF, in the part that converts the DTO to EntityModel:</p>
  <pre><code>@PostMapping(
        path = EndpointConstants.PATH_USERS,
        produces = MediaTypes.HAL_JSON_VALUE)
    @ResponseStatus(HttpStatus.OK)
    @Transactional
    public CompletableFuture&lt;PlatformUserOutboundDto&gt; mapUpdateOrCreateIfAbsent(
        @Valid @RequestBody PlatformUserInboundDto platformUserInboundDto) {
  
      log.debug(&quot;Check if user with externalRef={} exists&quot;, platformUserInboundDto.getExternalRef());
  
      return platformUserProxyAsync.mapUpdateOrCreateIfAbsent(platformUserInboundDto);
          // converts to hal
  //        .thenApply(platformUserOutboundDto -&gt; toEntityModel(platformUserInboundDto, platformUserOutboundDto));
    }
  
    private EntityModel&lt;PlatformUserOutboundDto&gt; toEntityModel(PlatformUserInboundDto platformUserInboundDto,
        PlatformUserOutboundDto platformUserOutboundDto) {
  
      log.debug(&quot;converting to hal document {}&quot;, platformUserOutboundDto);
  
      Link dtoLink = WebMvcLinkBuilder.linkTo(
  </code></pre>
  <p>// error is generated here</p>
  <pre><code>WebMvcLinkBuilder.methodOn(PlatformUserController.class).mapUpdateOrCreateIfAbsent(platformUserInboundDto)) // the error happen on this line
          .withSelfRel()
          .expand();
  
      return EntityModel.of(platformUserOutboundDto, dtoLink);
    }
  </code></pre>