java plugin does not work with non-openjdk java

Bug #568234 reported by Gabriel Nell
30
This bug affects 6 people
Affects Status Importance Assigned to Milestone
collectd (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Binary package hint: collectd

I'm on lucid, and I've installed collectd-core and sun-java6-jdk from the partners repository. Updating collectd.conf to have "LoadPlugin java" results in the following failure:

lt_dlopen (/usr/lib/collectd/java.so) failed: file not found
Unable to load plugin java.

The file referenced does in fact exist. I think what's going on is that java.so was built statically linking to the openjdk location of libjvm.so. Installing openjdk-6-jdk resolved the issue.

The bug here is that the collectd-core package has a hidden dependancy on a specific flavor of java. I suspect this repros on pre-lucid as well.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in collectd (Ubuntu):
status: New → Confirmed
Revision history for this message
frntn (frntn) wrote :

Looking at java.so content we can find the PATH from which it will try load the libjvm.so

> prompt$ strings /usr/lib/collectd/java.so | grep jre
> /usr/lib/jvm/default-java/jre/lib/amd64/server

So I have symlinked this *default-java* to my actual *java-7-oracle* install

> prompt$ ln -sf /usr/lib/jvm/java-7-oracle /usr/lib/jvm/default-java

My plugin is now loaded and ready to use.

---
ubuntu trusty 14.04.2 LTS

Revision history for this message
Poil (poil) wrote :

Hi,

A better way is to declare in /etc/default/collectd
LD_PRELOAD=/etc/alternatives/jre_1.8.0/lib/amd64/server/libjvm.so

Like that if we have openjdk 1.7 and 1.8 installed (or Java Oracle) on our host collectd jmx will work

Revision history for this message
Andreas Steffan (a-steffan) wrote :

Personally had no issues with artful, but the issue appeared with bionic where default-java symlinks to openjdk-11-jre-headless which has libjvm.so in a different directory (and not below jre/lib/amd64/server where it is expected by java.so).

My quick hack was:

patchelf --set-rpath '/usr/lib/jvm/default-java/lib/server' java.so

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.