I´ve call a native method without any parameters and it keep on failing...
Is there any 'rule' to put my JAVA classes and libraries in the Jakarta
directory tree?? I have my servlet class under
$CATALINA_HOME/webapps/myapplication/WEB-INF/classes/myservlet.class and
several classes in 2 packages under
$CATALINA_HOME/webapps/myapplication/WEB-INF/classes/mypackage1 and
$CATALINA_HOME/webapps/myapplication/WEB-INF/classes/mypackage2.
Libreria.java is under mypackage1, so I´ve also try to change the .h header
to:

JNIEXPORT void JNICALL Java_mypackage1_Libreria_JAdd....

and again the same....

Thanks for your help

-----Mensaje original-----
De: Manish Bhatnagar [mailto:[EMAIL PROTECTED]]
Enviado el: viernes, 15 de febrero de 2002 11:55
Para: Tomcat Users List
Asunto: RE: Problem with JNI, Tomcat 4.0.1 and FreeBSD


That seems to be ok. Are you sure you can pass "null" as a parameter? I
don't see any other reason. Everything seems to be fine.

-----Original Message-----
From: Mario Fernandez [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 15, 2002 4:22 PM
To: 'Tomcat Users List'
Subject: RE: Problem with JNI, Tomcat 4.0.1 and FreeBSD


It fails again... May the way I compile the C file be the error cause?? I
compile it like this:

# gcc -Wall -c mylib.c -I/usr/local/jdk1.2.2/include
-I/usr/local/jdk1.2.2/include/freebsd
# ld -shared -fPIC -o libmylib.so mylib.o

-----Mensaje original-----
De: Manish Bhatnagar [mailto:[EMAIL PROTECTED]]
Enviado el: viernes, 15 de febrero de 2002 11:33
Para: Tomcat Users List
Asunto: RE: Problem with JNI, Tomcat 4.0.1 and FreeBSD


Okay... do this:
replace #include <jni.h> with "#include "jni.h". Does it work?

-----Original Message-----
From: Mario Fernandez [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 15, 2002 4:05 PM
To: '[EMAIL PROTECTED]'
Subject: RV: Problem with JNI, Tomcat 4.0.1 and FreeBSD


I´ve tried with a function that only makes a return(); and it keeps on
crashing... I think the failure is not in JNI code, because it works with
Apache + Jserv, so that´s why I´m getting mad about this failure. The .h
file is like this:


/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class Libreria */

#ifndef _Included_Libreria
#define _Included_Libreria
#ifdef __cplusplus
extern "C" {
#endif
/*
 * Class:     Libreria
 * Method:    JAdd
 * Signature: (Lipfw/Regla;)V
 */
JNIEXPORT void JNICALL Java_Libreria_JAdd
  (JNIEnv *, jobject, jobject);

/*
 * Class:     Libreria
 * Method:    JInterfaces
 * Signature: ()Ljava/util/Vector;
 */
JNIEXPORT jobject JNICALL Java_Libreria_JInterfaces
  (JNIEnv *, jobject);

/*
 * Class:     Libreria
 * Method:    JListar
 * Signature: ([Ljava/lang/String;I)Ljava/util/Vector;
 */
JNIEXPORT jobject JNICALL Java_Libreria_JListar
  (JNIEnv *, jobject, jobjectArray, jint);

/*
 * Class:     Libreria
 * Method:    JResolver
 * Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
 */
JNIEXPORT jstring JNICALL Java_Libreria_JResolver
  (JNIEnv *, jobject, jstring, jstring);

#ifdef __cplusplus
}
#endif
#endif



-----Mensaje original-----
De: Manish Bhatnagar [mailto:[EMAIL PROTECTED]]
Enviado el: Friday, February 15, 2002 10:58 AM
Para: Tomcat Users List
Asunto: RE: Problem with JNI, Tomcat 4.0.1 and FreeBSD


I guess that is the message displayed when JNI performs some illegal
operation. I suggest you to check your JNI code. The best thing would be to
put *AfxMessageBox*es at different places. One more thing... have you
generated the .h file?
-mb-

-----Original Message-----
From: Mario Fernandez [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 15, 2002 3:33 PM
To: 'Tomcat Users List'
Subject: RE: Problem with JNI, Tomcat 4.0.1 and FreeBSD


Not exactly... the browser get stuck for some minutes, as if it was trying
to access the library methods; but when it finish, the error is: The page
cannot be displayed. I think this is because Tomcat is crashing, but I don´t
know why.

-----Mensaje original-----
De: Manish Bhatnagar [mailto:[EMAIL PROTECTED]]
Enviado el: Friday, February 15, 2002 10:45 AM
Para: Tomcat Users List
Asunto: RE: Problem with JNI, Tomcat 4.0.1 and FreeBSD


We have NOT made any changes to jni wrokers. What is the error that is being
displayed? Is it 500 Internal Server Error?

-----Original Message-----
From: Mario Fernandez [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 15, 2002 2:02 PM
To: 'Tomcat Users List'
Subject: RE: Problem with JNI, Tomcat 4.0.1 and FreeBSD


I´ve my library there, in $CATALINA_HOME\lib, and there´s mo way to make it
works... The System.loadLibrary() call works fine, but the problem is when I
call some native method. I´ve reading some responses in the mailing list
talking about jni workers or something like this, but always with Tomcat
3.2.3. In Tomcat 4.0.1, should I do something special in any configuration
file??

-----Mensaje original-----
De: Manish Bhatnagar [mailto:[EMAIL PROTECTED]]
Enviado el: Friday, February 15, 2002 5:29 AM
Para: Tomcat Users List
Asunto: RE: Problem with JNI, Tomcat 4.0.1 and FreeBSD


Where are you putting your mylib.so library? It should be in
$CATALINA_HOME\lib.

-----Original Message-----
From: Mario Fernandez [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 15, 2002 1:40 AM
To: [EMAIL PROTECTED]
Subject: Problem with JNI, Tomcat 4.0.1 and FreeBSD



> Hi everybody,
> 
> I´ve got an annoying error working with JNI and Tomcat 4.0.1 in a FreeBSD
> machine. I call a native method from a servlet and it doesn´t work. I get
> a core dumped... What do I have to do to make it works in Tomcat 4.0.1???
> My classes an native code are below:
> Is it necessary to do something in Tomcat to work with JNI??
> 
> From the servlet i make the following call:
> 
> ....
> 
> Library.list(null, 0);
> 
> ....
> 
> My class Library is like this:
> 
> public class Library{
> 
> static {
> 
> System.loadLibrary("mylib"); // The sahred library is called libmylib.so
> and this works fine
> }
> 
> public native static void list(String name, int num);
> 
> }
> 
> 
> The function header in Library.h (generated by javah -jni Library) is:
> 
> JNIEXPORT void JNICALL_Library_list(JNIEnv *,jobject,jobject,jint);
> 
> And I use this header in mylib.c
> 
> Thanks in advance
> 
> 

Reply via email to