File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes  Cannot find jni_md.h in /usr/bin/java/ when installing APR Native Library in Tomcat 6 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark " Cannot find jni_md.h in /usr/bin/java/ when installing APR Native Library in Tomcat 6 " Watch " Cannot find jni_md.h in /usr/bin/java/ when installing APR Native Library in Tomcat 6 " New topic
Author

Cannot find jni_md.h in /usr/bin/java/ when installing APR Native Library in Tomcat 6

Ulrich Von Litchtenstein
Greenhorn

Joined: Oct 11, 2009
Posts: 8
Hi folk,

Anyone ran into

when running trying to install APR native Library in tomcat?

I followed this instruction when attempting the installation. Its from Professional Apache Tomcat by Vivek Chopra, Sing Li.


For Linux/Unix, you need to install this from source.
❑ If you don’t have APR installed on your machine, download the source from http://apr
.apache.org . Install APR using the following steps as the root user to install the APR in its
default location ( /usr/local/apr ). If running as a non-root user, use the --prefix option
with configure to specify another install location.
$ tar zxvf apr-x.y.z.tar.gz
$ cd apr-x.y.z
$ ./buildconf
$ ./configure
$ make install



The APR JNI wrapper sources are packaged, along with the Tomcat distribution, as the tomcat- native
.tar.gz file in <TOMCAT_HOME>/bin . The installation steps are provided in the code that follows. In
the steps shown, the default apr_install_location is /usr/local/apr as shown in the earlier
step. If you don’t need OpenSSL support, you can use the --without-ssl option with configure to
disable it. If you need OpenSSL, you can download it from www.openssl.org . The JNI wrapper gets
installed under /usr/local/apr/lib , and as before, a --prefix option for configure can install it
elsewhere.
$ cd /path/to/tomcat/bin
$ tar zxvf tomcat-native.tar.gz
$ cd tomcat-native-x.y.z-src/jni/native
The APR JNI wrapper sources are packaged, along with the Tomcat distribution, as the tomcat- native
.tar.gz file in <TOMCAT_HOME>/bin . The installation steps are provided in the code that follows. In
the steps shown, the default apr_install_location is /usr/local/apr as shown in the earlier
step. If you don’t need OpenSSL support, you can use the --without-ssl option with configure to
disable it. If you need OpenSSL, you can download it from www.openssl.org . The JNI wrapper gets
installed under /usr/local/apr/lib , and as before, a --prefix option for configure can install it
elsewhere.
$ cd /path/to/tomcat/bin
$ tar zxvf tomcat-native.tar.gz
$ cd tomcat-native-x.y.z-src/jni/native
$ ./configure --with-apr=apr_install_location --with-ssl=openssl_install_location
$ make install




The line highlighted bold threw this error. I tried googling the problem, but there is hardly anything online with jni_md.h let alone to do with Tomcat's APR installation.

Would be appreciate if anyone can shed some light on this. Many thank.



OS: Fedora 16
JDK: 1.6
JAVA_HOME set to /usr/lib/java
Tomcat Version: 6
Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 509
    
    6
If fedora package manager already provides prebuilt APR and tcnative binaries, just have to install them - no need to build from source.
If it doesn't provide or provides an incompatible version, then try these steps:

1. First, check whether the JVM includes (jni.h, jni_md.h, etc) are installed.
With some OSes and package managers, it's not necessary that installing just the JDK will also install the include files.

For example, in CentOS (which is a kind of step sibling of Fedora), installing just the OpenJDK 1.6 does not install the includes; the associated "devel" package (named something like java-1.6.0-openjdk-devel.x86_64) should also be installed.

Start by checking in /usr/lib/java (which is hopefully the right JDK directory) whether there's an /include subdirectory under it.
Also, it's possible /usr/lib/java is not the right JDK directory in the first place; so also look for directories like /usr/lib/jvm and /include subdirectories under those.

If they're not present, do a "find / -name jni" just to be sure.
If it doesn't give any matches, then you're just missing the "devel" package. Find the right package name (using "yum list | grep" or "yum search") and install that.

