3

OS is Linux Ubuntu 16.04 LTS

(The application runs absolutely fine on Windows, I did not have to configure anything after the installation of Matlab Compiler SDK)

I am writing a web application in Java which also calls some functions written in Matlab which requires install Matlab Compiler SDK, after the installation, it told me to append this /usr/local/MATLAB/MATLAB_Runtime/v901/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v901/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v901/sys/os/glnxa64: to the end of the LD_LIBRARY_PATH variable, which I did by

export LD_LIBRARY_PATH=/usr/local/MATLAB/MATLAB_Runtime/v901/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v901/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v901/sys/os/glnxa64:

But why do I keep getting this error when I try to run the web app in Netbeans?

java.lang.UnsatisfiedLinkError: Failed to find the required library libmwmclmcrrt.so.9.0.1 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.

libmwmclmcrrt.so.9.0.1 resides inside the /usr/local/MATLAB/MATLAB_Runtime/v901/runtime/glnxa64 directory

I also added -Djava.library.path to point to 3 directory entries above to see if it helps, but it does not do anything good at all.

I read several posts on here, but did not seem to solve it.

  1. JNI: Library is Found on Path, but Method is not (java.lang.UnsatisfiedLinkError)
  2. java.lang.UnsatisfiedLinkError even on setting -Djava.library.path

How do I fix this? BTW, this is a web application

Community
  • 1
  • 1
Trash Can
  • 6,608
  • 5
  • 24
  • 38
  • Can you verify that you've set `java.library.path` correctly? What is the value of `java.library.path` property if you run `java -Djava.library.path= -XshowSettings:properties`? – vsminkov Aug 10 '16 at 01:03
  • @vsminkov It just returns whatever I passed which is `/usr/local/MATLAB/MATLAB_Runtime/v901/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v901/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v901/sys/os/glnxa64:` – Trash Can Aug 10 '16 at 01:40
  • so... In `showSettings` output path doesn't split on `:`? What is `path.separator` then? – vsminkov Aug 10 '16 at 01:42
  • `path.separator` is `:`, it does split on `:` since this is Linux, `java.library.path` showed `/usr/local/MATLAB/MATLAB_Runtime/v901/runtime/glnxa64:/usr/local/MATLAB/MATLAB_‌​Runtime/v901/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v901/sys/os/glnxa64:` without the colon `:` – Trash Can Aug 10 '16 at 01:49
  • that sounds strange. is there any chance that there is mess with 64/32-bit libraries? – vsminkov Aug 10 '16 at 01:55
  • Yeah, it has been annoying me for awhile, only happens on my Linux, on Windows, it runs just fine. Here is the link to the SDK http://www.mathworks.com/products/compiler/mcr/ – Trash Can Aug 10 '16 at 02:01
  • inside java how do you load the link library? – kuhajeyan Aug 10 '16 at 05:45
  • What does `ldd /usr/local/MATLAB/MATLAB_Runtime/v901/runtime/glnxa64/libmwmclmcrrt.so.9.0.1` say? – user2543253 Aug 10 '16 at 10:25
  • @Dummy did you find a solution to this? For sometimes it finds it and sometimes it fails with the error you mentioned. – Jay Apr 12 '17 at 17:17
  • @Jay so we decided to roll with windows because we didn't want to deal with the trouble, but I think you could try exporting `LD_LIBRARY_PATH` and then starts your IDE from the command line using the same terminal, that way, the terminal session in which you exported the variable `LD_LIBRARY_PATH` is preserved . I am not sure if this will work because I haven't tried. – Trash Can Apr 12 '17 at 18:36
  • @Dummy I also did the same, couldn't figure it out how to get it working on Ubuntu. Tried couple of things... 1.) set matlab.conf and added it under `/etc/ld.so.conf.d/` - This screwed up my system wide `LD_LIBRARY_PATH`, 2.) set `LD_LIBRARY_PATH` under by `.bashrc`, this also didnt help, 3.) set `LD_LIBRARY_PATH` under the `idea.vmoptions`, didnt help. Seems some issue with MCR on linux, or the right configuration is not documented on mathworks site. – Jay Apr 20 '17 at 08:09
  • @Jay, not sure if it is still relevant to you, but I managed to fix it on a MacOS. Should be similar for Linux – Trash Can Jul 18 '18 at 01:40
  • @Dummy not relevant any more, but anyway, thanks for getting back – Jay Jul 18 '18 at 11:21

1 Answers1

1

[ Tested on Mac OS High Sierra version 10.13.5 (17F77), should be similar for Linux ]

What I did was when I started the application server (In my case Payara). I provided the path to the javabuilder.jar like so

For Payara Full

asadmin deploy --libraries /path/to/javabuilder.jar app.war

For Payara Micro

java -jar payara-micro.jar --deploy app.war --addlibs /path/to/javabuilder.jar

Note: /path/to/javabuilder.jar is the location of javabuilder.jar within the directory MATLAB_HOME/MATLAB_Runtime/SOME_VERSION/toolbox/javabuilder/jar/javabuilder.jar, Copying this javabuilder.jar file out and reference it will fail with the same error. It must be its original path for it to work. Not sure why

Trash Can
  • 6,608
  • 5
  • 24
  • 38