Search code examples
tomcatantbuild.xmljnetpcap

Tomcat: java.lang.UnsatisfiedLinkError: no jnetpcap in java.library.path


I'm getting the following error when deploying my application to Tomcat: Tomcat error

I have added the jnetpcap jar file to the lib folder of Tomcat. I have also added it to my classpath in eclipse.

I am deploying my application as a WAR file built using Apache ant form the command line. I think the problem may lay in my build.xml file.

build.xml

<?xml version="1.0" ?>
<project name="IBM_Project" default="dist" basedir=".">
<description>
    sample
</description>
<!-- set global properties for this build -->
<property name="src" location="src"/>
<property name="build" location="build"/>
<property name="dist"  location="dist"/>
<property name="lib"  location="lib"/>
<property name="web.dir"  location="WebContent"/>

<path id="class.path">
  <pathelement path="${classpath}"/>
  <fileset dir="lib">
    <include name="**/*.jar"/>
  </fileset>
</path>

<javac srcdir="${src}"
    destdir="${build}"
    classpathref="class.path"/>

<target name="init">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>
</target>

<target name="compile" depends="init"
    description="compile the source " >
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}"/>
</target>

<target name="dist" depends="compile"
    description="generate the distribution" >
<!-- Create the distribution directory -->
<mkdir dir="${dist}/lib"/>  
<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
<jar jarfile="${dist}/PROJECT-${DSTAMP}.jar" basedir="${build}"/> 
</target>

<target name="build-war">
<war destfile="${dist}/ROOT.war" webxml="${web.dir}/WEB-INF/web.xml">
<fileset dir="${web.dir}">
  <include name="**/*.*"/>
</fileset>
<lib dir="${lib}">
</lib>
<classes dir="${build}"/>
</war>
</target>

<target name="clean"
    description="clean up" >
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}"/>
<delete dir="${dist}"/>
</target>

</project>

Ant command that's run:

ant build-war

I probably have a lot of things in my build.xml that are irrelevant, I'm still trying to learn my way around Ant.

Could anyone please shed a light on my problem?


Solution

  • It means that the native jnetpcap shared library is not found. jnetpcap is a Java wrapper for the native libpcap library. Having the "libpcap" library or WinPcap on windows systems installed is a prerequisite for installing jnetpcap.
    The library is supplied with jNetPcap. You need to ensure that you correctly define on each particular system, the folder or directory where the library is located. For detailed information about solving the issue please refer to the jnetpcap FAQ.