Tempo fa ho scritto un articolo su come installare le librerie APR su una Debian. Ho recentemente ripetuto la procedura ma cambiando distro linux, una Centos 6 a 64 bit. Vediamo nuovamente i passaggi per eseguire l’installazione.
Come di consueto, l’assenza della libreria è segnalata nei log catalina.out di Tomcat all’avvio del servizio:
Feb 01, 2012 5:23:55 PM org.apache.catalina.core.AprLifecycleListener
init INFO: The APR based Apache Tomcat Native library which allows
optimal performance in production environments was not found on
the java.library.path: :/home/tomcat/tomcat/lib:/usr/java/packages/
lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib Feb 01, 2012 5:23:55 PM
org.apache.coyote.AbstractProtocol init INFO: Initializing
ProtocolHandler ["http-bio-8080"] Feb 01, 2012 5:23:55 PM
org.apache.coyote.AbstractProtocol init INFO: Initializing
ProtocolHandler ["ajp-bio-8009"]
Procediamo quindi con l’installazione. Scaricate il pacchetto di Apache Tomcat dal sito ufficiale e scompattatelo nella directory da voi scelta. All’interno del path bin/ è presente un file tomcat-native.tar.gz:
[root@ native]# ls -l /home/tomcat/tomcat/bin/ total 660 -rw-r--r-- 1 tomcat tomcat 28150 Jan 17 10:53 bootstrap.jar -rw-r--r-- 1 tomcat tomcat 13218 Jan 17 10:53 catalina.bat -rwxr-xr-x 1 tomcat tomcat 19189 Jan 17 10:53 catalina.sh -rw-r--r-- 1 tomcat tomcat 2558 Jan 17 10:54 catalina-tasks.xml -rw-r--r-- 1 tomcat tomcat 24148 Jan 17 10:53 commons-daemon.jar -rw-r--r-- 1 tomcat tomcat 197674 Jan 17 10:53 commons-daemon-native.tar.gz -rw-r--r-- 1 tomcat tomcat 2131 Jan 17 10:53 configtest.bat -rwxr-xr-x 1 tomcat tomcat 1982 Jan 17 10:53 configtest.sh -rw-r--r-- 1 tomcat tomcat 1342 Jan 17 10:53 cpappend.bat -rwxr-xr-x 1 tomcat tomcat 7476 Jan 17 10:53 daemon.sh -rw-r--r-- 1 tomcat tomcat 2178 Jan 17 10:53 digest.bat -rwxr-xr-x 1 tomcat tomcat 2021 Jan 17 10:53 digest.sh -rw-r--r-- 1 tomcat tomcat 3264 Jan 17 10:53 setclasspath.bat -rwxr-xr-x 1 tomcat tomcat 3403 Jan 17 10:53 setclasspath.sh -rw-r--r-- 1 tomcat tomcat 406 Feb 1 17:14 setenv.sh -rw-r--r-- 1 tomcat tomcat 2111 Jan 17 10:53 shutdown.bat -rwxr-xr-x 1 tomcat tomcat 1960 Jan 17 10:53 shutdown.sh -rw-r--r-- 1 tomcat tomcat 2112 Jan 17 10:53 startup.bat -rwxr-xr-x 1 tomcat tomcat 1961 Jan 17 10:53 startup.sh -rw-r--r-- 1 tomcat tomcat 42316 Jan 17 10:53 tomcat-juli.jar -rw-r--r-- 1 tomcat tomcat 249259 Jan 17 10:53 tomcat-native.tar.gz -rw-r--r-- 1 tomcat tomcat 4114 Jan 17 10:53 tool-wrapper.bat -rwxr-xr-x 1 tomcat tomcat 5086 Jan 17 10:53 tool-wrapper.sh -rw-r--r-- 1 tomcat tomcat 2116 Jan 17 10:53 version.bat -rwxr-xr-x 1 tomcat tomcat 1965 Jan 17 10:53 version.sh
Scompattate il file, e seguite l’alberatura cosi ottenuta seguendo il path
cd tomcat-native-1.1.22-src/jni/native
Prima di procedere con la compilazione dobbiamo assicurarci che siano presenti le librerie di sistema apr (non includo questa volta ssl, quindi non sono necessarie). Nella Centos 6 ho eseguito il comando
yum install apr-devel.x86_64
per poi lanciare la consueta compilazione
./configure --prefix /home/tomcat/apache-tomcat-7.0.25
--with-java-home=/home/tomcat/java --with-apr=/usr/bin/apr-1-config
make
make install
in cui, nel comando configure, ho specificato il path di installazione dove voglio generare le librerie (ho scelto per comodità di metterle nel path dove ho scompattato apache tomcat), il path dove è installata la JVM e il path delle librerie necessarie alla compilazione. Alla conclusione del comando make install, se non ci sono stati errori ottengo a video il seguente messaggio:
Libraries have been installed in: /home/tomcat/apache-tomcat-7.0.25/lib
If you ever happen to want to link against installed libraries in a
given directory, LIBDIR, you must either use libtool, and specify the
full pathname of the library, or use the `-LLIBDIR' flag during
linking and do at least one of the following: - add LIBDIR to the
`LD_LIBRARY_PATH' environment variable during execution - add LIBDIR
to the `LD_RUN_PATH' environment variable during linking - use the
`-Wl,-rpath -Wl,LIBDIR' linker flag - have your system administrator
add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
Controllando la directory lib/ presente nel path di installazione del servizio, notiamo la presenza delle nuove librerie:
[root@ tomcat]# ls -l lib/
total 7728
-rw-r--r-- 1 tomcat tomcat 15264 Jan 17 10:53 annotations-api.jar
-rw-r--r-- 1 tomcat tomcat 54688 Jan 17 10:53 catalina-ant.jar
-rw-r--r-- 1 tomcat tomcat 130864 Jan 17 10:53 catalina-ha.jar
-rw-r--r-- 1 tomcat tomcat 1503393 Jan 17 10:53 catalina.jar
-rw-r--r-- 1 tomcat tomcat 253717 Jan 17 10:53 catalina-tribes.jar
-rw-r--r-- 1 tomcat tomcat 1748770 Jan 17 10:53 ecj-3.7.1.jar
-rw-r--r-- 1 tomcat tomcat 43490 Jan 17 10:53 el-api.jar
-rw-r--r-- 1 tomcat tomcat 122772 Jan 17 10:53 jasper-el.jar
-rw-r--r-- 1 tomcat tomcat 590923 Jan 17 10:53 jasper.jar
-rw-r--r-- 1 tomcat tomcat 88689 Jan 17 10:53 jsp-api.jar
-rw-r--r-- 1 root root 1179576 Feb 1 17:38 libtcnative-1.a
-rwxr-xr-x 1 root root 1029 Feb 1 17:38 libtcnative-1.la
lrwxrwxrwx 1 root root 23 Feb 1 17:38 libtcnative-1.so -> libtcnative-1.so.0.1.22
lrwxrwxrwx 1 root root 23 Feb 1 17:38 libtcnative-1.so.0 -> libtcnative-1.so.0.1.22
-rwxr-xr-x 1 root root 659872 Feb 1 17:38 libtcnative-1.so.0.1.22
drwxr-xr-x 2 root root 4096 Feb 1 17:38 pkgconfig
-rw-r--r-- 1 tomcat tomcat 176916 Jan 17 10:53 servlet-api.jar
-rw-r--r-- 1 tomcat tomcat 6873 Jan 17 10:53 tomcat-api.jar
-rw-r--r-- 1 tomcat tomcat 745219 Jan 17 10:53 tomcat-coyote.jar
-rw-r--r-- 1 tomcat tomcat 235411 Jan 17 10:53 tomcat-dbcp.jar
-rw-r--r-- 1 tomcat tomcat 76661 Jan 17 10:53 tomcat-i18n-es.jar
-rw-r--r-- 1 tomcat tomcat 48694 Jan 17 10:53 tomcat-i18n-fr.jar
-rw-r--r-- 1 tomcat tomcat 52118 Jan 17 10:53 tomcat-i18n-ja.jar
-rw-r--r-- 1 tomcat tomcat 117904 Jan 17 10:53 tomcat-jdbc.jar
-rw-r--r-- 1 tomcat tomcat 23051 Jan 17 10:53 tomcat-util.jar
Provando ad avviare il servizio, si ottiene però un errore:
SEVERE: Failed to initialize the SSLEngine. org.apache.tomcat.jni.Error: 70023: This function has not been implemented on this platform at org.apache.tomcat.jni.SSL.initialize(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.apache.catalina.core.AprLifecycleListener.initializeSSL(AprLifecycleListener.java:255) at org.apache.catalina.core.AprLifecycleListener.lifecycleEvent(AprLifecycleListener.java:109) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90) at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:401) at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:99) at org.apache.catalina.startup.Catalina.load(Catalina.java:595) at org.apache.catalina.startup.Catalina.load(Catalina.java:620) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:281) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:449)
dovuto al fatto che non ho compilato le librerie con l’opzione –with-ssl. E’ sufficiente modificare una configurazione nel file server.xml che si trova nella dir conf/ di installazione di apache tomcat in questo modo:
<!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="off" />
A questo punto, avviando nuovamente il servizio, le librerie verranno correttamente caricate:
Feb 01, 2012 5:40:29 PM org.apache.catalina.core.AprLifecycleListener init INFO: Loaded APR based Apache Tomcat Native library 1.1.22. Feb 01, 2012 5:40:29 PM org.apache.catalina.core.AprLifecycleListener init INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true]. Feb 01, 2012 5:40:30 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["http-apr-8080"] Feb 01, 2012 5:40:30 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["ajp-apr-8009"]