hello users,

my first experience in ws was axis2c 3 month ago.
when i noticed that axis2c has no client session,
i decided to take axis2java, cause i don#T want
to implement on my own.

my service has to communicate with some
hardwaredevices. i build an jni wrapper
dll to talk to that devices - this works
fine. but when i try to load the libary
in the skeleton i run into trouble.

i have searched the user- and developer-list,
saw that i am not the only onw that runs
into trouble with jni,
but didn't find a proper answer.

so my question is, has anyone of you
did this succefully ?

my enviroment :
winXP
java 1.6

what i did :

1. write a simple service with a method that
adds 2 int's (adb-codegen) - works fine

2. write a jni-dll with the same method and
test it standalone - works fine

3. try to integrate :
place the native method in the skeleton,

public native int addieren(int a, int b);

generate with javah -jni the header-file,

JNIEXPORT jint JNICALL Java_org_apache_ws_axis2_Jni_1serviceSkeleton_addieren
  (JNIEnv *, jclass, jint, jint);

implement method and build the jni-dll,

JNIEXPORT jint JNICALL JNICALL Java_org_apache_ws_axis2_Jni_1serviceSkeleton_addieren(JNIEnv *env, jobject obj, jint a, jint b) {
        return (a + b);
}

declare static construct in skeleton,

static {
  try {
    System.load("<path>\\jni_simple_native.dll");
    //System.loadLibrary("jni_simple_native.dll");
  } catch(Exception e) {
    e.printStackTrace();
  }
}

when i use "System.loadLibrary" the dll could not be found,
i searched the web and checked my Windows PATH variable,
placed the dll in different folders like c:\windows\system32,
but same result.

when i use "System.load" the dll was found, but it seems
that the native method could not perform correctly

here is my implementation :

public org.apache.ws.axis2.AddierenResponse
    addieren(org.apache.ws.axis2.Addieren addieren) {

  AddierenResponse response = new AddierenResponse();
  int a = addieren.getParam0();
  int b = addieren.getParam1();

  System.out.println("--- server before --------");

  int c = addieren(a,b);

  System.out.println("--- server after --------");
  System.out.println("c : " + c);

  response.set_return(c);
  return response;
}

with "System.load" the server prints out the line
before the native method call and sents back an
Fault :
org.apache.ws.axis2.Jni_serviceSkeleton.addieren(II)I

i do not know how to handle this,
any help would be appreciated.

mfg derMark








---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

  • JNI Mark Nüßler

Reply via email to