0

I am trying to get the JMagick library working under Tomcat to do some image translation following an upload.

Magic comes as a semi-stub library.jar archive and a native library libJMagick.so . I have used
System. LoadLibrary ("JMagick");,
but I get errors in the catalina.out complaining about being unable to find the library (details at the end of this message). the key clause being:

Caused by: java.lang.RuntimeException: Can't load MagickLoader (class not found) at magick.Magick.(Magick.java:25)

So where should I put the libraries, currently they are in WEB-INF/lib so that tomcat can use them

Thirumalai murugan
  • 5,698
  • 8
  • 32
  • 54

1 Answers1

1

If your shared object is not installed througha package manager, put into setenv.sh LD_LIBRARY_PATH=$CATALINA_BASE/lib:$LD_LIBRARY_PATH and copy the so to that lib directory.

Michael-O
  • 18,123
  • 6
  • 55
  • 121
  • I copied .so files to my tomcat's lib folder and added LD_LIBRARY_PATH=$CATALINA_BASE/lib:$LD_LIBRARY_PATH to catalina.sh as I dont have setenv.sh .Its not working for me. Same error I am getting – user2523002 Jun 19 '14 at 09:20
  • Do not modify the `catalina.sh`. Always put stuff in `setenv.sh`. If that file does not exist, create it in `bin` and add #!/bin/sh # $Id: setenv.sh 9504 2012-12-10 16:19:19Z osipovmi $ umask 022 LD_LIBRARY_PATH="$CATALINA_HOME/lib:/usr/local/lib:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH. – Michael-O Jun 19 '14 at 11:08
  • I created setenv.sh in bin with content #!/bin/sh # $Id: setenv.sh 9504 2012-12-10 16:19:19Z osipovmi $ umask 022 LD_LIBRARY_PATH="$CATALINA_HOME/lib:/opt/jmagick-6.4.0/lib/:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH where /opt/jmagick-6.4.0/lib is path where my .so files are.Still getting same error. – user2523002 Jun 19 '14 at 11:35
  • Please remove the trailing `/` and show how the exact so name is. – Michael-O Jun 19 '14 at 11:52
  • which trailing / are you talking about? – user2523002 Jun 20 '14 at 10:08
  • My .so file is in /opt/jmagick-6.4.0/lib/ directory.So you want me to write full path like /opt/jmagick-6.4.0/lib/jmagick.so? – user2523002 Jun 24 '14 at 12:32
  • actually i have 2 .so files So I tried doing $ umask 022 LD_LIBRARY_PATH="$CATALINA_HOME/lib:/opt/jmagick-6.4.0/lib/libJMagick.so:$LD_LIBRARY_PATH" LD_LIBRARY_PATH="$CATALINA_HOME/lib:/opt/jmagick-6.4.0/lib/libJMagick-6.4.0.so:$LD_LIBRARY_PATH" Still getting same error export LD_LIBRARY_PATH – user2523002 Jun 24 '14 at 12:41
  • Did you set the `x` bit? – Michael-O Jun 24 '14 at 13:54
  • Which x bit are you talking about? – user2523002 Jun 25 '14 at 10:11
  • The mod of the so must look like this `r-xr-xr-x`. Otherwise the lib is not loadable. – Michael-O Jun 25 '14 at 11:05
  • permissions are fine they are rwxrwxrwx – user2523002 Jun 25 '14 at 11:15
  • OK, seems fine. I would write a small Java test class which resembles your problem and see whether lib is loaded or not. I'd like to exclude any config-related problems. – Michael-O Jun 25 '14 at 12:01
  • Did you get a chance to write that java Test class? – user2523002 Jun 26 '14 at 09:45
  • @user2523002, that task has directed to you. That's why I wrote: "I would write" and not "I will write one for you". – Michael-O Jun 26 '14 at 10:04