2. Even if the includes have been installed, it's important to give the right hints about your particular installation to "configure" so that it can prepare the makefile correctly.
So, provide the following additional hints to configure:


Ulrich Von Litchtenstein
Greenhorn

Joined: Oct 11, 2009
Posts: 8
Thanks.

Yes there is a jvm directory in /usr/lib which has

$less /usr/bin

drwxr-xr-x 2 root root 4096 Sep 15 23:28 java/
drwxr-xr-x 2 root root 4096 Sep 15 23:28 java-1.5.0/
drwxr-xr-x 2 root root 4096 Sep 15 23:28 java-1.6.0/
drwxr-xr-x 2 root root 4096 Sep 15 23:28 java-1.7.0/
drwxr-xr-x 2 root root 4096 Sep 15 23:28 java-ext/
drwxr-xr-x 4 root root 4096 Jan 26 23:43 jvm/
drwxr-xr-x 2 root root 4096 Sep 15 23:28 jvm-commmon/

Inside jvm directory I got:

drwxr-xr-x 3 root root 4096 Jan 26 23:43 java-1.5.0-gcj-1.5.0.0/
drwxr-xr-x 3 root root 4096 Jan 26 23:43 java-1.6.0-openjdk-1.6.0.0/
lrwxrwxrwx 1 root root 21 Jan 26 23:43 jre -> /etc/alternatives/jre/
lrwxrwxrwx 1 root root 27 Jan 26 23:43 jre-1.5.0 -> /etc/alternatives/jre_1.5.0/
lrwxrwxrwx 1 root root 26 Jan 26 23:43 jre-1.5.0-gcj -> java-1.5.0-gcj-1.5.0.0/jre/
lrwxrwxrwx 1 root root 27 Jan 26 23:43 jre-1.6.0 -> /etc/alternatives/jre_1.6.0/
lrwxrwxrwx 1 root root 30 Jan 26 23:43 jre-1.6.0-openjdk -> java-1.6.0-openjdk-1.6.0.0/jre/
lrwxrwxrwx 1 root root 25 Jan 26 23:43 jre-gcj -> /etc/alternatives/jre_gcj/
lrwxrwxrwx 1 root root 29 Jan 26 23:43 jre-openjdk -> /etc/alternatives/jre_openjdk/


When I did java -version i get 1.6 so those 1.5s are obsolete. But I got Java directories with java executable everywhere so not sure which one is called when I run

$java

And the jni doesn't exist. Only jni I have is the directory in tomcat native library.

Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 509
    
    6
$java will execute the first "java" found in $PATH (usually in /usr/bin). java -version will also give the vendor name. Anyway, configure does not really require java executable; it's more interested in where to find JDK home and /include under that. My guess, just based on my installation, would be that the active JDK here is /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/

It seems the openJDK "devel" package is missing. Find the openjdk devel package using yum and install it. I'm not sure what its exact name is in fedora, but it's possible to find out using something like "yum list | grep jdk | grep devel".

Ulrich Von Litchtenstein
Greenhorn

Joined: Oct 11, 2009
Posts: 8
Karthik Shiraly wrote:$java will execute the first "java" found in $PATH (usually in /usr/bin). java -version will also give the vendor name. Anyway, configure does not really require java executable; it's more interested in where to find JDK home and /include under that. My guess, just based on my installation, would be that the active JDK here is /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/

It seems the openJDK "devel" package is missing. Find the openjdk devel package using yum and install it. I'm not sure what its exact name is in fedora, but it's possible to find out using something like "yum list | grep jdk | grep devel".



Thank Karthikh. I have changed the JDK home to /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/ and installed the "devel".

jni_md.h error went away. But APR wasn't stalled as per catalina log. But thanks for your help and suggestions.
Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 509
    
    6
I'm not sure what the issue is, but looking through that article from the book, it seems odd to me that a 'make' has not been done before 'make install'. That's the usual sequence - I'm not sure why it's not been included there. Retry the steps, but this time do a 'make' (plain make without any arguments) and only after that do a 'make install'.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cannot find jni_md.h in /usr/bin/java/ when installing APR Native Library in Tomcat 6