• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Need help for JSP to call C API using JNI

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi..

Sorry, not sure if this the right forum to post this question..

I need to use C API in my JSP. I have a class file which define all the native method and load the C API in public class MyClass like this:-

public native static byte[] myMethod();

static
{
System.loadLibrary("mycompanycapi");
}

I had compiled this class and the .h file and put it in my webapps/ROOT/WEB-INF/classes/com/mycompany folder under tomcat.

The libmycompanycapi.so I put it under /lib and I call this class in jsp like this:-

<jsp:useBean id="MyClass" class="MyClass" scope="request">
</jsp:useBean>

But, when the jsp give me the following error:-

exception

org.apache.jasper.JasperException: Unable to load class for JSP
org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:591)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:137)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause

java.lang.ClassNotFoundException: org.apache.jsp.test_005fbank_jsp
java.net.URLClassLoader$1.run(URLClassLoader.java:199)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(URLClassLoader.java:187)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:158)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:71)
org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:589)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:137)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

Can anyone help and advise what is the possible problem to this? Thanks.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And the JSP works if you remove the call to the bean?
 
Bill Ngu
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Basically, if I remove the call to the useBean it mean I have to remove all the call to API.

Yup, my jsp work without JNI calling. I had tested with normal useBean, it working too.. so I suppose it is the JNI call that I am having problem.

Can you point me to a step by step guide on how to use an C API in JSP for Tomcat? Thanks
 
Space seems cool in the movies, but once you get out there, it is super boring. Now for a fascinating tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic