Search code examples
javac++jakarta-eejava-native-interfacejms

Calling C++ From JMS with JNI


I'm trying to call Sleuth Kit C++ Framework through its JNI wrapper from a JMS MessageListener. But I'm getting this error

java.lang.UnsatisfiedLinkError: /tmp/libtsk_jni.so: libtsk.so.10: cannot open shared object file: No such file or directory

I tried coping the libtsk_jni.so to /tmp but no difference. But I can do this in a Java console application. What could be the error?

public void onMessage(Message message) {
   try {
      String imagePath = "uploads/Cfreds001A001.dd";
         try{
            SleuthkitCase sk = SleuthkitCase.newCase(imagePath + ".db");

         } catch (TskCoreException ex) {

         } 
  } catch (JMSException ex) {
     Logger.getLogger(WorkerBean.class.getName()).log(Level.SEVERE, null, ex);
  } catch (InterruptedException ex) {
     Logger.getLogger(WorkerBean.class.getName()).log(Level.SEVERE, null, ex);
}

Solution

  • Attempting to use native methods from code running in a Java EE container is not allowed by the standard and may cause undefined behavior. See the JavaWorld article from August 2000 "Programming restrictions on EJB", still true today as far as I know.

    Depending on your Java EE container, you may in fact be able to get this to work. It may help to put the libtsk_jni.so in the system library directory or to edit the server's start script to set the LD_LIBRARY_PATH environment variable.