Solved

java.lang.UnsatisfiedLinkError: for native method called on JSP in Tomcat

Posted on 2014-02-24
4
1,653 Views
Last Modified: 2014-03-12
I have a native method that works fine in java application. However when the method is accessed via JSP it gives UnsatisfiedLinkError errors. The dll is in tomcat + tomcat/bin  + tomcat/lib folders all the places.

The Library loads fine on JSP but on calling the native method it gives "java.lang.UnsatisfiedLinkError:"  

JSP Code-
<%!  public static native String stringMethod(String text); %>

<% System.loadLibrary("dll_name");
out.print(stringMethod("JGD"));
out.flush();
%>

Open in new window


exception

org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.UnsatisfiedLinkError: org.apache.jsp.index_jsp.stringMethod(Ljava/lang/String;)Ljava/lang/String;
	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:534)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:442)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause

javax.servlet.ServletException: java.lang.UnsatisfiedLinkError: org.apache.jsp.index_jsp.stringMethod(Ljava/lang/String;)Ljava/lang/String;
	org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:911)
	org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:840)
	org.apache.jsp.index_jsp._jspService(index_jsp.java:141)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause

java.lang.UnsatisfiedLinkError: org.apache.jsp.index_jsp.stringMethod(Ljava/lang/String;)Ljava/lang/String;
	org.apache.jsp.index_jsp.stringMethod(Native Method)
	org.apache.jsp.index_jsp._jspService(index_jsp.java:94)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

Open in new window

ServerLogs.txt
0
Comment
Question by:jgdvishnu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 20

Assisted Solution

by:chaitu chaitu
chaitu chaitu earned 500 total points
ID: 39884779
when the  jars are conflicted then you get this erorr.check in the classpath and see this method stringMethod coming from two jars.remove the jars one by one and debug the issue
0
 

Assisted Solution

by:jgdvishnu
jgdvishnu earned 0 total points
ID: 39884939
Thanks chaituu,

The native method that is throwing error is stored in a dll (not JAR) and to me it seems that there is no conflict at the moment .  I cleaned up and the dll is only at the "WEB-INF/lib" folder and it is nowhere in the classpath now. the WEB-INF/lib folder is loaded with the war.

should the dll  be wrapped in a jar file?
How could we debug the native method? the control goes up to the starting of the method and vanishes.

I am also not sure why the root cause is printed twice.


root cause

javax.servlet.ServletException: java.lang.UnsatisfiedLinkError: org.apache.jsp.index_jsp.stringMethod(Ljava/lang/String;)Ljava/lang/String;
	org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:911)
	org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:840)
	org.apache.jsp.index_jsp._jspService(index_jsp.java:141)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause

java.lang.UnsatisfiedLinkError: org.apache.jsp.index_jsp.stringMethod(Ljava/lang/String;)Ljava/lang/String;
	org.apache.jsp.index_jsp.stringMethod(Native Method)
	org.apache.jsp.index_jsp._jspService(index_jsp.java:94)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

Open in new window

index-jsp.java
0
 

Accepted Solution

by:
jgdvishnu earned 0 total points
ID: 39905711
The work around was import the class and call the function to get the required data. The JSP will not work as declaring in the JSP method gets overwritten on deployment.
0
 

Author Closing Comment

by:jgdvishnu
ID: 39922892
it was tried and tested
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
A small collection of useful tips and tricks for Windows 10 users that I decided to write as a result of recent questions that were asked and answered at Experts Exchange. Two short video tutorials included. Enjoy..
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question