| Author |
Need help for JSP to call C API using JNI
|
Bill Ngu
Greenhorn
Joined: Oct 14, 2002
Posts: 16
|
|
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.
|
- Bill -
|
 |
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
|
|
|
And the JSP works if you remove the call to the bean?
|
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
|
 |
Bill Ngu
Greenhorn
Joined: Oct 14, 2002
Posts: 16
|
|
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
|
 |
 |
|
|
subject: Need help for JSP to call C API using JNI
|
|
|