Solved

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

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

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sleep laptop 20 70
Identify two keyboard codes and how to enter them 9 53
Windows Restrict installation 11 38
Changing the Users Path and User Name in Windows 10 Home 4 30
Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.

808 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