3

I use Apache POI to write out a spreadsheet. The problematic line is where I invoke Sheet#autoSizeColumn(int column). If I run it on a unix shell with no graphical environment, the following exception appears:

Exception in thread "Thread-3" java.lang.UnsatisfiedLinkError: /usr/pkg/java/openjdk7/jre/lib/amd64/xawt/libmawt.so: Shared object "libXext.so.7" not found

According to apache's quick guide there is a property which should be set to signalize headless environment, so I try the following call:

 java -jar -Xmx200m -Djava.awt.headless=true myJar.jar

But I get then another exception for the same line:

Exception in thread "Thread-3" java.lang.UnsatisfiedLinkError: /usr/pkg/java/openjdk7/jre/lib/amd64/libfontmanager.so: Shared object "libfreetype.so.7" not found

The above apache guide also says "I should ensure that the fonts I use in your workbook are available to Java". I really don't use any specific fonts, the one and only thing I do with fonts is

XSSFFont boldFont = (XSSFFont) wb.createFont();
boldFont.setBold(true);
titleRowStyle.setFont(boldFont);

The unix shell runs

openjdk version "1.7.0-internal"
OpenJDK Runtime Environment (build 1.7.0-internal-pkgsrc_2015_01_06_05_56-b00)
OpenJDK 64-Bit Server VM (build 24.71-b01, mixed mode)

and

NetBSD *** 6.1.5 NetBSD 6.1.5 (jajo) #1: Sun Jun 21 09:13:03 UTC 2015  spaj@***:/usr/src/sys/arch/amd64/compile/jajo amd64

Is it possible to fix this issue?

Danny Lo
  • 1,553
  • 4
  • 26
  • 48
  • How did you install the JVM? Was it from a package? Did you skip any dependencies? Do you have freetype installed? – Gagravarr Dec 06 '15 at 16:51
  • I am not the administrator of the target machine so unfortunately I cannot give you such details aboute the JVM installation. Freetype seems to be installed because `freetype-config` is available. – Danny Lo Dec 06 '15 at 17:11
  • You likely need to install the missing libraries on that machine to make it work. – centic Dec 09 '15 at 07:11
  • @centic Is is possible to do this as non-root? – Danny Lo Dec 09 '15 at 11:45
  • Usually this will require root-access as installing these adds system libraries. You could try installing them manually somewhere in the user-directory and adjusting the LD_LIBRARY_PATH to include these, but it sounds like a hack for a very common library which is usually required to have a fully working Java JRE installation. – centic Dec 10 '15 at 07:17

3 Answers3

2

I found an older library version in the system:

bash-4.3$ find /usr -name "libfreetype.*"
find: /usr/games/hide: Permission denied
/usr/pkg/lib/libfreetype.la
/usr/pkg/lib/libfreetype.a
/usr/pkg/lib/libfreetype.so
/usr/pkg/lib/libfreetype.so.6
/usr/pkg/lib/libfreetype.so.6.11.3

Then I created a symbolic link for the lastest available version as if it would be version 7:

ln -s /usr/pkg/lib/libfreetype.so.6.11.3 ~/tmp/lib/libfreetype.so.7

And start now my jar file with an environment variable:

LD_LIBRARY_PATH=~/tmp/lib java -jar -Xmx200m -Djava.awt.headless=true myJar.jar
Danny Lo
  • 1,553
  • 4
  • 26
  • 48
2

I had an issue similar to this. Danny's answer pointed me in the right direction. Basically, if the app is inside a Tomcat Docker container, make sure you are not using the slim version.

Using tomcat:9.0.24-jdk11-openjdk-slim, find /usr -name libfreetype.* shows that FreeType libfreetype was not included in the JVM. Updating the base image to tomcat:9.0.24-jdk11-openjdk resolved this.

Ders
  • 1,068
  • 13
  • 16
0

First, update your apt using RUN apt update; and then install fontconfig libfreetype6 through the below command.

apt install -y fontconfig libfreetype6

I faced this for jdk11.

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103