Solved

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

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article summaries thoughts and ideas from two years of sustained use. It provides good reasoning to make the jump to Windows 10.
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…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

726 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