[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2014-02-24
4
Medium Priority
?
1,741 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 1500 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

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

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..
Windows 10 Creator Update has just been released and I have it working very well on my laptop. Read below for issues, fixes and ideas.
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…
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…

656 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