The APR based Apache Tomcat Native library was not found on the java.library.path
Solution 1
not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
The native lib is expected in one of the following locations
/usr/java/packages/lib/amd64
/usr/lib64
/lib64
/lib
/usr/lib
and not in
tomcat/lib
The files in tomcat/lib
are all jar
file and are added by tomcat to the classpath
so that they are available to your application.
The native lib is needed by tomcat to perform better on the platform it is installed on and thus cannot be a jar
, for linux it could be a .so
file, for windows it could be a .dll
file.
Just download the native library for your platform and place it in the one of the locations tomcat is expecting it to be.
Note that you are not required to have this lib for development/test purposes. Tomcat runs just fine without it.
org.apache.catalina.startup.Catalina start INFO: Server startup in 2882 ms
EDIT
The output you are getting is very normal, it's just some logging outputs from tomcat, the line right above indicates that the server correctly started and is ready for operating.
If you are troubling with running your servlet then after the run on sever
command eclipse opens a browser window (embeded (default) or external, depends on your config). If nothing shows on the browser, then check the url bar of the browser to see whether your servlet was requested or not.
It should be something like that
http://localhost:8080/<your-context-name>/<your-servlet-name>
EDIT 2
Try to call your servlet using the following url
http://localhost:8080/com.filecounter/FileCounter
Also each web project has a web.xml, you can find it in your project under WebContent\WEB-INF
.
It is better to configure your servlets there using servlet-name
servlet-class
and url-mapping
. It could look like that:
<servlet>
<description></description>
<display-name>File counter - My first servlet</display-name>
<servlet-name>file_counter</servlet-name>
<servlet-class>com.filecounter.FileCounter</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>file_counter</servlet-name>
<url-pattern>/FileFounter</url-pattern>
</servlet-mapping>
In eclipse dynamic web project the default context name is the same as your project name.
http://localhost:8080/<your-context-name>/FileCounter
will work too.
Solution 2
Regarding the original question asked in the title ...
sudo apt-get install libtcnative-1
or if you are on RHEL Linux
yum install tomcat-native
The documentation states you need http://tomcat.apache.org/native-doc/
sudo apt-get install libapr1.0-dev libssl-dev
- or RHEL
yum install apr-devel openssl-devel
catch23
Updated on May 16, 2020Comments
-
catch23 almost 4 years
I'm newly at server development and have been started from easy tutorial by Lars Vogel. Servlet and JSP development with Eclipse WTP .
Step by step accord this tutorial:
- installed Eclipse Java EE Kepler;
- installed tomcat 7 on Ubuntu 12.04 -
http://localhost:8080/
shows correct tomcat page; - Setting up tomcat runtime environments into eclipse;
- added tomcat server to eclipse;
- create
DAO
; - created the Servlet;
- run =>
And here I caught next prompt:
Sep 15, 2013 3:40:39 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: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib Sep 15, 2013 3:40:42 PM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:com.filecounter' did not find a matching property. Sep 15, 2013 3:40:43 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["http-bio-8080"] Sep 15, 2013 3:40:43 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["ajp-bio-8009"] Sep 15, 2013 3:40:43 PM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 5203 ms Sep 15, 2013 3:40:43 PM org.apache.catalina.core.StandardService startInternal INFO: Starting service Catalina Sep 15, 2013 3:40:43 PM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: Apache Tomcat/7.0.42 Sep 15, 2013 3:40:45 PM org.apache.catalina.util.SessionIdGenerator createSecureRandom INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [171] milliseconds. Sep 15, 2013 3:40:46 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["http-bio-8080"] Sep 15, 2013 3:40:46 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["ajp-bio-8009"] Sep 15, 2013 3:40:46 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 2882 ms
Here is content of
tomcat/lib
folder:nazar_art@nazar-desctop:/usr/local/tomcat/apache-tomcat-7.0.42/lib$ ls -lg total 6132 -rwxrwxrwx 1 nazar_art 15264 Jul 2 10:59 annotations-api.jar -rwxrwxrwx 1 nazar_art 54142 Jul 2 10:59 catalina-ant.jar -rwxrwxrwx 1 nazar_art 134215 Jul 2 10:59 catalina-ha.jar -rwxrwxrwx 1 nazar_art 1581311 Jul 2 10:59 catalina.jar -rwxrwxrwx 1 nazar_art 257520 Jul 2 10:59 catalina-tribes.jar -rwxrwxrwx 1 nazar_art 1801636 Jul 2 10:59 ecj-4.2.2.jar -rwxrwxrwx 1 nazar_art 46085 Jul 2 10:59 el-api.jar -rwxrwxrwx 1 nazar_art 123241 Jul 2 10:59 jasper-el.jar -rwxrwxrwx 1 nazar_art 599428 Jul 2 10:59 jasper.jar -rwxrwxrwx 1 nazar_art 88690 Jul 2 10:59 jsp-api.jar -rwxrwxrwx 1 nazar_art 177598 Jul 2 10:59 servlet-api.jar -rwxrwxrwx 1 nazar_art 6873 Jul 2 10:59 tomcat-api.jar -rwxrwxrwx 1 nazar_art 796527 Jul 2 10:59 tomcat-coyote.jar -rwxrwxrwx 1 nazar_art 235411 Jul 2 10:59 tomcat-dbcp.jar -rwxrwxrwx 1 nazar_art 77364 Jul 2 10:59 tomcat-i18n-es.jar -rwxrwxrwx 1 nazar_art 48693 Jul 2 10:59 tomcat-i18n-fr.jar -rwxrwxrwx 1 nazar_art 51678 Jul 2 10:59 tomcat-i18n-ja.jar -rwxrwxrwx 1 nazar_art 124006 Jul 2 10:59 tomcat-jdbc.jar -rwxrwxrwx 1 nazar_art 23201 Jul 2 10:59 tomcat-util.jar
Here is content of catalina.2013-09-15.log.
Update:
Here is tutorial:
Installing Apache Tomcat Native on Linux Ubuntu 12.04Update2:
Here is content of Data Access Object:
public class FileDao { public int getCount() { int count = 0; // Load the file with the counter FileReader fileReader = null; BufferedReader bufferedReader = null; PrintWriter writer = null ; try { File f = new File("FileCounter.initial"); if (!f.exists()) { f.createNewFile(); writer = new PrintWriter(new FileWriter(f)); writer.println(0); } if (writer !=null){ writer.close(); } fileReader = new FileReader(f); bufferedReader = new BufferedReader(fileReader); String initial = bufferedReader.readLine(); count = Integer.parseInt(initial); } catch (Exception ex) { if (writer !=null){ writer.close(); } } if (bufferedReader != null) { try { bufferedReader.close(); } catch (IOException e) { e.printStackTrace(); } } return count; } public void save(int count) throws Exception { FileWriter fileWriter = null; PrintWriter printWriter = null; fileWriter = new FileWriter("FileCounter.initial"); printWriter = new PrintWriter(fileWriter); printWriter.println(count); // Make sure to close the file if (printWriter != null) { printWriter.close(); } } }
And here Servlet code:
public class FileCounter extends HttpServlet { private static final long serialVersionUID = 1L; int count; private FileDao dao; public void init() throws ServletException { dao = new FileDao(); try { count = dao.getCount(); } catch (Exception e) { getServletContext().log("An exception occurred in FileCounter", e); throw new ServletException("An exception occurred in FileCounter" + e.getMessage()); } } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // Set a cookie for the user, so that the counter does not increate // every time the user press refresh HttpSession session = request.getSession(true); // Set the session valid for 5 secs session.setMaxInactiveInterval(5); response.setContentType("text/plain"); PrintWriter out = response.getWriter(); if (session.isNew()) { count++; } out.println("This site has been accessed " + count + " times."); } public void destroy() { super.destroy(); try { dao.save(count); } catch (Exception e) { e.printStackTrace(); } } }
I haven't had
web.xml
yet.How to solve this trouble?
-
catch23 over 10 yearsIn my location exist last three paths. I misunderstood how to exactly download this libs? Here is link for tomcat 7 - tomcat.apache.org/tomcat-7.0-doc/apr.html
-
A4L over 10 years@nazar_art follow the instructions in this page
-
A4L over 10 years@nazar_art which error? If it is
The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path
then follow the steps in the tutorial you found or in the link from the apache tomcat site. Or do you have another error? (The only 'error' - it's actually just a warning - I see is about ARP!) -
catch23 over 10 yearsI followed this tutorial but maybe have missed smt coz this warning is showed again. I couldn't understand the end of this tutorial
Now I have compiled Tomcat Native library in /usr/local/apr/libtcnative-1.so.0.1.27 and symbolic link file /usr/local/apr/@libtcnative-1.so pointed to the library 5. Create or edit the $CATALINA_HOME/bin/setenv.sh file with following lines : export LD_LIBRARY_PATH='$LD_LIBRARY_PATH:/usr/local/apr/lib'
-
A4L over 10 years@nazar_art, please see my edit! also just ignore the warning about ARP if you are just starting up with servlets and tomcat.
-
catch23 over 10 yearsExactly it shows me this page into eclipse (localhost:8080/com.filecounter) but shows
HTTP Status 404 - /com.filecounter/
too. At browser the same result. -
A4L over 10 years@nazar_art I cannot access your
localhost
, you only can ;-) please update your question and post the content of your web.xml file and the code of your servlet.