Showing posts with label tomcat. Show all posts
Showing posts with label tomcat. Show all posts

How to resolve UnresolvedExternal exceptions while deploying jni apps in Tomcat

Cause:
UnresolvedExternal errors are caused in JNI applications when the class files tries to reference a native method in a shared object or dll and is unable to find the dll.

Solution:
  • Find out Tomcat's current java.library.path
  • Copy your application dlls to this path
  • The jars would remain within the application's war file
  • The dlls need not be along with the application jars

What is tcnative.dll in Tomcat?

The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.16\lib;
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.core.AprLifecycleListener.init(AprLifecycleListener.java:135)
at org.apache.catalina.core.AprLifecycleListener.lifecycleEvent(AprLifecycleListener.java:80)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.StandardServer.initialize(StandardServer.java:770)
at org.apache.catalina.startup.Catalina.load(Catalina.java:530)
at org.apache.catalina.startup.Catalina.load(Catalina.java:550)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:260)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:412)
Caused by: java.lang.UnsatisfiedLinkError: no tcnative-1 in java.library.path, no libtcnative-1 in java.library.path(C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.16\lib;)

Cause:
You get this message when you start Tomcat. Tomcat is looking for a shared object call tcnative (dll or so depending on the platform). If it doesn't find it, it'll revert to java libs. Either way, this shouldn't affect your application. tcnative dll is needed to address scalability in Tomcat.

Solution:
  1. Turn down debugging level for Tomcat or
  2. Get tcnative from http://tomcat.apache.org/native-doc/ (windows users can download the binary) and place it in your library path.
  3. Lib path is usually: C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.16\lib; for windows

Exception loading sessions from persistent storage java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException

IOException while loading persisted sessions: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException:com.test java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.test

SEVERE: Exception loading sessions from persistent storage
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.test

Cause:

You get this error on restarting tomcat. This is caused by classes that are not serializable. Tomcat tries to serialize objects on shutdown and deserialize on a restart.

Solution:

Make your classes serializable or

Turn off this feature in Tomcat by adding this in your webapp's context.xml

<Manager pathname=""></Manager>