0

I have a web project with some native libraries. Most of them are loaded by JNA library.

I put them in this folder

WEB-INF\classes\*.dll

of a ROOT package.

When the application starts they are loaded by Tomcat in

${catalina.home}\webapps\ROOT\WEB-INF\classes\mylibrary.dll

All libraries are founded by JNA and work, however there is just one library managed by third parties (Zebra Multilink platform SDK) that I cannot load from that folder. Maybe because it doesn't work with JNA but with JNI. If I move that libraries to

 ${catalina.home}\bin

that is the folder defined by java.library.path param in tomcat start command it works!

Can I distribute libraries in ROOT.war package and set tomcat to look into all my applications to find native libraries?

JoshDM
  • 4,939
  • 7
  • 43
  • 72
Tobia
  • 9,165
  • 28
  • 114
  • 219
  • You can do it like described in https://stackoverflow.com/a/15984514/1398418 or https://stackoverflow.com/a/6909689/1398418 – Oleg Sep 27 '17 at 07:35

1 Answers1

0

Well, you can modify java.library.path and let it point to the exploded webapp directory (your ${catalina.home}\webapps\ROOT\WEB-INF\classes\, but resolve ${catalina.home} yourself beforehands).

Florian Fray
  • 274
  • 1
  • 6
  • Ok, but this works just for the main app (ROOT) I was looking something to let it works for all application looking into its main class folder, like JNA. – Tobia Sep 27 '17 at 06:57
  • This works for any application you're running. Tomcat unpacks all applications unless you configure it to not unpack. So you can change java.library.path to the exploded WAR directory plus some extra path, like ```${catalina.home}\webapps\yourapp\WEB-INF\classes```. I'd personally prefer to use a distinct directory like WEB-INF/lib, but that's a matter of taste. – Florian Fray Sep 27 '17 at 19:41