Hi Konstantin, thank you *very* much for your extremely helpful information, which gives me quite something to digest and think about!
Your remark about the JVM and loading a native library through one classloader only makes me think that it would not be possible at the moment to have two or more webapps with binary resources (that may even be at different version levels over time). Although I would not pursue this therefore at the moment, I still will put your valuable information on the table of "interesting things to explore" and may come back later. The motivation behind such thoughts is to exploit Tomcat as much as possible as it has turned out to be really *great* boon for empowering business administration students to get to create web applications with Tomcat in surprisingly short time (and if BA students can get empowered to exploit Tomcat within a short time, then professionals can get empowered in a fraction of that time, even if they do not speak Java). [In the context of this question the idea was to supply the ooRexx interpreter together with the webapp, such that the webapp contains everything needed to run it. OTOH the students have the interpreter already installed together with its Java bridge and as such can become productive with Tomcat, right after having Tomcat installed on their machines (Windows, Apple and Linux).] Again, thank you very much! ---rony On 11.04.2021 15:19, Konstantin Kolinko wrote: > сб, 10 апр. 2021 г. в 21:50, Rony G. Flatscher (Apache) <r...@apache.org>: >> Is it possible to place and use binaries (including shared libraries) in a >> webapp? Very much like >> supplying jars to the "lib"-directory? >> >> Use case: if possible, I would like to create a webapp that includes >> non-Java binaries (executable, >> image and shared libraries) that get interfaced with via JNI. >> >> If this is possible then how so? Any pointers/hints would be highly >> appreciated! > Hi, Rony! > > 1) You may look for an inspiration on how Tomcat Navive library is loaded > https://tomcat.apache.org/tomcat-9.0-doc/apr.html > https://tomcat.apache.org/native-doc/ > > Note that "64-bit Windows zip" binary distribution includes the > library (tcnative-1.dll). > https://tomcat.apache.org/download-90.cgi > > In the source code, look at > org.apache.tomcat.jni.Library > org.apache.catalina.core.AprLifecycleListener > and its message resources, > java/org/apache/catalina/core/LocalStrings.properties > > You may find examples of System.load(), System.loadLibrary(), > System.mapLibraryName() calls in the Library class. > > See also the system property "java.library.path". > > > 2) JVM has a limitation that a library is allowed to be loaded by one > classloader only. > > That is why using a web application classloader looks to be a poor > place for loading a library, if you are ever going to use its full > features (parallel deployment of several web applications, a reload / > redeploy without stopping Tomcat, etc.) See > https://tomcat.apache.org/tomcat-9.0-doc/class-loader-howto.html > > 3) It is possible to load any classes when Apache Tomcat starts: > > a) with a custom Listener, > > b) abusing a JreMemoryLeakPreventionListener > https://tomcat.apache.org/tomcat-9.0-doc/config/listeners.html > > c) as a custom resource > https://tomcat.apache.org/tomcat-9.0-doc/jndi-resources-howto.html#Generic_JavaBean_Resources > > HTH. > > Best regards, > Konstantin Kolinko > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org