Problems starting Java

If running a legacy java app on a newer RH or RHEL system, youget:

Error occurred during initialization of VM
Unable to load native library:
.../libjava.so: symbol __libc_wait, version GLIBC_2.0 not
defined in file libc.so.6 with link time reference

This is a symptom of an older JDKs that is buggy. Jakub Jelinek of RedHat suggests the following:

gcc -O2 -shared -o ~/libcwait.so -fpic -xc - <<EOF
#include <errno.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/wait.h>
pid_t
__libc_wait (int *status)
{
  int res;
  asm volatile ("pushl %%ebxnt"
                "movl %2, %%ebxnt"
                "movl %1, %%eaxnt"
                "int $0x80nt"
                "popl %%ebx"
                : "=a" (res)
                : "i" (__NR_wait4), "0" (WAIT_ANY), "c" (status), "d" (0),
                  "S" (0));
  return res;
}
EOF

and using LD_ASSUME_KERNEL=2.4.19 LD_PRELOAD=~/libcwait.so when you need to load the buggy JDK.

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Blogplay
  • email
  • LinkedIn
  • PDF
  • Ping.fm
  • RSS
  • Slashdot
  • Twitter
This entry was posted in Java and tagged , , . Bookmark the permalink.
blog comments powered by Disqus