Search code examples
matlabnetbeansenvironment-variablesmatlab-compilerjavabuilders

How to set up Matlab MCR for Ubuntu and Netbeans (UnsatisfiedLinkedError)


I am deploying a Java EE project in a server that uses the MCR of Matlab for some image processing functions. I've been trying this for months I can't make it work. The problem is when it is going to uses the MCR it cannot find the .so libraries. I got this error:

javax.servlet.ServletException: Failed to find the library libmwmclmcrrt.so.7.13, required by MATLAB builder JA, on java.library.path. This library is typically installed along with MATLAB or the MCR, its absence may indicate an issue with that installation or r the current path configuration. The MCR version that this component is trying to use is 7.13.

ROOT CAUSE:

java.lang.UnsatisfiedLinkError: Failed to find the library libmwmclmcrrt.so.7.13, required by MATLAB Builder JA, on java.library.path. This library is typically installed along with MATLAB or the MCR, its absence may indicate an issue with that installation or the current path configuration. The MCR version that this component is trying to use is: 7.13.

The servers uses:

  • Ubutuntu 64 bits.
  • Netbeans 7.4
  • Glassfish
  • java 6 sdk
  • first it uses MCR 7.13 now it uses MCR 8.1

Things I've already tried:

  • Setting the environment variables LD_LIBRARY_PATH and XAPPLERSDIR with export:

export LD_LIBRARY_PATH=/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/sys/java/jre/glnxa64/jre/lib/amd64/native_threads:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/sys/java/jre/glnxa64/jre/lib/amd64/server:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/sys/java/jre/glnxa64/jre/lib/amd64:$LD_LIBRARY_PATH

export XAPPLRESDIR=/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/X11/app-defaults

  • Setting the environment variables LD_LIBRARY_PATH and XAPPLERSDIR with setenv:

Command setenv not found

I've tried lots of more things that I can't remember and none of them works, it keeps showing the same error (now for version 8.1 instead of 7.13). Please I would I appreciate any help.


Solution

  • I had the same problem working with Linux, Java EE and Matlab. My solution was:

    • Open a terminal
    • Log as root $ su and type password
    • Edit the /etc/enviroment $ gedit /etc/enviroment
    • Add the needed variables, in our case:

    LD_LIBRARY_PATH="/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/sys/java/jre/glnxa64/jre/lib/amd64/native_threads:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/sys/java/jre/glnxa64/jre/lib/amd64/server:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/sys/java/jre/glnxa64/jre/lib/amd64"

    XAPPLRESDIR="/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/X11/app-defaults"

    • Save the file and reboot.
    • Start the server as root.

    What happened with your other solutions, like the export, was that there was no visibility between the variables that you created and the GlassFish server. Setting variables in the environment will asure you that they are visible from any other program/process.