While calling c methods from servlets where should I place the .c and .dll in apache tomcat directory stucture?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   anshuma_patni
Posted On:   Sunday, February 15, 2004 04:58 AM

I am using servlet to call c methods that will ultimately use VC++ inbuilt functions to communicate with parallel port. I am working in Windows 98 platform and using Apache Tomcat1.4.18 web server for servlet and JNI communication. At present whenever I run my servlet I encounter an internal error showing the root cause as java.lang.NoClassDefFoungException . My problem is that where should I place my .c,.h files and the dll file formed in the directory structure of tomcat. Currently I am placing them including the .class file in C:Program FilesApacheTomcat1.4.18webappsexamplesWEB-INFclasses directory. Please suggest me the solution to solve my problem so that   More>>


I am using servlet to call c methods that will ultimately use VC++ inbuilt functions to communicate with parallel port.

I am working in Windows 98 platform and using Apache Tomcat1.4.18 web server for servlet and JNI communication.

At present whenever I run my servlet I encounter an internal error showing the root cause as java.lang.NoClassDefFoungException .


My problem is that where should I place my .c,.h files and the dll file formed in the directory structure of tomcat.


Currently I am placing them including the .class file in C:Program FilesApacheTomcat1.4.18webappsexamplesWEB-INFclasses directory.


Please suggest me the solution to solve my problem so that I can successfully run the C methods from Java Servlets.

   <<Less

Re: While calling c methods from servlets where should I place the .c and .dll in apache tomcat directory stucture?

Posted By:   Terry_Laurenzo  
Posted On:   Sunday, February 15, 2004 08:46 AM

Your .c and .h files are not necessary in a runtime environment. Your dll should go in the $TOMCAT_HOME/bin directory or anywhere that is accessible on the effective path when tomcat starts.


The class files with "native" declarations can go into your WEB-INF/classes directory but you will run into problems with servlet class reloading (JNI libraries can only be loaded once in a JVM). I would recommend putting the generated files into a jar and placing that in $TOMCAT_HOME/shared/lib. Jars in this directory exist in a class loader one step removed from all web app classloaders, and are available to all webapps. More importantly, they are only loaded once by tomcat. Make sure you have added a "static" declaration (or some other mechanism) to call System.loadLibrary("MyDllName_Without_The_Dll_Extension"); prior to making any calls on the classes with "native" methods.
About | Sitemap | Contact