javatomcatdlljarwaffle

Could not extract dll file from jar file deployed in tomcat


I have developed a sample java web application with Waffle for SSO authentication. I am using Waffle 1.8 with Tomcat 8. I have it running and authenticating successfully in my dev environment (Java 1.8, Tomcat 8, Windows 2012 R2 server). But when i run the same application in prod environment(same as dev environment) it gives below error when trying to access the url:

SEVERE [http-nio-443-exec-7] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [Jersey REST Service] in context with path [/Auth-Test] threw exception [Filter execution threw an exception] with root cause java.lang.UnsatisfiedLinkError: Native library (com/sun/jna/win32-x86-64/jnidispatch.dll) not found in resource path ([file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%208.0/webapps/Auth-Test/WEB-INF/classes/, file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%208.0/webapps/Auth-Test/WEB-INF/lib/asm-3.1.jar, file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%208.0/webapps/Auth-Test/WEB-INF/lib/guava-18.0.jar, file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%208.0/webapps/Auth-Test/WEB-INF/lib/jersey-bundle-1.17.1.jar, file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%208.0/webapps/Auth-Test/WEB-INF/lib/jna-4.2.1.jar, file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%208.0/webapps/Auth-Test/WEB-INF/lib/jna-platform-4.2.1.jar, file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%208.0/webapps/Auth-Test/WEB-INF/lib/log4j-1.2.8.jar, file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%208.0/webapps/Auth-Test/WEB-INF/lib/slf4j-api-1.7.12.jar, file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%208.0/webapps/Auth-Test/WEB-INF/lib/waffle-jna-1.8.0.jar])at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:866).....

The dll file (com/sun/jna/win32-x86-64/jnidispatch.dll) is inside jna-4.2.1.jar and jna is supposed to extract this to Tomcat 8.0/temp folder. In my dev server a folder is created under temp folder and a couple of dll files are created inside this folder. Whereas in prod server an empty folder is created inside temp folder. As per my understanding jna could not extract the dll files from the jar to an external location. I also tried moving jna-4.2.1.jar and jna-platform-4.2.1.jar to from WEB-INF/lib/ to tomcat8/lib. Still no success.

I have also verified that the tomcat is running without a security manger to confirm the issue is not related to access permission.

Right now i am clueless as what to do. It would be a great help if a solution is provided or at least point me to a direction to troubleshoot the issue. Thanks in advance.


Solution

  • I have resolved the issue. The root cause for the issue was the jna jar file got corrupted while transferring the war file to prod server. I replaced the jna jar file in prod server with a fresh copy of jar file it got working.