Skip to content

Docker image build failed on Mac M1 chipΒ #76

@maiconrocha

Description

@maiconrocha

after running the following on my laptop Mac M1 chip

./mvnw clean install -P buildDocker

I faced the error:

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] spring-petclinic-microservices 2.6.7 ............... SUCCESS [  0.183 s]
[INFO] spring-petclinic-admin-server ...................... FAILURE [  6.180 s]
[INFO] spring-petclinic-customers-service ................. SKIPPED
[INFO] spring-petclinic-vets-service ...................... SKIPPED
[INFO] spring-petclinic-visits-service .................... SKIPPED
[INFO] spring-petclinic-config-server ..................... SKIPPED
[INFO] spring-petclinic-discovery-server .................. SKIPPED
[INFO] spring-petclinic-api-gateway 2.6.7 ................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.786 s
[INFO] Finished at: 2024-12-02T16:07:05+10:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.2.0:build (default) on project spring-petclinic-admin-server: Exception caught: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: java.lang.UnsatisfiedLinkError: could not load FFI provider jnr.ffi.provider.jffi.Provider: ExceptionInInitializerError: Can't overwrite cause with java.lang.UnsatisfiedLinkError: java.lang.UnsatisfiedLinkError: /private/var/folders/2p/4n7c7gqs6xb23jgy_sq_3gsh0000gr/T/jffi17500918540463413337.dylib: dlopen(/private/var/folders/2p/4n7c7gqs6xb23jgy_sq_3gsh0000gr/T/jffi17500918540463413337.dylib, 0x0001): tried: '/private/var/folders/2p/4n7c7gqs6xb23jgy_sq_3gsh0000gr/T/jffi17500918540463413337.dylib' (fat file, but missing compatible architecture (have 'i386,x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/private/var/folders/2p/4n7c7gqs6xb23jgy_sq_3gsh0000gr/T/jffi17500918540463413337.dylib' (no such file), '/private/var/folders/2p/4n7c7gqs6xb23jgy_sq_3gsh0000gr/T/jffi17500918540463413337.dylib' (fat file, but missing compatible architecture (have 'i386,x86_64', need 'arm64e' or 'arm64'))
[ERROR] 	at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
[ERROR] 	at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:331)
[ERROR] 	at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:197)
[ERROR] 	at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:139)
[ERROR] 	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2402)
[ERROR] 	at java.base/java.lang.Runtime.load0(Runtime.java:852)
[ERROR] 	at java.base/java.lang.System.load(System.java:2028)
[ERROR] 	at com.kenai.jffi.internal.StubLoader.loadFromJar(StubLoader.java:371)
[ERROR] 	at com.kenai.jffi.internal.StubLoader.load(StubLoader.java:258)
[ERROR] 	at com.kenai.jffi.internal.StubLoader.<clinit>(StubLoader.java:444)
[ERROR] 	at java.base/java.lang.Class.forName0(Native Method)
[ERROR] 	at java.base/java.lang.Class.forName(Class.java:578)
[ERROR] 	at java.base/java.lang.Class.forName(Class.java:557)
[ERROR] 	at com.kenai.jffi.Init.load(Init.java:68)
[ERROR] 	at com.kenai.jffi.Foreign$InstanceHolder.getInstanceHolder(Foreign.java:49)
[ERROR] 	at com.kenai.jffi.Foreign$InstanceHolder.<clinit>(Foreign.java:45)
[ERROR] 	at com.kenai.jffi.Foreign.getInstance(Foreign.java:103)
[ERROR] 	at com.kenai.jffi.Type$Builtin.lookupTypeInfo(Type.java:242)
[ERROR] 	at com.kenai.jffi.Type$Builtin.getTypeInfo(Type.java:237)
[ERROR] 	at com.kenai.jffi.Type.resolveSize(Type.java:155)
[ERROR] 	at com.kenai.jffi.Type.size(Type.java:138)
[ERROR] 	at jnr.ffi.provider.jffi.NativeRuntime$TypeDelegate.size(NativeRuntime.java:187)
[ERROR] 	at jnr.ffi.provider.AbstractRuntime.<init>(AbstractRuntime.java:48)
[ERROR] 	at jnr.ffi.provider.jffi.NativeRuntime.<init>(NativeRuntime.java:66)
[ERROR] 	at jnr.ffi.provider.jffi.NativeRuntime.<init>(NativeRuntime.java:41)
[ERROR] 	at jnr.ffi.provider.jffi.NativeRuntime$SingletonHolder.<clinit>(NativeRuntime.java:62)
[ERROR] 	at jnr.ffi.provider.jffi.NativeRuntime.getInstance(NativeRuntime.java:58)
[ERROR] 	at jnr.ffi.provider.jffi.Provider.<init>(Provider.java:29)
[ERROR] 	at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
[ERROR] 	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:501)
[ERROR] 	at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:132)
[ERROR] 	at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:259)
[ERROR] 	at java.base/java.lang.Class.newInstance(Class.java:804)
[ERROR] 	at jnr.ffi.provider.FFIProvider$SystemProviderSingletonHolder.getInstance(FFIProvider.java:68)
[ERROR] 	at jnr.ffi.provider.FFIProvider$SystemProviderSingletonHolder.<clinit>(FFIProvider.java:57)
[ERROR] 	at jnr.ffi.provider.FFIProvider.getSystemProvider(FFIProvider.java:35)
[ERROR] 	at jnr.ffi.LibraryLoader.create(LibraryLoader.java:73)
[ERROR] 	at jnr.unixsocket.Native.<clinit>(Native.java:76)
[ERROR] 	at jnr.unixsocket.UnixSocketChannel.<init>(UnixSocketChannel.java:101)
[ERROR] 	at jnr.unixsocket.UnixSocketChannel.open(UnixSocketChannel.java:60)
[ERROR] 	at com.spotify.docker.client.UnixConnectionSocketFactory.createSocket(UnixConnectionSocketFactory.java:69)
[ERROR] 	at com.spotify.docker.client.UnixConnectionSocketFactory.createSocket(UnixConnectionSocketFactory.java:44)
[ERROR] 	at com.spotify.docker.client.shaded.org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:118)
[ERROR] 	at com.spotify.docker.client.shaded.org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
[ERROR] 	at com.spotify.docker.client.shaded.org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
[ERROR] 	at com.spotify.docker.client.shaded.org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
[ERROR] 	at com.spotify.docker.client.shaded.org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
[ERROR] 	at com.spotify.docker.client.shaded.org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
[ERROR] 	at com.spotify.docker.client.shaded.org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
[ERROR] 	at com.spotify.docker.client.shaded.org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
[ERROR] 	at com.spotify.docker.client.shaded.org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
[ERROR] 	at com.spotify.docker.client.shaded.org.glassfish.jersey.apache.connector.ApacheConnector.apply(ApacheConnector.java:435)
[ERROR] 	at com.spotify.docker.client.shaded.org.glassfish.jersey.apache.connector.ApacheConnector$1.run(ApacheConnector.java:491)
[ERROR] 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
[ERROR] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
[ERROR] 	at jersey.repackaged.com.google.common.util.concurrent.MoreExecutors$DirectExecutorService.execute(MoreExecutors.java:299)
[ERROR] 	at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:124)
[ERROR] 	at jersey.repackaged.com.google.common.util.concurrent.AbstractListeningExecutorService.submit(AbstractListeningExecutorService.java:50)
[ERROR] 	at jersey.repackaged.com.google.common.util.concurrent.AbstractListeningExecutorService.submit(AbstractListeningExecutorService.java:37)
[ERROR] 	at com.spotify.docker.client.shaded.org.glassfish.jersey.apache.connector.ApacheConnector.apply(ApacheConnector.java:487)
[ERROR] 	at com.spotify.docker.client.shaded.org.glassfish.jersey.client.ClientRuntime$2.run(ClientRuntime.java:178)
[ERROR] 	at com.spotify.docker.client.shaded.org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
[ERROR] 	at com.spotify.docker.client.shaded.org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
[ERROR] 	at com.spotify.docker.client.shaded.org.glassfish.jersey.internal.Errors.process(Errors.java:315)
[ERROR] 	at com.spotify.docker.client.shaded.org.glassfish.jersey.internal.Errors.process(Errors.java:297)
[ERROR] 	at com.spotify.docker.client.shaded.org.glassfish.jersey.internal.Errors.process(Errors.java:267)
[ERROR] 	at com.spotify.docker.client.shaded.org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:340)
[ERROR] 	at com.spotify.docker.client.shaded.org.glassfish.jersey.client.ClientRuntime$3.run(ClientRuntime.java:210)
[ERROR] 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
[ERROR] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
[ERROR] 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
[ERROR] 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
[ERROR] 	at java.base/java.lang.Thread.run(Thread.java:1575)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :spring-petclinic-admin-server

In order to fix I had to update the file from spring-petclinic-admin-server/pom.xml:

from:

<profiles>
  <profile>
    <id>buildDocker</id>
    <build>
      <plugins>
        <plugin>
          <groupId>com.spotify</groupId>
          <artifactId>docker-maven-plugin</artifactId>
          <version>${docker.plugin.version}</version>
        </plugin>
      </plugins>
    </build>
  </profile>
</profiles>

to:

<profiles>
  <profile>
    <id>buildDocker</id>
    <build>
      <plugins>
        <plugin>
          <groupId>io.fabric8</groupId>
          <artifactId>docker-maven-plugin</artifactId>
          <version>0.38.1</version>
          <executions>
                <execution>
                    <id>build</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>build</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
      </plugins>
    </build>
  </profile>
</profiles>

Then I was able to build successfully:

[INFO] spring-petclinic-admin-server ...................... SUCCESS [ 41.743 s]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions