Solved

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

Posted on 2014-02-24
4
1,540 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
  • 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Join & Write a Comment

Suggested Solutions

Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup". After a while, you have entered a loop for Auto repair which does not fix anything and you will be in a  panic as all your work w…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now