2

Recently I started using Jenkins in a Docker container with Oracle Java 8. When building a project with Gradle I get this error message:

UnsatisfiedLinkError: linux-amd64/libnative-platform.so: libstdc++.so.6: cannot open shared object file: No such file or directory

In Jenkins I selected "Force GRADLE_USER_HOME to use workspace" with no luck at all. The file libnative-platform.so is in the directory expected but gradle won't work. I tried installing Gradle in the container and same result. My last setup is with Gradle Wrapper.

I looked everywhere but I had no luck on my quest. I appreciate if someone can shed a light on this.

Paulo Pedroso
  • 3,555
  • 2
  • 29
  • 34

3 Answers3

6

You can make this work by installing the libstdc++ package in Alpine

apk add --no-cache libstdc++
mixja
  • 6,977
  • 3
  • 32
  • 34
2

libstdc++.so.6: cannot open shared object file

libnative-platform.so of the JRE/JDK is linked against gnu libc but Alpine images are based on musl libc.

The easy solution is to use a glibc based docker image like Debian, if you want to stick with Alpine you might find some clues in this github issue.

Erik Dannenberg
  • 5,716
  • 2
  • 16
  • 21
  • I'll check the link, I know there's some kind of trick to install Oracle Java in the container, will take a look at it too. Will post the result, thanks a lot @Erik. – Paulo Pedroso Jun 13 '16 at 19:41
2

The problem is that Oracle JDK is linked against GNU C library (glibc) that is not available here.

Alpine Linux doesn’t use glibc as conventional distributions like Debian, Fedora or Gentoo. Instead, it uses musl libc, a lightweight, fast, simple and standards-conform C library (i.e. everything that glibc is not).

The solution is very simple, just install OpenJDK from the Alpine repository (package openjdk8). Don’t worry about compatibility, Oracle JDK 8 is just branded distribution of OpenJDK 8, the code base is nearly identical.

If you insist on Oracle JDK for whatever reason and don’t care about security at all*, then don’t use Alpine Linux, but some conventional distribution…

You can read more in my article JRuby on Alpine Linux on the JRuby wiki.

* Oracle JDK has restricted cryptography by default, because of U.S. policy. It’s distributed with Ask.com adware. And because it’s distributed only as a BLOB, you can’t know what else bad is inside…

Jakub Jirutka
  • 10,269
  • 4
  • 42
  • 35
  • 1
    Good info, I didn't knew about that cryptography thing. I had to pause the job for a couple of days and will get back to it, will keep you posted. – Paulo Pedroso Jun 14 '16 at 11:54
  • Installing unlimited cryptography strength is dead easy and the adware bit is only true for Windows/Mac installs and optional at that. – Erik Dannenberg Jun 14 '16 at 12:06
  • @ErikDannenberg Still most people don’t even know about it. Anyway, the point is that it greatly reduces Oracle’s credibility, enough for that you don’t wanna install nontransparent BLOB from them. Especially when there’s no reason for that. – Jakub Jirutka Jun 14 '16 at 12:17