Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker image build failed on Mac M1 chip #76

Open
maiconrocha opened this issue Dec 2, 2024 · 2 comments
Open

Docker image build failed on Mac M1 chip #76

maiconrocha opened this issue Dec 2, 2024 · 2 comments

Comments

@maiconrocha
Copy link

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]
@pxaws
Copy link
Member

pxaws commented Dec 2, 2024

Please note that we do not officially support the build on Mac. We recommend to do the build on a Linux machine. See the readme: https://github.com/aws-observability/application-signals-demo?tab=readme-ov-file#prerequisite. However you are welcome to submit a PR if you get things working on mac.

@maiconrocha
Copy link
Author

As I am not a Java expert, I'm not sure if the fix I applied is following best practices or is something your team would recommend. I've decided to open the issue here in case other customers have stumbled across the same problem and may want a way to just fix the issue and keep moving with the build. I will let the maintainers of this repository decide whether to incorporate that fix into the code or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants