Generating native code executable

I would like to generate an executable file of my Java application program to run on my PC. Is there a way to do this?
Thanks for your help,
Miguel

You can get a cross compiler that will take java code and give you an exe, there a several threads that talk about doing that.
If you just want to convenience of being able to double click and have it run, then you can make an executable jar file in java.

Similar Messages

  • Generate, compile, load, execute code on-the-fly

    Hi,
    I'd like to make something that:
    - 1) Generates Java source code (this I can do)
    - 2) Compiles this generated source code (I found an unsatisfying solution)
    - 3) Loads the newly created classes (I'm stuck here)
    - 4) Executes them in this very same program. (That should be trivial once the classes are loaded)
    The solution I found for 2) is to invoke the compiler through Runtime.exec(). Isn't there a more integrated solution ?
    And for 3), I think there is something to do with a ClassLoader or so, I'll try to figure it out on my own in the meantime.
    Thank you,
    The Ultimate Koala

    see maybe Jakarta BCEL on : http://jakarta.apache.org/bcel/index.html and : http://jakarta.apache.org/bcel/manual.html (Byte Code Engineering Library)

  • Java Runtime crash while executing native code.(version 1.6.0_10-beta)

    HI all
    i observed a crash while execution a native fuction , which is initializing an
    char array of size (1024*1024).Plz see the code snippet below:
    But it is working with java version: 1.5.0
    FileTest.c:
    #include<stdio.h>
    #include<fcntl.h>
    #include<string.h>
    #include<stdlib.h>
    #include "HelloWorld.h"
    JNIEXPORT jint JNICALL Java_HelloWorld_CreateLargestF<div style="direction: ltr">ile (JNIEnv * env, jclass obj)
    //int CreateLargestFile(char* filename)
    char *filename = "LargestFile.tmp";
    int fd = creat(filename, 0666);
    if(fd == -1)
    return 0;
    int size = 1024 * 1024;
    char buffer[size];
    //buffer is not filled fully, JRE aborts after i reaches to 61327 approx.
    int i;
    for( i = 0;i<size;i++)
    buffer[i] = 'a';
    printf("\n\n==>> Executing FSTLD0001 : buffer %d = %c \n",i,buffer);
    printf("\n\n==>> Executing FSTLD0001 : after init\n");
    //memset(buffer, 'a', size);
    while(1)
    long bytes = write(fd, buffer, size);
    if(bytes < size)
    break;
    close(fd);
    return 1;
    HelloWorld.java
    public class HelloWorld {
    public static native int CreateLargestFile();
    public static void main(String[] args)
    String dir = System.getProperty("user.dir");
    String libpath = dir + "/libFileTest.so";
    System.load(libpath);
    CreateLargestFile();
    jni.h version used is: 1.56 03/12/19
    jni_md.h version used is : 1.14 03/12/19
    FULL PRODUCT VERSION :
    java version "1.6.0_10-beta"
    Java(TM) SE Runtime Environment (build 1.6.0_10-beta-b14)
    Java HotSpot(TM) Client VM (11.0-b11 mixed mode, sharing)
    FULL OS VERSION :
    Linux debian 2.6.18-6-686 #1 SMP Sun Feb 10 22:11:31 UTC 2008 i686 GNU/Linux
    ERROR MESSAGES:
    # An unexpected error has been detected by Java Runtime Environment:
    # SIGSEGV (0xb) at pc=0xb7eec667, pid=7128, tid=3084340144
    # Java VM: Java HotSpot(TM) Client VM (11.0-b11 mixed mode, sharing linux-x86)
    # Problematic frame:
    # C [libFileTest.so+0x667] Java_HelloWorld_CreateLargestFile+0x8b
    <div style="direction: ltr">#
    # If you would like to submit a bug report, please visit:
    # [http://java.sun.com/webapps/bugreport/crash.jsp]
    # The crash happened outside the Java Virtual Machine in native code.
    # See problematic frame for where to report the bug.</div>
    May i have any feedbacks or help?
    Thanks
    </div>

    Stack size perhaps?
    Allocate the buffer off the heap instead of the stack.
    The following might be related (might not as well.)
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6227033
    There is a flag that adds info for jni via the command line turn it on.

  • GUI crashes when calling native code..

    Hi,
    I have interfaced to an existing C program using the Java Native Interface and I am controlling the C program using a GUI. The problem is that everytime I click on the button to call the native method, the GUI crashes... The bizarre thing is that the C code seems to actually execute properly and no exceptions are thrown..
    Anyone come across this problem?
    /john

    Hi,
    Thanks for the replies...
    The GUI completely disappears. No error file is generated. No exceptions are thrown. Here it is in more detail..
    The C code is invoked using the java native interface. The C code converts a MIDI file to a text file. It is normally run in DOS and accepts two parameters. You would run it in DOS normally as follows:
    mf2t Example1.mid Example1.txt.
    In the GUI I select the MIDI file and specify the output file (Example1.txt). I then pass these two parameters to the C code. The C code originally used argc and argv to accept the parameters. I replaced these with "fileArray" and "parameter"... "mf2t" replaces "main" in the native code...
    On the java side the code looks like this:
    static public native boolean mf2t(String s6, String s7);
    public String infile; // Input MIDI file
    public String textOut; // Output text file
    private void MIDIButtonActionPerformed(java.awt.event.ActionEvent evt) {
    Object target=evt.getSource();
    if(target == MIDIButton) {
    if(mf2t(infile,textOut)){
    InfoLabel.setText("MIDI to text conversion complete");
    The code is built on the C side into a DLL using MS Visual Studio.
    On the C side the code looks something like this:
    static char *fileArray[5];
    static int argument=3;
    static char midiArray[25];
    static char txtArray[25];
    void mf2t(int argument,char * fileArray[]);
    // Entry point to native C code is here
    JNIEXPORT jboolean JNICALL
    Java_MainWindow_mf2t (JNIEnv *env, jobject j1, jstring midi, jstring txt)
    const jbyte *midiFile;
    const jbyte *txtFile;
    midiFile=(*env)->GetStringUTFChars(env,midi, NULL);
    txtFile=(*env)->GetStringUTFChars(env,txt, NULL);
    // The lines above just convert the java string into a C equivalent..
    strcpy(midiArray,midiFile);
    strcpy(txtArray,txtFile);
    fileArray[0]="mf2t.exe"; // Here I get fileArray to point to the converted strings
    fileArray[1]=midiArray;
    fileArray[2]=txtArray;
    mf2t(argument,fileArray); // Then I pass this to a native method
    (*env)->ReleaseStringUTFChars(env,midi, midiFile);
    (*env)->ReleaseStringUTFChars(env,txt, txtFile);
    return 1;
    void mf2t(int argument,char * fileArray[]){
    // native code in here
    I think it may have something to do with threads.. I'm not sure though.. It's impossible to know whats going on in the C code when the GUI crashes. If anything looks strange it's because I left out some code here for the sake of brevity... Still if you see anything that stands out let me know..
    Thanks,
    John

  • How to run 64-bit native code with Java Web Start

    This question has probably been asked many times, but I couldn't find anything in my searches.
    How can I get Java Web Start on a Solaris client (Solaris 10 in this case, with JRE 1.5) to run a java application that includes a 64-bit native code library? The application downloads fine, including the jar file that has the native shared object, but when the native library is loaded by the java application, I get a "wrong ELF class: ELFCLASS64" error.
    I assume that is because Web Start is invoking the 32-bit java VM, which can't load a 64-bit library. I tried configuring Java Web Start to use the 64-bit VM (by setting the path to java to ".../jre/bin/sparcv9/java" in the javaws console) but then I get an error that says "Can't load library: .../jre/lib/sparcv9/libdeploy.so".
    Does Java Web Start support 64-bit native code, and if so, what do I need to do differently?
    Thanks.

    No it can't. On the Sun download page of the JRE it says that 64 Bit systems need to use the 32 Bit JRE to execute Plugins - this might be the same for Web Start apps.

  • The crash happened outside the java virtual machine in native code

    Hi,
    I have a biometric device with which I am given some C++ dlls. I am trying to call methods inside these using java (jna). I am loading the dll "zkemsdk.dll+" as follows:
    zkemkeeper INSTANCE1 = (zkemkeeper)Native.loadLibrary("zkemsdk", zkemkeeper.class);//zkemsdk is the dll, I am loading the dll here.
    Then, I am calling the function:
    zkemkeeper.INSTANCE1.Z_Connect_NETEX("ip address",4370);//Z_Connect_NETEX is a function inside zkemsdk.dll
    This returns me true or false based on whether am connected to the biometric device or not.Thus I am able to invoke this method without issues. But for other methods inside the dll, run time exception is thrown in console:
    Can someone help me resolve this issue. ??? Following is the content of the log file generated.
    # A fatal error has been detected by the Java Runtime Environment:
    # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0351fe3b, pid=1664, tid=3832
    # JRE version: 6.0_20-b02
    # Java VM: Java HotSpot(TM) Client VM (16.3-b01 mixed mode, sharing windows-x86 )
    # Problematic frame:
    # C [zkemsdk.dll+0xfe3b]
    # If you would like to submit a bug report, please visit:
    # http://www.java.net/external?url=http://java.sun.com/webapps/bugreport/crash.jsp
    # The crash happened outside the Java Virtual Machine in native code.
    # See problematic frame for where to report the bug.
    --------------- T H R E A D ---------------
    Current thread (0x003a9000): JavaThread "main" [_thread_in_native, id=3832, stack(0x008c0000,0x00910000)]
    siginfo: ExceptionCode=0xc0000005, reading address 0x00000106
    Registers:
    EAX=0x0090f7c4, EBX=0x00000001, ECX=0x00000000, EDX=0x00000001
    ESP=0x0090f7b4, EBP=0x0090f848, ESI=0x00000096, EDI=0x003a9000
    EIP=0x0351fe3b, EFLAGS=0x00010216
    Top of Stack: (sp=0x0090f7b4)
    0x0090f7b4: 00000000 0090f930 000003fc 00000103
    0x0090f7c4: 0090f800 6d9532d0 373e92a0 00912ec5
    0x0090f7d4: 00000401 0090f7d8 369860d1 0090f800
    0x0090f7e4: 37390050 00000000 37390f90 00000000
    0x0090f7f4: 0090f800 0090f930 003a9000 0090f830
    0x0090f804: 10008fd8 0090f840 0090f930 00000008
    0x0090f814: 0090f88c 0090fa28 0090f8f4 0090f848
    0x0090f824: eb53f637 0351ffdc 00000096 00000003
    Instructions: (pc=0x0351fe3b)
    0x0351fe2b: 0f 53 50 8d 44 24 18 50 e8 58 7c 00 00 83 c4 0c
    0x0351fe3b: 8b 4e 70 51 8b 0e 83 c3 04 53 6a 64 8d 54 24 18
    Stack: [0x008c0000,0x00910000], sp=0x0090f7b4, free space=13d0090f2e8k
    Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
    C [zkemsdk.dll+0xfe3b]
    C [jna5972695927945545932.tmp+0x9182]
    C [jna5972695927945545932.tmp+0x2161]
    C [jna5972695927945545932.tmp+0x2849]
    j com.sun.jna.Function.invokeInt(I[Ljava/lang/Object;)I+0
    j com.sun.jna.Function.invoke([Ljava/lang/Object;Ljava/lang/Class;)Ljava/lang/Object;+90
    j com.sun.jna.Function.invoke(Ljava/lang/Class;[Ljava/lang/Object;Ljava/util/Map;)Ljava/lang/Object;+194
    j com.sun.jna.Library$Handler.invoke(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;+344
    j $Proxy0.Z_Beep(J)Z+19
    j com.rfarrays.bhabs.fingerPrint.main([Ljava/lang/String;)V+84
    v ~StubRoutines::call_stub
    V [jvm.dll+0xf049c]
    V [jvm.dll+0x17fcf1]
    V [jvm.dll+0xf051d]
    V [jvm.dll+0xf9bc5]
    V [jvm.dll+0x10181d]
    C [javaw.exe+0x2155]
    C [javaw.exe+0x8614]
    C [kernel32.dll+0xb729]
    Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
    j com.sun.jna.Function.invokeInt(I[Ljava/lang/Object;)I+0
    j com.sun.jna.Function.invoke([Ljava/lang/Object;Ljava/lang/Class;)Ljava/lang/Object;+90
    j com.sun.jna.Function.invoke(Ljava/lang/Class;[Ljava/lang/Object;Ljava/util/Map;)Ljava/lang/Object;+194
    j com.sun.jna.Library$Handler.invoke(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;+344
    j $Proxy0.Z_Beep(J)Z+19
    j com.rfarrays.bhabs.fingerPrint.main([Ljava/lang/String;)V+84
    v ~StubRoutines::call_stub
    --------------- P R O C E S S ---------------
    Java Threads: ( => current thread )
    0x02b10c00 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=1976, stack(0x02dc0000,0x02e10000)]
    0x02b0a400 JavaThread "CompilerThread0" daemon [_thread_blocked, id=1280, stack(0x02d70000,0x02dc0000)]
    0x02b08c00 JavaThread "Attach Listener" daemon [_thread_blocked, id=1984, stack(0x02d20000,0x02d70000)]
    0x02b07800 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=2160, stack(0x02cd0000,0x02d20000)]
    0x02b02400 JavaThread "Finalizer" daemon [_thread_blocked, id=2052, stack(0x02c80000,0x02cd0000)]
    0x02afd800 JavaThread "Reference Handler" daemon [_thread_blocked, id=752, stack(0x02c30000,0x02c80000)]
    =>0x003a9000 JavaThread "main" [_thread_in_native, id=3832, stack(0x008c0000,0x00910000)]
    Other Threads:
    0x02afc400 VMThread [stack: 0x02be0000,0x02c30000] [id=1504]
    0x02b1b800 WatcherThread [stack: 0x02e10000,0x02e60000] [id=1980]
    VM state:not at safepoint (normal execution)
    VM Mutex/Monitor currently owned by a thread: None
    Heap
    def new generation total 4928K, used 2455K [0x22970000, 0x22ec0000, 0x27ec0000)
    eden space 4416K, 55% used [0x22970000, 0x22bd5db0, 0x22dc0000)
    from space 512K, 0% used [0x22dc0000, 0x22dc0000, 0x22e40000)
    to space 512K, 0% used [0x22e40000, 0x22e40000, 0x22ec0000)
    tenured generation total 10944K, used 0K [0x27ec0000, 0x28970000, 0x32970000)
    the space 10944K, 0% used [0x27ec0000, 0x27ec0000, 0x27ec0200, 0x28970000)
    compacting perm gen total 12288K, used 343K [0x32970000, 0x33570000, 0x36970000)
    the space 12288K, 2% used [0x32970000, 0x329c5f20, 0x329c6000, 0x33570000)
    ro space 10240K, 51% used [0x36970000, 0x36e9ae00, 0x36e9ae00, 0x37370000)
    rw space 12288K, 54% used [0x37370000, 0x37a072d8, 0x37a07400, 0x37f70000)
    Dynamic libraries:
    0x00400000 - 0x00424000 C:\Program Files\Java\jre6\bin\javaw.exe
    0x7c900000 - 0x7c9b2000 C:\WINDOWS\system32\ntdll.dll
    0x7c800000 - 0x7c8f6000 C:\WINDOWS\system32\kernel32.dll
    0x77dd0000 - 0x77e6b000 C:\WINDOWS\system32\ADVAPI32.dll
    0x77e70000 - 0x77f03000 C:\WINDOWS\system32\RPCRT4.dll
    0x77fe0000 - 0x77ff1000 C:\WINDOWS\system32\Secur32.dll
    0x7e410000 - 0x7e4a1000 C:\WINDOWS\system32\USER32.dll
    0x77f10000 - 0x77f59000 C:\WINDOWS\system32\GDI32.dll
    0x76390000 - 0x763ad000 C:\WINDOWS\system32\IMM32.DLL
    0x7c340000 - 0x7c396000 C:\Program Files\Java\jre6\bin\msvcr71.dll
    0x6d800000 - 0x6da97000 C:\Program Files\Java\jre6\bin\client\jvm.dll
    0x76b40000 - 0x76b6d000 C:\WINDOWS\system32\WINMM.dll
    0x6d7b0000 - 0x6d7bc000 C:\Program Files\Java\jre6\bin\verify.dll
    0x6d330000 - 0x6d34f000 C:\Program Files\Java\jre6\bin\java.dll
    0x6d290000 - 0x6d298000 C:\Program Files\Java\jre6\bin\hpi.dll
    0x76bf0000 - 0x76bfb000 C:\WINDOWS\system32\PSAPI.DLL
    0x6d7f0000 - 0x6d7ff000 C:\Program Files\Java\jre6\bin\zip.dll
    0x68000000 - 0x68036000 C:\WINDOWS\system32\rsaenh.dll
    0x77c10000 - 0x77c68000 C:\WINDOWS\system32\msvcrt.dll
    0x769c0000 - 0x76a74000 C:\WINDOWS\system32\USERENV.dll
    0x5b860000 - 0x5b8b5000 C:\WINDOWS\system32\netapi32.dll
    0x6d610000 - 0x6d623000 C:\Program Files\Java\jre6\bin\net.dll
    0x71ab0000 - 0x71ac7000 C:\WINDOWS\system32\WS2_32.dll
    0x71aa0000 - 0x71aa8000 C:\WINDOWS\system32\WS2HELP.dll
    0x71a50000 - 0x71a8f000 C:\WINDOWS\System32\mswsock.dll
    0x76f20000 - 0x76f47000 C:\WINDOWS\system32\DNSAPI.dll
    0x76d60000 - 0x76d79000 C:\WINDOWS\system32\iphlpapi.dll
    0x76fb0000 - 0x76fb8000 C:\WINDOWS\System32\winrnr.dll
    0x76f60000 - 0x76f8c000 C:\WINDOWS\system32\WLDAP32.dll
    0x76fc0000 - 0x76fc6000 C:\WINDOWS\system32\rasadhlp.dll
    0x10000000 - 0x10052000 C:\Documents and Settings\bkonwar\Local Settings\Temp\jna5972695927945545932.tmp
    0x03510000 - 0x03546000 C:\WINDOWS\system32\zkemsdk.dll
    0x03560000 - 0x03574000 C:\WINDOWS\system32\commpro.dll
    0x662b0000 - 0x66308000 C:\WINDOWS\system32\hnetcfg.dll
    0x71a90000 - 0x71a98000 C:\WINDOWS\System32\wshtcpip.dll
    VM Arguments:
    jvm_args: -Dfile.encoding=Cp1252
    java_command: com.xyz.bhabs.fingerPrint
    Launcher Type: SUN_STANDARD
    Environment Variables:
    PATH=C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:/Program Files/Java/jre6/lib/i386;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;;C:\Program Files\Java\jre1.6.0_07\bin;C:\Program Files\Android\android-sdk-windows\tools;C:\Program Files\TortoiseSVN\bin
    USERNAME=BKonwar
    OS=Windows_NT
    PROCESSOR_IDENTIFIER=x86 Family 6 Model 15 Stepping 13, GenuineIntel
    --------------- S Y S T E M ---------------
    OS: Windows XP Build 2600 Service Pack 3
    CPU:total 2 (2 cores per cpu, 1 threads per core) family 6 model 15 stepping 13, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3
    Memory: 4k page, physical 2085780k(1286036k free), swap 4024188k(3249652k free)
    vm_info: Java HotSpot(TM) Client VM (16.3-b01) for windows-x86 JRE (1.6.0_20-b02), built on Apr 12 2010 13:52:23 by "java_re" with MS VC++ 7.1 (VS2003)
    time: Wed May 25 10:02:24 2011
    elapsed time: 21 seconds
    Regards,
    Bhabs
    Edited by: 861222 on May 25, 2011 12:19 AM

    861222 wrote:
    # A fatal error has been detected by the Java Runtime Environment:
    # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0351fe3b, pid=1664, tid=3832Not much to tell here. This line here looks suspiciously like a null-pointer error happening in the native code. It is impossible to say how, where and why. Go back to your code and start debugging I'd say, see where invalid data can be passed to the native code.

  • Null pointer exception in native code

    Hi
    We are running JRockit 1.4.2 and we are having a lot of crashes recently. All of them have this error
    Error Message: Null pointer exception in native code
    Signal info : si_signo=11, si_code=1
    but the location of the crash differs. Our last one occured in java.util.Hashmap.get(). Another common element is that they appear to occur after deserialisation.
    Has anyone else had similar problems?
    Any help much appreciated.
    Thanks,
    Dave
    Thread Stack Trace:
    at java/util/HashMap.get(Optimized Method)@0x1c9b350
    at java/io/ObjectStreamClass.lookup(Optimized Method)@0x7e6fbde
    at java/io/ObjectStreamClass.initProxy(Unknown Source)@0x5feef04
    at java/io/ObjectInputStream.readProxyDesc(Optimized Method)@0xaa7b0ec
    at java/io/ObjectInputStream.readObject(Optimized Method)@0xa7bee63
    at java/rmi/MarshalledObject.get(Optimized Method)@0xbfe238c
    at org/jnp/interfaces/MarshalledValuePair.get(MarshalledValuePair.java:28)@0x263b571
    at org/jnp/interfaces/NamingContext.lookup(Optimized Method)@0xb08cfe1
    at org/jnp/interfaces/NamingContext.lookup(Optimized Method)@0xbf57275

    Thanks for the reply.
    The version is
    BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-29212-20040415-1332-linux-ia32, Native Threads, GC strategy: parallel)
    I have opened a support case but here is the contents of the dump file. Thanks again for any help.
    ===== BEGIN DUMP =============================================================
    JRockit dump produced after 2 days, 03:50:51 on Tue Jan 18 22:27:28 2005
    Additional information is available in:
    /home/ebask11/rel_15_59912-jb-3.2.3-2.19/bin/jrockit.26704.dump
    /home/ebask11/rel_15_59912-jb-3.2.3-2.19/bin/core
    Please send the file(s), information about your system
    setup and the program you were running to [email protected]. Thank you.
    Error Message: Null pointer exception in native code
    Signal info : si_signo=11, si_code=1
    Version : BEA WebLogic JRockit(TM) 1.4.2_04 JVM ari-29212-20040415-1332-linux-ia32
    Threads / GC : Native Threads, GC strategy: parallel
    : mmHeap->data = 0x20000000, mmHeap->top = 0x40000000
    : mmStartCompaction = 0x20000000, mmEndCompaction = 0x22800000
    Number CPUs : 2
    Tot Phys Mem : 4107608064
    OS version : Red Hat Linux release 7.3 (Valhalla)
    Linux version 2.4.22ow1np-ht (root@devbgb0211) (gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-110)) #8 SMP Mon Oct 13 19:54:55 GMT 2003
    State : JVM is running
    Command Line : -Djava.class.path=. -Djava.security.manager=java.rmi.RMISecurityManager -Xmx512m -Xms512m -Djmx.host=prdlog2 -Duser.timezone=GMT -Dprogram.name=run.sh -Djava.class.path=/home/ebask11/live_jboss/server/default/syslib:/home/ebask11/live_jboss/server/default/syslib/jce.zip:/home/ebask11/live_jboss/bin/run.jar:/usr/java/bea/jdk/1.4.2/lib/tools.jar -Dsun.java.command=org.jboss.Main -c default
    Environment : JAVA_HOME=/usr/java/bea/jdk/1.4.2, java.home=/usr/java/bea/jdk/1.4.2/jre, java.class.path=/home/ebask11/live_jboss/server/default/syslib:/home/ebask11/live_jboss/server/default/syslib/jce.zip:/home/ebask11/live_jboss/bin/run.jar:/usr/java/bea/jdk/1.4.2/lib/tools.jar, java.library.path=/usr/java/bea/jdk/1.4.2/jre/lib/i386/jrockit:/usr/java/bea/jdk/1.4.2/jre/lib/i386:/usr/java/bea/jdk/1.4.2/jre/../lib/i386
    C Heap : Good; no memory allocations have failed
    Registers:
    EAX = 33115950 EBX = 25252a50
    ECX = 00000002 EDX = 200da968
    ESI = 21aba548 EDI = 21aba548
    ESP = 0ac20000 EIP = 00000000
    EBP = 21aba548 EFL = 00010206
    CS = 0023 DS = 002b ES = 002b
    SS = 002b FS = 0357 GS = 0357
    Stack:
    0ac20000 :01c9b350 200da968 200da970 200da930 200da920 07e6fbde
    0ac20018 :2233ff08 0adc6cb8 200da936 00000000 00000000 21aba548
    0ac20030 :00000000 25a3c710 24f42f30 200da920 05feef04 21aba548
    0ac20048 :00000000 200f35d8 0aa7b0ec 00000000 271a5318 00000000
    0ac20060 :00000010 00000000 24f19bc8 24f19590 271a5318 0adc6cb8
    0ac20078 :271a5368 245b2710 271a5318 00000001 00000000 200f35d8
    0ac20090 :24f42f30 00000000 21aba548 00000000 00000000 0adc6cb8
    0ac200a8 :0a7bee63 24f1a3b0 00000000 0aa8003e 24f19d78 245b2710
    0ac200c0 :24f1a3f0 0adc6cb8 0b0df368 00000001 24f19d10 ffffffff
    0ac200d8 :24f19cc8 24f19d10 0bfe238c 00000003 205e68f8 245b2710
    0ac200f0 :245b2710 245b26f8 245b1e70 00000000 0b08d69b 00000000
    0ac20108 :205e1590 245b1e70 24f14a70 24f14428 24f144e0 24f14740
    0ac20120 :0000000a 24f14428 0bf57275 00000003 0aa7712b 00000030
    0ac20138 :258174e0 0adc6cb8 00000000 24f13fe0 00000000 258339f8
    0ac20150 :87effc53 00000101 0378e84b 258174e0 0378e525 24f13fe0
    0ac20168 :2585f4e8 2585f4e8 0378e21d 2a280920 24f13fe0 00000001
    0ac20180 :24f128a8 00000000 00000000 2585f4e8 24ed15c8 0378db6f
    0ac20198 :24ed1598 24ed16a0 05ed9299 24ed1730 20085640 24ed15c8
    0ac201b0 :24eb9bc0 00000000 24ed1730 24e9c5a0 24ed15c8 00000000
    0ac201c8 :24eb9b80 391182e8 24e9c5b0 00000000 391182e8 08006231
    0ac201e0 :00000000 24e9c5a0 24e9c5b0 08005bea 00000000 24e9c5a0
    0ac201f8 :24e9c5b0 31a26218 24ec68e8 00000027 0adc6cb8 0000001d
    0ac20210 :00000000 24e9c5a0 24ec6848 27986b80 24e9c5a0 24e9c5b0
    0ac20228 :27968208 24e9c5a0 24e9c5a0 31a263b0 0800fe11 24e9c5b0
    0ac20240 :368dd1e0 24e9c5b0 24e9c5a0 00c448bc 04ab64f4 24e9c5b0
    0ac20258 :0470ae51 24e9c5b0 24ec62e8 ffffffff 24e9c5b0 368dd1e0
    0ac20270 :ffffffff 00000002 3196a2f8 24e9c5a0 24eb9440 0bd5d31a
    0ac20288 :24e9c5b0 24eb9440 0bfa0e4a 24e9c5b0 24e9c5a0 24e9c5b0
    0ac202a0 :03fb5c09 24e9c5b0 24ec6238 00000000 00000000 00000000
    0ac202b8 :00000000 22921d98 24ec6368 25a3c710 03fbdb83 24e9c5b0
    0ac202d0 :03fbdb67 24e9c5b0 0c9ff12c 0adc6cb8 27a28c98 042e5528
    0ac202e8 :00000000 24ec6368 24ec6368 0c0b7c86 24e9c5b0 03fbda44
    0ac20300 :24e9c5a0 24e9c5b0 24e9c5a0 24eb9440 24e9c5a0 24eb9440
    0ac20318 :04ab631e 24e9c5b0 24e9c5b0 368eb0c8 254cd0b0 24e9c5a0
    0ac20330 :24e9c5a0 24eb9440 0bfa0f23 24e9c5b0 24eb9440 24e9c5b0
    0ac20348 :0adc6d44 24e9c5b0 368eb0c8 368eb0c8 368eb0c8 368eb0c8
    0ac20360 :368eb0c8 22921d98 24eb9610 25a3c710 03fbdb83 24e9c5b0
    0ac20378 :03fbdb67 24e9c5b0 0c9ff12c 0adc6cb8 254c4c70 00000000
    0ac20390 :00000000 24eb9610 24eb9610 0c0b7c86 24e9c5b0 03fbda44
    0ac203a8 :24e9c5a0 24e9c5b0 24e9c5a0 24eb9440 00000000 00000001
    0ac203c0 :03fbcc0d 24e9c5b0 07fbaf2f 00000000 24eb9440 3196a3f8
    0ac203d8 :3196a070 24e9c5a0 00000000 24e9c5b0 368dd1e0 24e9c5b0
    0ac203f0 :24e44550 24798b78 00000101 87effc52 00000000 3196a268
    0ac20408 :07fbc349 24e44550 24eb9430 24eb9430 24e44550 02787424
    0ac20420 :24e44550 3196a070 24798b78 0bf9dde1 24e44550 03fbc71d
    0ac20438 :24e44550 24e44550 24e9c698 2f5c12c0 2f5c1cd8 00000004
    0ac20450 :2f5c14a8 07fbc349 24e44550 24e9cc48 00000000 2f5c1d38
    0ac20468 :03fbc428 24e44550 24798b78 24e9cc48 24e44550 00000004
    0ac20480 :2f5c14a8 07fbc371 24e44550 24e9cc48 00000004 09bc5570
    0ac20498 :03fb98ad 24e44550 200a4008 3419b0e0 00000000 24e9c698
    0ac204b0 :24798b78 24e44550 24798b78 24e44550 24e9cc48 319fd4e0
    0ac204c8 :00000004 2f5c14a8 07fbc371 24e44550 24e9cc48 24798b78
    0ac204e0 :24798b78 03fb8a7a 24e44550 3419f128 24e9cc48 24e44550
    0ac204f8 :00000004 2f5c14a8 07fbc371 24e44550 24e9cc48 31a34d88
    0ac20510 :00000101 03fb8934 24e44550 24798b78 87effc52 24e9cc48
    0ac20528 :00000004 2f5c14a8 07fbc371 24e44550 24e9cc48 24e9cc48
    0ac20540 :24e44550 02787424 24e44550 2f5c12c0 24e44550 0bf9dde1
    0ac20558 :24e44550 03fb8875 24e44550 24798b78 00000000 2f5c12c0
    0ac20570 :0bf23542 24e44550 0adc6cb8 22961f38 24798b78 24e9c5c8
    0ac20588 :25a3c710 25a3c710 22921d98 24e44550 00000004 229629e0
    0ac205a0 :07fbc349 24e44550 24e9c688 24798b78 24e44550 0bf2376a
    0ac205b8 :24e44550 00000000 229496f0 00000004 229629e0 07fbc371
    0ac205d0 :24e44550 24e9c688 24e44550 0280d39c 0278d370 24e44550
    0ac205e8 :00000040 24798b78 27f4b688 00000030 229490a0 00000004
    0ac20600 :229629e0 07fbc371 24e44550 24e9c688 3196a070 00000000
    0ac20618 :0bfa040d 24e44550 00000000 00000000 0ad52e9c 22965b90
    0ac20630 :24798b78 00000008 00000000 200c7480 00000000 000e3274
    0ac20648 :00000000 00000000 24798b78 24e44550 24e9c688 00000004
    0ac20660 :229629e0 07fbc371 24e44550 24e9c688 00000004 24e9c688
    0ac20678 :0bf9c372 24e44550 0adc6cb8 25a3c710 00000019 228a5da0
    0ac20690 :00000101 87effc52 01c9b3aa 7025a84b 229127d8 22911f18
    0ac206a8 :229127d8 0bf9e5eb 0adc6cb8 22965b90 24798b78 246934c8
    0ac206c0 :22962a40 24e44550 00000000 00000004 229629e0 07fbc371
    0ac206d8 :24e44550 24e9c688 24e9c688 24e44550 02787424 24e44550
    0ac206f0 :22961f38 0233875c 0bf9dde1 24e44550 02787686 24e44550
    0ac20708 :24798b78 24e44550 22917728 00000000 22912938 07fbc349
    0ac20720 :24e44550 24e9c590 24e9c590 24e44550 02787424 24e44550
    0ac20738 :247963d8 24798b78 0bf9dde1 24e44550 0275384d 24e44550
    0ac20750 :24791f18 24e44550 24e44550 2298ae60 24791348 24791f18
    0ac20768 :0000000a 247963d8 0bf987e2 24791f18 24798b60 0adc6cb8
    0ac20780 :24791348 247912c8 00000055 0adc6cb8 24791b38 24796468
    0ac20798 :247919e0 24791f18 24791348 22981450 24e11ad0 2298d1e0
    0ac207b0 :247912c8 247912c8 0adc6cb8 0bf993f2 24e11ad0 247912c8
    0ac207c8 :24e11b10 0000000d 07cbea65 00000000 0ad52e9c 25a3c710
    0ac207e0 :24e11ad0 247912c8 247912b0 22981450 41ed8d4e 00000002
    0ac207f8 :22981d60 25a3c710 25a3c6e8 22981450 02751c10 24e11ad0
    Code:
    Loaded modules:
    (* denotes the module causing the exception)
    0x08048000-0x0804cd66 /usr/java/bea/jdk/1.4.2/bin/java
    0x00127000-0x0013343a /lib/i686/libpthread.so.0
    0x0013c000-0x0015ca02 /lib/i686/libm.so.6
    0x0015e000-0x0015fbac /lib/libdl.so.2
    0x42000000-0x4212b962 /lib/i686/libc.so.6
    0x00161000-0x003293cf /usr/java/bea/jdk/1.4.2/jre/lib/i386/jrockit/libjvm.so
    0x003c7000-0x003cff0d /lib/libnss_files.so.2
    0x00c29000-0x00c29ffa /usr/lib/gconv/ISO8859-1.so
    0x00c2b000-0x00c3afa5 /usr/java/bea/jdk/1.4.2/jre/lib/i386/libverify.so
    0x01211000-0x012309cf /usr/java/bea/jdk/1.4.2/jre/lib/i386/libjava.so
    0x01233000-0x0124485a /lib/libnsl.so.1
    0x01505000-0x0150e012 /lib/libnss_nisplus.so.2
    0x01625000-0x01627c71 /lib/libnss_dns.so.2
    0x01b0e000-0x01b1b990 /lib/libresolv.so.2
    0x00ddc000-0x00ddc6e9 /usr/java/bea/jdk/1.4.2/jre/lib/i386/librmi.so
    0x0196e000-0x019715c1 /usr/java/bea/jdk/1.4.2/jre/lib/i386/libioser12.so
    Java Thread ID = 0x00003500, lastJavaFrame = (nil), Name = TP-Processor32
    Thread Stack Trace:
    at java/util/HashMap.get(Optimized Method)@0x1c9b350
    at java/io/ObjectStreamClass.lookup(Optimized Method)@0x7e6fbde
    at java/io/ObjectStreamClass.initProxy(Unknown Source)@0x5feef04
    at java/io/ObjectInputStream.readProxyDesc(Optimized Method)@0xaa7b0ec
    at java/io/ObjectInputStream.readObject(Optimized Method)@0xa7bee63
    at java/rmi/MarshalledObject.get(Optimized Method)@0xbfe238c
    at org/jnp/interfaces/MarshalledValuePair.get(MarshalledValuePair.java:28)@0x263b571
    at org/jnp/interfaces/NamingContext.lookup(Optimized Method)@0xb08cfe1
    at org/jnp/interfaces/NamingContext.lookup(Optimized Method)@0xbf57275
    at javax/naming/InitialContext.lookup(Optimized Method)@0xaa7712b
    at com/lastminute/ebasket/basket/JNDIHostedEJBObjectsFactory.lookupBasketHome(JNDIHostedEJBObjectsFactory.java:352)@0x378e84b
    at com/lastminute/ebasket/basket/JNDIHostedEJBObjectsFactory.findBasket(JNDIHostedEJBObjectsFactory.java:310)@0x378e21d
    at com/lastminute/ebasket/basket/JNDIHostedEJBObjectsFactory.findBasket(JNDIHostedEJBObjectsFactory.java:250)@0x378db6f
    at com/lastminute/ebasketx/ui/servlet/AddToBasketAction.perform(AddToBasketAction.java:101)@0x5ed9299
    at org/apache/struts/action/Action.execute(Optimized Method)@0x8006231
    at org/apache/struts/action/RequestProcessor.processActionPerform(RequestProcessor.java:484)@0x5ed8fe1
    at org/apache/struts/action/RequestProcessor.process(Optimized Method)@0x8004b71
    at org/apache/struts/action/ActionServlet.process(Optimized Method)@0x800fe11
    at org/apache/struts/action/ActionServlet.doGet(ActionServlet.java:507)@0x4ab64f4
    at javax/servlet/http/HttpServlet.service(HttpServlet.java:740)@0x470ae51
    at javax/servlet/http/HttpServlet.service(Optimized Method)@0xbd5d31a
    at org/apache/catalina/core/ApplicationFilterChain.internalDoFilter(Optimized Method)@0xbfa0e4a
    at org/apache/catalina/core/ApplicationFilterChain.access$000(ApplicationFilterChain.java:98)@0x3fbdb83
    at org/apache/catalina/core/ApplicationFilterChain$1.run(ApplicationFilterChain.java:176)@0x3fbdb67
    at jrockit/vm/AccessController.do_privileged_exc(Optimized Method)@0xc9ff12c
    at jrockit/vm/AccessController.doPrivileged(Optimized Method)@0xc0b7c86
    at org/apache/catalina/core/ApplicationFilterChain.doFilter(ApplicationFilterChain.java:172)@0x3fbda44
    at com/lastminute/ebasketx/ui/helper/SessionFilter.doFilter(SessionFilter.java:56)@0x4ab631e
    at org/apache/catalina/core/ApplicationFilterChain.internalDoFilter(Optimized Method)@0xbfa0f23
    at org/apache/catalina/core/ApplicationFilterChain.access$000(ApplicationFilterChain.java:98)@0x3fbdb83
    at org/apache/catalina/core/ApplicationFilterChain$1.run(ApplicationFilterChain.java:176)@0x3fbdb67
    at jrockit/vm/AccessController.do_privileged_exc(Optimized Method)@0xc9ff12c
    at jrockit/vm/AccessController.doPrivileged(Optimized Method)@0xc0b7c86
    at org/apache/catalina/core/ApplicationFilterChain.doFilter(ApplicationFilterChain.java:172)@0x3fbda44
    at org/apache/catalina/core/StandardWrapperValve.invoke(StandardWrapperValve.java:256)@0x3fbcc0d
    at org/apache/catalina/core/StandardPipeline$StandardPipelineValveContext.invokeNext(Optimized Method)@0x7fbc349
    at org/apache/catalina/core/StandardPipeline.invoke(StandardPipeline.java:480)@0x2787424
    at org/apache/catalina/core/ContainerBase.invoke(Optimized Method)@0xbf9dde1
    at org/apache/catalina/core/StandardContextValve.invoke(StandardContextValve.java:191)@0x3fbc71d
    at org/apache/catalina/core/StandardPipeline$StandardPipelineValveContext.invokeNext(Optimized Method)@0x7fbc349
    at org/jboss/web/tomcat/security/JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:220)@0x3fbc428
    at org/apache/catalina/core/StandardPipeline$StandardPipelineValveContext.invokeNext(Optimized Method)@0x7fbc371
    at org/apache/catalina/authenticator/AuthenticatorBase.invoke(AuthenticatorBase.java:494)@0x3fb98ad
    at org/apache/catalina/core/StandardPipeline$StandardPipelineValveContext.invokeNext(Optimized Method)@0x7fbc371
    at org/apache/catalina/valves/CertificatesValve.invoke(CertificatesValve.java:246)@0x3fb8a7a
    at org/apache/catalina/core/StandardPipeline$StandardPipelineValveContext.invokeNext(Optimized Method)@0x7fbc371
    at org/jboss/web/tomcat/tc4/statistics/ContainerStatsValve.invoke(ContainerStatsValve.java:76)@0x3fb8934
    at org/apache/catalina/core/StandardPipeline$StandardPipelineValveContext.invokeNext(Optimized Method)@0x7fbc371
    at org/apache/catalina/core/StandardPipeline.invoke(StandardPipeline.java:480)@0x2787424
    at org/apache/catalina/core/ContainerBase.invoke(Optimized Method)@0xbf9dde1
    at org/apache/catalina/core/StandardContext.invoke(StandardContext.java:2417)@0x3fb8875
    at org/apache/catalina/core/StandardHostValve.invoke(Optimized Method)@0xbf23542
    at org/apache/catalina/core/StandardPipeline$StandardPipelineValveContext.invokeNext(Optimized Method)@0x7fbc349
    at org/apache/catalina/valves/ErrorDispatcherValve.invoke(Optimized Method)@0xbf2376a
    at org/apache/catalina/core/StandardPipeline$StandardPipelineValveContext.invokeNext(Optimized Method)@0x7fbc371
    at org/apache/catalina/valves/ErrorReportValve.invoke(ErrorReportValve.java:172)@0x278d370
    at org/apache/catalina/core/StandardPipeline$StandardPipelineValveContext.invokeNext(Optimized Method)@0x7fbc371
    at org/jboss/web/tomcat/security/SecurityAssociationValve.invoke(Optimized Method)@0xbfa040d
    at org/apache/catalina/core/StandardPipeline$StandardPipelineValveContext.invokeNext(Optimized Method)@0x7fbc371
    at org/apache/catalina/valves/AccessLogValve.invoke(Optimized Method)@0xbf9c372
    at org/apache/catalina/core/StandardPipeline$StandardPipelineValveContext.invokeNext(Optimized Method)@0x7fbc371
    at org/apache/catalina/core/StandardPipeline.invoke(StandardPipeline.java:480)@0x2787424
    at org/apache/catalina/core/ContainerBase.invoke(Optimized Method)@0xbf9dde1
    at org/apache/catalina/core/StandardEngineValve.invoke(StandardEngineValve.java:174)@0x2787686
    at org/apache/catalina/core/StandardPipeline$StandardPipelineValveContext.invokeNext(Optimized Method)@0x7fbc349
    at org/apache/catalina/core/StandardPipeline.invoke(StandardPipeline.java:480)@0x2787424
    at org/apache/catalina/core/ContainerBase.invoke(Optimized Method)@0xbf9dde1
    at org/apache/coyote/tomcat4/CoyoteAdapter.service(CoyoteAdapter.java:197)@0x275384d
    at org/apache/jk/server/JkCoyoteHandler.invoke(Optimized Method)@0xbf987e2
    at org/apache/jk/common/HandlerRequest.invoke(Optimized Method)@0xbf993f2
    at org/apache/jk/common/ChannelSocket.invoke(ChannelSocket.java:673)@0x2751c10
    at org/apache/jk/common/ChannelSocket.processConnection(Optimized Method)@0x7fb5e35
    at org/apache/jk/common/SocketConnection.runIt(Optimized Method)@0xbf99f01
    at org/apache/tomcat/util/threads/ThreadPool$ControlRunnable.run(ThreadPool.java:677)@0x224f434
    at java/lang/Thread.run(Optimized Method)@0x7e7473a
    at java/lang/Thread.startThreadFromVM(Optimized Method)@0x1c9c0da
    --- End of stack trace
    Additional information is available in:
    /home/ebask11/rel_15_59912-jb-3.2.3-2.19/bin/jrockit.26704.dump
    /home/ebask11/rel_15_59912-jb-3.2.3-2.19/bin/core
    Please send the file(s), information about your system
    setup and the program you were running to [email protected]. Thank you.

  • [JNI Beginner] GC of Java arrays returned by the native code

    Hello all,
    I am beginning with JNI, to integrate a C library that pilots an industrial equipment, into a java UI. This library enables to exchange various proprietary PDUs (protocol data units), with the equipment, up and down (request/replies). Both requests and replies are arrays of bytes (+char*+).
    "Request" byte arrays are constructed by Java code, which passes them to the JNI code that glues with the lib. "Reply" byte arrays are returned to the Java code, which analyzes them.
    The "return reply" part is very similar to this [tutorial example|http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jniexamp.html] , which returns bytes read from a file. However there's something I don't understand with regard to garbage collection of the returned byte array:
    - in this stock example, the C code creates a Java byte array fills it, and simply returns it (example code stripped to highlight only the parts relevant to my question):
        jByteArray=(*env)->NewByteArray(env, size);
        (*env)->SetByteArrayRegion(env, jByteArray, 0, size, (jbyte *)sourceBytes);
        return (jByteArray);What will happen to this Java array (jByteArray) with regard to garbage collection?
    - if it's no more referenced (the example Java code just systemouts it and forgets it), will it be eligible to GC?
    - if it is referenced by a Java variable (in my case, I plan to keep a reference to several replies as the business logic requires to analyze several of them together), do regular Java language GC rules apply, and prevent eligibility of the array to GC as long as it's referenced?
    That may sound obvious, but what mixes me up is that the same tutorial describes memory issues in subsequent chapters: spécifically, the section on "passing arrays states that:
    [in the example] the array is returned to the calling Java language method, which in turn, garbage collects the reference to the array when it is no longer usedThis seems to answer "yes" to both my questions above :o) But it goes on:
    The array can be explicitly freed with the following call:
    {code} (*env)-> ReleaseByteArrayElements(env, jByteArray, (jbyte *)sourceBytes, 0);{code}Under what circumstances would one need to explicitly free jByteArray when it's about to be returned to the Java calling method? Or does this sentence apply to completely different situations (such as, when the array is +not+ returned as is to a Java method)?
    The tutorial's next section has a much-expected +memory issues+ paragraph, from which I quote:
    By default, JNI uses local references when creating objects inside a native method. This means when the method returns, the references are eligible to be garbage collected.I assume this means, +unless the references are assigned, in the Java code, to a Java variable+, right?
    If you want an object to persist across native method calls, use a global reference instead. A global reference is created from a local reference by calling NewGlobalReference on the the local reference.I assume this enables the C code to maintain a global reference to a java object even if it's not referenced anymore from the Java variables, right?
    I also checked the [JNI specification|http://download-llnw.oracle.com/javase/6/docs/technotes/guides/jni/spec/design.html#wp1242] , but this didn't clear the doubt completely:
    *Global and Local References*
    The JNI divides object references used by the native code into two categories: local and global references. Local references are valid for the duration of a native method call, and are automatically freed after the native method returns. Global references remain valid until they are explicitly freed.
    Objects are passed to native methods as local references. All Java objects returned by JNI functions are local references. The JNI allows the programmer to create global references from local references. JNI functions that expect Java objects accept both global and local references. A native method may return a local or global reference to the VM as its resultAgain I assume the intent is that Global references are meant for objects that have to survive across native calls, regardless of whether they are referenced by Java code. But what worries me is that combining both sentences end up in +All Java objects returned by JNI functions are local references (...) and are automatically freed after the native method returns.+.
    Could you clarify how to make sure that my Java byte arrays, be they allocated in C code, behave consistently with a Java array allocated in Java code (I'm familiar already with GC of "regular" Java objects)?
    Thanks in advance, and best regards,
    J.

    jduprez wrote:
    Hello all,
    I am beginning with JNI, to integrate a C library that pilots an industrial equipment, into a java UI. This library enables to exchange various proprietary PDUs (protocol data units), with the equipment, up and down (request/replies). Both requests and replies are arrays of bytes (+char*+).
    "Request" byte arrays are constructed by Java code, which passes them to the JNI code that glues with the lib. "Reply" byte arrays are returned to the Java code, which analyzes them.
    The "return reply" part is very similar to this [tutorial example|http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jniexamp.html] , which returns bytes read from a file. However there's something I don't understand with regard to garbage collection of the returned byte array:
    - in this stock example, the C code creates a Java byte array fills it, and simply returns it (example code stripped to highlight only the parts relevant to my question):
        jByteArray=(*env)->NewByteArray(env, size);
    (*env)->SetByteArrayRegion(env, jByteArray, 0, size, (jbyte *)sourceBytes);
    return (jByteArray);What will happen to this Java array (jByteArray) with regard to garbage collection?It will be collected when it is no longer referenced.
    The fact that you created it in jni doesn't change that.
    The array can be explicitly freed with the following call:
    (*env)-> ReleaseByteArrayElements(env, jByteArray, (jbyte *)sourceBytes, 0);Under what circumstances would one need to explicitly free jByteArray when it's about to be returned to the Java calling method? Or does this sentence apply to completely different situations (such as, when the array is not returned as is to a Java method)?
    Per what the tutorial says it is either poorly worded or just wrong.
    An array which has been properly initialized it a just a java object. Thus it can be freed like any other object.
    Per your original question that does not concern you because you return it.
    In terms of why you need to explicitly free local references.
    [http://download-llnw.oracle.com/javase/6/docs/technotes/guides/jni/spec/design.html#wp16785]
    The tutorial's next section has a much-expected memory issues paragraph, from which I quote:
    By default, JNI uses local references when creating objects inside a native method. This means when the method returns, the references are eligible to be garbage collected.I assume this means, unless the references are assigned, in the Java code, to a Java variable, right?As stated it is not precise.
    The created objects are tracked by the VM. When they are eligible to be collected they are.
    If you create a local reference and do NOTHING that creates an active reference elsewhere then when the executing thread returns to the VM then the local references are eligible to be collected.
    >
    If you want an object to persist across native method calls, use a global reference instead. A global reference is created from a local reference by calling NewGlobalReference on the the local reference.That is not precise. The scope is the executing thread. You can pass a local reference to another method without problem.
    I assume this enables the C code to maintain a global reference to a java object even if it's not referenced anymore from the Java variables, right?
    It enables access to it to be insured across multiple threads in terms of execution scope. Normally you should not use them.

  • JVM Crashes in Native Code - JDK#1.4.2_10 for solaris-sparc

    Hi,
    We are facing irregular but quite frequent JVM crash in our Test environment. From the stacktrace it seems that JVM is crashing inside the native code. Can anyone help me in finding the cause of this problem please?
    Please find below the dump generated after JVM crash -
    # An unexpected error has been detected by HotSpot Virtual Machine:
    # SIGBUS (0xa) at pc=0xfea32db4, pid=4695, tid=1
    # Java VM: Java HotSpot(TM) Client VM (1.4.2_10-b03 mixed mode)
    # Problematic frame:
    # C [libzip.so+0x2db4]
    --------------- T H R E A D ---------------
    Current thread (0x0003c2f0): JavaThread "main" [_thread_in_native, id=1]
    siginfo:si_signo=10, si_errno=151, si_code=3, si_addr=0xfe3a11cd
    Registers:
    O0=0xfe390000 O1=0x000111cc O2=0xffbfa350 O3=0x0003c4a0
    O4=0xff02aa10 O5=0xff008000 O6=0xffbfa1f0 O7=0xfea32d90
    G1=0x506f6c6c G2=0xff362a00 G3=0x0003c2f0 G4=0x00000066
    G5=0xf58d6cd8 G6=0x00000000 G7=0xff362a00 Y=0x00000000
    PC=0xfea32db4 nPC=0xfea32db8
    Top of Stack: (sp=0xffbfa1f0)
    0xffbfa1f0: 001de478 001deda8 fe3a11cc 00000000
    0xffbfa200: 00000000 fea40000 00000000 00000000
    0xffbfa210: 001de478 001deda8 0000506f 4f6d734e
    0xffbfa220: 80808080 01010101 ffbfa250 fea32ce0
    0xffbfa230: 00000000 2f3cbdc2 2f3cbdc2 f19cdfe8
    0xffbfa240: 0003c8b0 0003c8b0 ffbfa2b8 0000002b
    0xffbfa250: 001de478 ffbfa314 00000000 001deda8
    0xffbfa260: f206a1aa 00000043 0000ffff ff01f8a8
    Instructions: (pc=0xfea32db4)
    0xfea32da4: aa 02 40 0f d2 04 60 00 a4 02 00 09 a0 10 00 18
    0xfea32db4: d4 0c a0 01 95 2a a0 08 d0 0a 00 09 90 12 00 0a
    Stack: [0xffb7c000,0xffc00000), sp=0xffbfa1f0, free space=504k
    Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
    C [libzip.so+0x2db4]
    C [libzip.so+0x2ce8] ZIP_GetEntry+0xe0
    C [libzip.so+0x3488] Java_java_util_zip_ZipFile_getEntry+0x9c
    J java.util.zip.ZipFile.getEntry(JLjava/lang/String;)J
    J java.util.zip.ZipFile.getEntry(Ljava/lang/String;)Ljava/util/zip/ZipEntry;
    J java.util.jar.JarFile.getEntry(Ljava/lang/String;)Ljava/util/zip/ZipEntry;
    J sun.misc.URLClassPath$JarLoader.getResource(Ljava/lang/String;Z)Lsun/misc/Resource;
    J sun.misc.URLClassPath.getResource(Ljava/lang/String;Z)Lsun/misc/Resource;
    J java.net.URLClassLoader$1.run()Ljava/lang/Object;
    v ~StubRoutines::call_stub
    V [libjvm.so+0xc9ccc]
    V [libjvm.so+0xd6a34]
    C [libjava.so+0xdc38] Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedExceptionAction_2Ljava_secu
    rity_AccessControlContext_2+0x1c
    J java.security.AccessController.doPrivileged(Ljava/security/PrivilegedExceptionAction;Ljava/security/AccessControlContext;)L
    java/lang/Object;
    J java.net.URLClassLoader.findClass(Ljava/lang/String;)Ljava/lang/Class;
    J java.lang.ClassLoader.loadClass(Ljava/lang/String;Z)Ljava/lang/Class;
    J sun.misc.Launcher$AppClassLoader.loadClass(Ljava/lang/String;Z)Ljava/lang/Class;
    J java.lang.ClassLoader.loadClass(Ljava/lang/String;)Ljava/lang/Class;
    J java.lang.ClassLoader.loadClassInternal(Ljava/lang/String;)Ljava/lang/Class;
    v ~StubRoutines::call_stub
    V [libjvm.so+0xc9ccc]
    V [libjvm.so+0xd1cec]
    V [libjvm.so+0xf43a0]
    V [libjvm.so+0x9ce34]
    V [libjvm.so+0x9c2c4]
    V [libjvm.so+0x9be3c]
    V [libjvm.so+0x9bbc4]
    V [libjvm.so+0xcbec8]
    V [libjvm.so+0xd0b84]
    j be.telenet.rts.oms.dbpoller.PollOmsNotificationTable.processDeleteOfAging(Lbe/telenet/rts/oms/dbpoller/OmsNotificationDataV
    O;)V+4
    J be.telenet.rts.oms.dbpoller.PollOmsNotificationTable.processOmsNotificationData(Ljava/util/Collection;)V
    J be.telenet.rts.oms.dbpoller.PollOmsNotificationTable.pollTable()V
    v ~RuntimeStub::osr_frame_return Runtime1 stub
    j be.telenet.rts.oms.dbpoller.ILMAdapter_NotifierPoller.main([Ljava/lang/String;)V+30
    v ~StubRoutines::call_stub
    V [libjvm.so+0xc9ccc]
    V [libjvm.so+0xdde98]
    V [libjvm.so+0x16791c]
    C [java+0x2f94] main+0x167c
    Thanks & Regards,
    Anuj

    Here's the exception I'm getting (slightly sanitized):
    Java Plug-in 1.4.2_10
    Using JRE version 1.4.2_10 Java HotSpot(TM) Client VM
    User home directory = C:\Documents and Settings\tvalesky
    c: clear console window
    f: finalize objects on finalization queue
    g: garbage collect
    h: display this help message
    l: dump classloader list
    m: print memory usage
    o: trigger logging
    q: hide console
    r: reload policy configuration
    s: dump system and deployment properties
    t: dump thread list
    v: dump thread stack
    x: clear classloader cache
    0-5: set trace level to
    load: class appls/DOLARS/user/Applet.class not found.
    java.lang.ClassNotFoundException: appls.DOLARS.user.Applet.class
         at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.IOException: open HTTP connection failed:http://hostname.com/DOLARS.testing/dolars.testbed/classes/appls%2fDOLARS%2fuser%2fApplet%2fclass.class
         at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
         at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
         at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         ... 7 more
    Exception: java.lang.ClassNotFoundException: appls.DOLARS.user.Applet.class

  • Exception in native code causing Tomcat to crash

    I am running a java servlet on Tomcat and have noticed that it has been unexpectedly terminating quite a bit over the last month or so. Yesterday it happened twice, citing an exception in native code outside the VM. I really have no idea where to start debugging this. Below is what is in the log file that is generated when it terminates. Does anybody know why something like this would be happening? Looking at the stack trace, it looks like a strange place to be terminating? Has anybody come accross anything like this? If you need more information, let me know!
    Thanks!!!
    An unexpected exception has been detected in native code outside the VM.
    Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x77F4200B
    Function=RtlEnterCriticalSection+0xB
    Library=C:\WINDOWS\system32\ntdll.dll
    Current Java thread:
    at sun.jdbc.odbc.JdbcOdbc.allocConnect(Native Method)
    at sun.jdbc.odbc.JdbcOdbc.SQLAllocConnect(JdbcOdbc.java:114)
    at sun.jdbc.odbc.JdbcOdbcDriver.allocConnection(JdbcOdbcDriver.java:929)
    at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:126)
    at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
    - locked <02F7D2F0> (a sun.jdbc.odbc.JdbcOdbcDriver)
    at java.sql.DriverManager.getConnection(DriverManager.java:512)
    - locked <06A87EB0> (a java.lang.Class)
    at java.sql.DriverManager.getConnection(DriverManager.java:193)
    - locked <06A87EB0> (a java.lang.Class)
    at com.lmp.iomada.servlets.LMPPersistence.buildObjects(LMPPersistence.java:56)
    at com.lmp.iomada.servlets.LMPServlet.transformHTML(LMPServlet.java:635)
    at com.lmp.iomada.servlets.LMPServlet.doGet(LMPServlet.java:71)
    at com.lmp.iomada.servlets.LMPServlet.doPost(LMPServlet.java:82)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java)
    at org.apache.tomcat.facade.ServletHandler.doService(Unknown Source)
    at org.apache.tomcat.core.Handler.invoke(Unknown Source)
    at org.apache.tomcat.core.Handler.service(Unknown Source)
    at org.apache.tomcat.facade.ServletHandler.service(Unknown Source)
    at org.apache.tomcat.core.ContextManager.internalService(Unknown Source)
    at org.apache.tomcat.core.ContextManager.service(Unknown Source)
    at org.apache.tomcat.modules.server.Ajp12Interceptor.processConnection(Unknown Source)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(Unknown Source)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:536)
    Dynamic libraries:
    0x00400000 - 0x00406000 c:\j2sdk1.4.1_03\bin\java.exe
    0x77F40000 - 0x77FFA000 C:\WINDOWS\system32\ntdll.dll
    0x77E40000 - 0x77F34000 C:\WINDOWS\system32\kernel32.dll
    0x77DA0000 - 0x77E30000 C:\WINDOWS\system32\ADVAPI32.dll
    0x77C50000 - 0x77CF5000 C:\WINDOWS\system32\RPCRT4.dll
    0x77BA0000 - 0x77BF4000 C:\WINDOWS\system32\MSVCRT.dll
    0x6D340000 - 0x6D46B000 c:\j2sdk1.4.1_03\jre\bin\client\jvm.dll
    0x77D00000 - 0x77D8F000 C:\WINDOWS\system32\USER32.dll
    0x77C00000 - 0x77C44000 C:\WINDOWS\system32\GDI32.dll
    0x76AA0000 - 0x76ACC000 C:\WINDOWS\system32\WINMM.dll
    0x6D1E0000 - 0x6D1E7000 c:\j2sdk1.4.1_03\jre\bin\hpi.dll
    0x6D310000 - 0x6D31E000 c:\j2sdk1.4.1_03\jre\bin\verify.dll
    0x6D220000 - 0x6D239000 c:\j2sdk1.4.1_03\jre\bin\java.dll
    0x6D330000 - 0x6D33D000 c:\j2sdk1.4.1_03\jre\bin\zip.dll
    0x76F50000 - 0x76F63000 C:\WINDOWS\system32\Secur32.dll
    0x6D2E0000 - 0x6D2EE000 C:\j2sdk1.4.1_03\jre\bin\net.dll
    0x71BB0000 - 0x71BB9000 C:\WINDOWS\system32\WSOCK32.dll
    0x71C00000 - 0x71C18000 C:\WINDOWS\system32\WS2_32.dll
    0x71BF0000 - 0x71BF8000 C:\WINDOWS\system32\WS2HELP.dll
    0x71B20000 - 0x71B63000 C:\WINDOWS\system32\mswsock.dll
    0x71AE0000 - 0x71AE8000 C:\WINDOWS\System32\wshtcpip.dll
    0x6D260000 - 0x6D26B000 C:\j2sdk1.4.1_03\jre\bin\JdbcOdbc.dll
    0x0B3E0000 - 0x0B41A000 C:\WINDOWS\system32\ODBC32.dll
    0x70BC0000 - 0x70C50000 C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_5.82.0.0_x-ww_8A69BA05\COMCTL32.dll
    0x77380000 - 0x77B5D000 C:\WINDOWS\system32\SHELL32.dll
    0x77290000 - 0x772D9000 C:\WINDOWS\system32\SHLWAPI.dll
    0x762B0000 - 0x762F7000 C:\WINDOWS\system32\comdlg32.dll
    0x70AD0000 - 0x70BB6000 C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.100.0_x-ww_8417450B\comctl32.dll
    0x0B580000 - 0x0B597000 C:\WINDOWS\system32\odbcint.dll
    0x0B720000 - 0x0B73A000 C:\WINDOWS\system32\odbccp32.dll
    0x77160000 - 0x77285000 C:\WINDOWS\system32\ole32.dll
    0x77B90000 - 0x77B98000 C:\WINDOWS\system32\VERSION.dll
    0x76ED0000 - 0x76EF7000 C:\WINDOWS\system32\DNSAPI.dll
    0x76F70000 - 0x76F77000 C:\WINDOWS\System32\winrnr.dll
    0x76F10000 - 0x76F3F000 C:\WINDOWS\system32\WLDAP32.dll
    0x76F80000 - 0x76F85000 C:\WINDOWS\system32\rasadhlp.dll
    0x0FFD0000 - 0x0FFFD000 C:\WINDOWS\system32\rsaenh.dll
    0x76B70000 - 0x76B7B000 C:\WINDOWS\system32\PSAPI.DLL
    0x76C10000 - 0x76C38000 C:\WINDOWS\system32\imagehlp.dll
    0x6D580000 - 0x6D621000 C:\WINDOWS\system32\dbghelp.dll
    Local Time = Tue Jun 01 21:23:49 2004
    Elapsed Time = 5644
    # The exception above was detected in native code outside the VM
    # Java VM: Java HotSpot(TM) Client VM (1.4.1_03-b02 mixed mode)

    Library=C:\WINDOWS\system32\ntdll.dll
    Current Java thread:
    at sun.jdbc.odbc.JdbcOdbc.allocConnect(Native Method)
    at sun.jdbc.odbc.JdbcOdbc.SQLAllocConnect(JdbcOdbc.java:114)
    at sun.jdbc.odbc.JdbcOdbcDriver.allocConnection(JdbcOdbcDriver.java:929)
    at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:126)
    at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
    The stack trace points to an error in ntdll.dll, the NT system calls library, while it being used by Sun's standard ODBC driver.
    There are two unfixed bugs against 1.4 in this area. One suggests incorrect usage of the driver by client code. The other suggests that the current Java library has poor handling of exceptions in system code.
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4812268
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4641011
    The latter does not explort the actual cause of exceptions - they will have something to do with your Windows configuration. Applying the latest NT service packs might help. Unfortunately as the bug report indicates, this issue will not be fixed in 1.4.

  • XA  jDriver for Oracle problem : Getting native code exception

    Hi,
    I'm getting a native code exception which causes the Weblogic server to crash when
    using XA drivers for transaction with two oracle databases. My application uses RMI
    and threads.
    I'm using BEA's jDriver for Oracle running under Weblogic server 6.1 sp1 talking
    to Oracle 8.1.6. The OS is Solaris 2.8.
    In middle of the program execution it's giving this problem. I'm using jdk131 in
    solaris platform.
    Any idea what's going on here ?
    Thanks,
    Nagoor Haja
    Exception in the Log file:
    ===========================
    An unexpected exception has been detected in native code outside the VM.
    Unexpected Signal : 11 occurred at PC=0xff2414d8
    Function name=madvise
    Library=/usr/lib/libc.so.1
    Current Java thread:
    at weblogic.jdbc.oci.xa.XA.native_commit(Native Method)
    at weblogic.jdbc.oci.xa.XA.commit(XA.java:136)
    at weblogic.jdbc.oci.xa.XADataSource.commit(XADataSource.java:696)
    at weblogic.jdbc.jta.DataSource.commit(DataSource.java:784)
    at weblogic.transaction.internal.ServerResourceInfo.commit(ServerResourceInfo.java:1180)
    at weblogic.transaction.internal.ServerResourceInfo.commit(ServerResourceInfo.java:419)
    at weblogic.transaction.internal.ServerSCInfo.startCommit(ServerSCInfo.java:233)
    at weblogic.transaction.internal.ServerTransactionImpl.localCommit(ServerTransactionImpl.java:1397)
    at weblogic.transaction.internal.ServerTransactionImpl.globalRetryCommit(ServerTransactionImpl.java:1940)
    at weblogic.transaction.internal.ServerTransactionImpl.globalCommit(ServerTransactionImpl.java:1886)
    at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:221)
    at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:190)
    at weblogic.transaction.internal.CoordinatorImpl.commit(CoordinatorImpl.java:68)
    at weblogic.transaction.internal.CoordinatorImpl_WLSkel.invoke(Unknown Source)
    at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:296)
    at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:265)
    at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:22)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    Dynamic libraries:
    0x10000 /opt/jdk131/jre/bin/../bin/sparc/native_threads/java
    0xff350000 /usr/lib/libthread.so.1
    0xff390000 /usr/lib/libdl.so.1
    0xff200000 /usr/lib/libc.so.1
    0xff330000 /usr/platform/SUNW,Ultra-60/lib/libc_psr.so.1
    0xfe480000 /opt/jdk131/jre/lib/sparc/hotspot/libjvm.so
    0xff2e0000 /usr/lib/libCrun.so.1
    0xff1e0000 /usr/lib/libsocket.so.1
    0xff100000 /usr/lib/libnsl.so.1
    0xff0d0000 /usr/lib/libm.so.1
    0xff100000 /usr/lib/libnsl.so.1
    0xff0d0000 /usr/lib/libm.so.1
    0xff310000 /usr/lib/libw.so.1
    0xff0b0000 /usr/lib/libmp.so.2
    0xff080000 /opt/jdk131/jre/lib/sparc/native_threads/libhpi.so
    0xff050000 /opt/jdk131/jre/lib/sparc/libverify.so
    0xfe440000 /opt/jdk131/jre/lib/sparc/libjava.so
    0xff020000 /opt/jdk131/jre/lib/sparc/libzip.so
    0xfafb0000 /opt/jdk131/jre/lib/sparc/libnet.so
    0xfadd0000 /usr/lib/nss_files.so.1
    0xe1d00000 /opt/wlserver6.1/lib/solaris/oci816_8/libweblogicoci37.so
    0xe1400000 /opt/oracle/lib/libclntsh.so.8.0
    0xfac90000 /usr/lib/libC.so.5
    0xfadb0000 /opt/oracle/lib/libwtc8.so
    0xfad90000 /usr/lib/libgen.so.1
    0xfac70000 /usr/lib/libsched.so.1
    0xfac40000 /usr/lib/libaio.so.1
    0xfac20000 /opt/wlserver6.1/lib/solaris/oci816_8/libweblogicoxa37.so
    0xe8ad0000 /redis/tibco/rv6.6/lib/libtibrvj.so
    0xe8ab0000 /redis/tibco/rv6.6/lib/libtibrvcmq.so
    0xe89c0000 /redis/tibco/rv6.6/lib/libtibrvcm.so
    0xe8990000 /redis/tibco/rv6.6/lib/libtibrvft.so
    0xe8890000 /redis/tibco/rv6.6/lib/libtibrv.so
    0xe8870000 /usr/lib/libpthread.so.1
    0xe6fe0000 /opt/wlserver6.1/lib/solaris/libmuxer.so
    0xe6fc0000 /opt/wlserver6.1/lib/solaris/libweblogicunix1.so
    java Exception in the program due to the above reason:
    ======================================================
    java.sql.SQLException: weblogic.rmi.extensions.RemoteRuntimeException - with nested
    exception:
    [weblogic.rjvm.PeerGoneException: ; nested exception is:
         java.io.EOFException]
         at weblogic.jdbc.rmi.SerialStatement.execute(SerialStatement.java:310)
         at com.cme.clearing.jta.JThread.insertAgain(JThread.java:121)
         at com.cme.clearing.jta.JThread.process(JThread.java:100)
         at com.cme.clearing.jta.JThread.run(JThread.java:85)
    java.sql.SQLException: weblogic.rmi.extensions.RemoteRuntimeException - with nested
    exception:
    [weblogic.rjvm.PeerGoneException: ; nested exception is:
         java.io.EOFException]
         at weblogic.jdbc.rmi.SerialStatement.execute(SerialStatement.java:310)
         at com.cme.clearing.jta.JThread.insertAgain(JThread.java:121)
         at com.cme.clearing.jta.JThread.process(JThread.java:100)
         at com.cme.clearing.jta.JThread.run(JThread.java:85)
    java.sql.SQLException: weblogic.rmi.extensions.RemoteRuntimeException - with nested
    exception:
    [weblogic.rjvm.PeerGoneException: ; nested exception is:
         java.io.EOFException]
         at weblogic.jdbc.rmi.SerialStatement.execute(SerialStatement.java:310)
         at com.cme.clearing.jta.JThread.insertAgain(JThread.java:121)
         at com.cme.clearing.jta.JThread.process(JThread.java:100)
         at com.cme.clearing.jta.JThread.run(JThread.java:85)
    java.rmi.RemoteException: Message was not sent because transaction is not active.
    Xid=0:a1ccd55d7f28edb9(795840),Status=Rolled back. [Reason=weblogic.transaction.internal.TimedOutException:
    Transaction timed out after 29 seconds
    Xid=0:a1ccd55d7f28edb9(795840),Status=Active,numRepliesOwedMe=1,numRepliesOwedOthers=0,seconds
    since begin=29,seconds left=30,activeThread=Thread[Thread-1,5,main],spatidbxa,SCInfo[mydomain+myserver]=(state=active),properties=({}),OwnerTransactionManager=ClientTM,CoordinatorURL=myserver+10.1.32.81:8001+mydomain+)],numRepliesOwedMe=1,numRepliesOwedOthers=0,seconds
    since begin=68,seconds left=1,activeThread=Thread[Thread-1,5,main],spatidbxa,SCInfo[mydomain+myserver]=(state=active),properties=({}),OwnerTransactionManager=ClientTM,CoordinatorURL=myserver+10.1.32.81:8001+mydomain+)
         at weblogic.transaction.internal.TransactionManagerImpl.sendRequest(TransactionManagerImpl.java:1155)
         at weblogic.rmi.internal.BasicRemoteRef.getOutboundRequest(BasicRemoteRef.java:101)
         at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:123)
         at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:35)
         at $Proxy1.process(Unknown Source)
         at com.cme.clearing.jta.JThread.process(JThread.java:101)
         at com.cme.clearing.jta.JThread.run(JThread.java:85)
    java.rmi.RemoteException: Message was not sent because transaction is not active.
    Xid=1:a1ccd55d7f28edb9(6051803),Status=Rolled back. [Reason=weblogic.transaction.internal.TimedOutException:
    Transaction timed out after 29 seconds
    Xid=1:a1ccd55d7f28edb9(6051803),Status=Active,numRepliesOwedMe=1,numRepliesOwedOthers=0,seconds
    since begin=29,seconds left=30,activeThread=Thread[Thread-2,5,main],spatidbxa,SCInfo[mydomain+myserver]=(state=active),properties=({}),OwnerTransactionManager=ClientTM,CoordinatorURL=myserver+10.1.32.81:8001+mydomain+)],numRepliesOwedMe=1,numRepliesOwedOthers=0,seconds
    since begin=69,seconds left=0,activeThread=Thread[Thread-2,5,main],spatidbxa,SCInfo[mydomain+myserver]=(state=active),properties=({}),OwnerTransactionManager=ClientTM,CoordinatorURL=myserver+10.1.32.81:8001+mydomain+)
         at weblogic.transaction.internal.TransactionManagerImpl.sendRequest(TransactionManagerImpl.java:1155)
         at weblogic.rmi.internal.BasicRemoteRef.getOutboundRequest(BasicRemoteRef.java:101)
         at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:123)
         at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:35)
         at $Proxy1.process(Unknown Source)
         at com.cme.clearing.jta.JThread.process(JThread.java:101)
         at com.cme.clearing.jta.JThread.run(JThread.java:85)
    java.rmi.RemoteException: Message was not sent because transaction is not active.
    Xid=2:a1ccd55d7f28edb9(4244097),Status=Rolled back. [Reason=weblogic.transaction.internal.TimedOutException:
    Transaction timed out after 33 seconds
    Xid=2:a1ccd55d7f28edb9(4244097),Status=Active,numRepliesOwedMe=1,numRepliesOwedOthers=0,seconds
    since begin=33,seconds left=30,activeThread=Thread[Thread-3,5,main],spatidbxa,SCInfo[mydomain+myserver]=(state=active),properties=({}),OwnerTransactionManager=ClientTM,CoordinatorURL=myserver+10.1.32.81:8001+mydomain+)],numRepliesOwedMe=1,numRepliesOwedOthers=0,seconds
    since begin=68,seconds left=5,activeThread=Thread[Thread-3,5,main],spatidbxa,SCInfo[mydomain+myserver]=(state=active),properties=({}),OwnerTransactionManager=ClientTM,CoordinatorURL=myserver+10.1.32.81:8001+mydomain+)
         at weblogic.transaction.internal.TransactionManagerImpl.sendRequest(TransactionManagerImpl.java:1155)
         at weblogic.rmi.internal.BasicRemoteRef.getOutboundRequest(BasicRemoteRef.java:101)
         at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:123)
         at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:35)
         at $Proxy1.process(Unknown Source)
         at com.cme.clearing.jta.JThread.process(JThread.java:101)
         at com.cme.clearing.jta.JThread.run(JThread.java:85)
    javax.naming.CommunicationException. Root exception is java.rmi.ConnectException:
    Unable to get direct or routed connection to: '-736127454917455663S:10.1.32.81:[8001,8001,8002,8002,8001,8002,-1]:mydomain:myserver'
         at weblogic.rmi.internal.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:85)
         at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:255)
         at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:222)
         at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:35)
         at $Proxy0.lookup(Unknown Source)
         at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:323)
         at javax.naming.InitialContext.lookup(InitialContext.java:350)
         at com.cme.clearing.jta.JContext.getTransaction(JContext.java:29)
         at com.cme.clearing.jta.JThread.startTransaction(JThread.java:67)
         at com.cme.clearing.jta.JThread.run(JThread.java:81)
    Exception null
    javax.naming.CommunicationException. Root exception is java.rmi.ConnectException:
    Unable to get direct or routed connection to: '-736127454917455663S:10.1.32.81:[8001,8001,8002,8002,8001,8002,-1]:mydomain:myserver'
         at weblogic.rmi.internal.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:85)
         at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:255)
         at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:222)
         at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:35)
         at $Proxy0.lookup(Unknown Source)
         at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:323)
         at javax.naming.InitialContext.lookup(InitialContext.java:350) Exception null
         at com.cme.clearing.jta.JContext.getTransaction(JContext.java:29)
         at com.cme.clearing.jta.JThread.startTransaction(JThread.java:67)
         at com.cme.clearing.jta.JThread.run(JThread.java:81)

    I see. Do you mean this code runs outside of the server? :
    at com.cme.clearing.jta.JThread.insertAgain(JThread.java:121)
    at com.cme.clearing.jta.JThread.process(JThread.java:100)
    at com.cme.clearing.jta.JThread.run(JThread.java:85)
    Regards,
    Slava Imeshev
    "Tim" <[email protected]> wrote in message
    news:[email protected]...
    >
    Slava,
    In my case, I'm not spawning any threads.
    Regards,
    Tim
    "Slava Imeshev" <[email protected]> wrote:
    That could be a trace of some threading issue. Note that EJB spec
    prohibits
    using threads within a container.
    Regards,
    Slava Imeshev
    "Tim" <[email protected]> wrote in message
    news:[email protected]...
    Nagoor,
    Did anybody respond? I'm getting the same exception with the sameenvironment configuration
    but using WLS 6.1 SP2.
    Tim
    "Nagoor Haja" <[email protected]> wrote:
    Hi,
    I'm getting a native code exception which causes the Weblogic server
    to
    crash when
    using XA drivers for transaction with two oracle databases. Myapplication
    uses RMI
    and threads.
    I'm using BEA's jDriver for Oracle running under Weblogic server 6.1sp1
    talking
    to Oracle 8.1.6. The OS is Solaris 2.8.
    In middle of the program execution it's giving this problem. I'm
    using
    jdk131 in
    solaris platform.
    Any idea what's going on here ?
    Thanks,
    Nagoor Haja
    Exception in the Log file:
    ===========================
    An unexpected exception has been detected in native code outside theVM.
    Unexpected Signal : 11 occurred at PC=0xff2414d8
    Function name=madvise
    Library=/usr/lib/libc.so.1
    Current Java thread:
    at weblogic.jdbc.oci.xa.XA.native_commit(Native Method)
    at weblogic.jdbc.oci.xa.XA.commit(XA.java:136)
    atweblogic.jdbc.oci.xa.XADataSource.commit(XADataSource.java:696)
    at weblogic.jdbc.jta.DataSource.commit(DataSource.java:784)
    at
    weblogic.transaction.internal.ServerResourceInfo.commit(ServerResourceInfo.j
    ava:1180)
    at
    weblogic.transaction.internal.ServerResourceInfo.commit(ServerResourceInfo.j
    ava:419)
    at
    weblogic.transaction.internal.ServerSCInfo.startCommit(ServerSCInfo.java:233
    at
    weblogic.transaction.internal.ServerTransactionImpl.localCommit(ServerTransa
    ctionImpl.java:1397)
    at
    weblogic.transaction.internal.ServerTransactionImpl.globalRetryCommit(Server
    TransactionImpl.java:1940)
    at
    weblogic.transaction.internal.ServerTransactionImpl.globalCommit(ServerTrans
    actionImpl.java:1886)
    at
    weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTra
    nsactionImpl.java:221)
    at
    weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransaction
    Impl.java:190)
    at
    weblogic.transaction.internal.CoordinatorImpl.commit(CoordinatorImpl.java:68
    atweblogic.transaction.internal.CoordinatorImpl_WLSkel.invoke(Unknown
    Source)
    atweblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:296)
    at
    weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:265)
    atweblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:2
    2)
    at
    weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    Dynamic libraries:
    0x10000 /opt/jdk131/jre/bin/../bin/sparc/native_threads/java
    0xff350000 /usr/lib/libthread.so.1
    0xff390000 /usr/lib/libdl.so.1
    0xff200000 /usr/lib/libc.so.1
    0xff330000 /usr/platform/SUNW,Ultra-60/lib/libc_psr.so.1
    0xfe480000 /opt/jdk131/jre/lib/sparc/hotspot/libjvm.so
    0xff2e0000 /usr/lib/libCrun.so.1
    0xff1e0000 /usr/lib/libsocket.so.1
    0xff100000 /usr/lib/libnsl.so.1
    0xff0d0000 /usr/lib/libm.so.1
    0xff100000 /usr/lib/libnsl.so.1
    0xff0d0000 /usr/lib/libm.so.1
    0xff310000 /usr/lib/libw.so.1
    0xff0b0000 /usr/lib/libmp.so.2
    0xff080000 /opt/jdk131/jre/lib/sparc/native_threads/libhpi.so
    0xff050000 /opt/jdk131/jre/lib/sparc/libverify.so
    0xfe440000 /opt/jdk131/jre/lib/sparc/libjava.so
    0xff020000 /opt/jdk131/jre/lib/sparc/libzip.so
    0xfafb0000 /opt/jdk131/jre/lib/sparc/libnet.so
    0xfadd0000 /usr/lib/nss_files.so.1
    0xe1d00000/opt/wlserver6.1/lib/solaris/oci816_8/libweblogicoci37.so
    0xe1400000 /opt/oracle/lib/libclntsh.so.8.0
    0xfac90000 /usr/lib/libC.so.5
    0xfadb0000 /opt/oracle/lib/libwtc8.so
    0xfad90000 /usr/lib/libgen.so.1
    0xfac70000 /usr/lib/libsched.so.1
    0xfac40000 /usr/lib/libaio.so.1
    0xfac20000/opt/wlserver6.1/lib/solaris/oci816_8/libweblogicoxa37.so
    0xe8ad0000 /redis/tibco/rv6.6/lib/libtibrvj.so
    0xe8ab0000 /redis/tibco/rv6.6/lib/libtibrvcmq.so
    0xe89c0000 /redis/tibco/rv6.6/lib/libtibrvcm.so
    0xe8990000 /redis/tibco/rv6.6/lib/libtibrvft.so
    0xe8890000 /redis/tibco/rv6.6/lib/libtibrv.so
    0xe8870000 /usr/lib/libpthread.so.1
    0xe6fe0000 /opt/wlserver6.1/lib/solaris/libmuxer.so
    0xe6fc0000 /opt/wlserver6.1/lib/solaris/libweblogicunix1.so
    java Exception in the program due to the above reason:
    ======================================================
    java.sql.SQLException: weblogic.rmi.extensions.RemoteRuntimeException-
    with nested
    exception:
    [weblogic.rjvm.PeerGoneException: ; nested exception is:
    java.io.EOFException]
    at
    weblogic.jdbc.rmi.SerialStatement.execute(SerialStatement.java:310)
    >>>>
    at com.cme.clearing.jta.JThread.insertAgain(JThread.java:121)
    at com.cme.clearing.jta.JThread.process(JThread.java:100)
    at com.cme.clearing.jta.JThread.run(JThread.java:85)
    java.sql.SQLException: weblogic.rmi.extensions.RemoteRuntimeException-
    with nested
    exception:
    [weblogic.rjvm.PeerGoneException: ; nested exception is:
    java.io.EOFException]
    at
    weblogic.jdbc.rmi.SerialStatement.execute(SerialStatement.java:310)
    >>>>
    at com.cme.clearing.jta.JThread.insertAgain(JThread.java:121)
    at com.cme.clearing.jta.JThread.process(JThread.java:100)
    at com.cme.clearing.jta.JThread.run(JThread.java:85)
    java.sql.SQLException: weblogic.rmi.extensions.RemoteRuntimeException-
    with nested
    exception:
    [weblogic.rjvm.PeerGoneException: ; nested exception is:
    java.io.EOFException]
    at
    weblogic.jdbc.rmi.SerialStatement.execute(SerialStatement.java:310)
    >>>>
    at com.cme.clearing.jta.JThread.insertAgain(JThread.java:121)
    at com.cme.clearing.jta.JThread.process(JThread.java:100)
    at com.cme.clearing.jta.JThread.run(JThread.java:85)
    java.rmi.RemoteException: Message was not sent because transaction isnot
    active.
    Xid=0:a1ccd55d7f28edb9(795840),Status=Rolled back.[Reason=weblogic.transaction.internal.TimedOutException:
    Transaction timed out after 29 seconds
    Xid=0:a1ccd55d7f28edb9(795840),Status=Active,numRepliesOwedMe=1,numReplies
    O
    wedOthers=0,seconds
    since begin=29,seconds
    left=30,activeThread=Thread[Thread-1,5,main],spatidbxa,SCInfo[mydomain+myser
    >
    ver]=(state=active),properties=({}),OwnerTransactionManager=ClientTM,Coordin
    >
    atorURL=myserver+10.1.32.81:8001+mydomain+)],numRepliesOwedMe=1,numRepliesOw
    edOthers=0,seconds
    since begin=68,seconds
    left=1,activeThread=Thread[Thread-1,5,main],spatidbxa,SCInfo[mydomain+myserv
    >
    er]=(state=active),properties=({}),OwnerTransactionManager=ClientTM,Coordina
    torURL=myserver+10.1.32.81:8001+mydomain+)
    at
    weblogic.transaction.internal.TransactionManagerImpl.sendRequest(Transaction
    ManagerImpl.java:1155)
    at
    weblogic.rmi.internal.BasicRemoteRef.getOutboundRequest(BasicRemoteRef.java:
    101)
    at
    weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:123)
    >>>>
    at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:35)
    at $Proxy1.process(Unknown Source)
    at com.cme.clearing.jta.JThread.process(JThread.java:101)
    at com.cme.clearing.jta.JThread.run(JThread.java:85)
    java.rmi.RemoteException: Message was not sent because transaction isnot
    active.
    Xid=1:a1ccd55d7f28edb9(6051803),Status=Rolled back.[Reason=weblogic.transaction.internal.TimedOutException:
    Transaction timed out after 29 seconds
    Xid=1:a1ccd55d7f28edb9(6051803),Status=Active,numRepliesOwedMe=1,numReplie
    s
    OwedOthers=0,seconds
    since begin=29,seconds
    left=30,activeThread=Thread[Thread-2,5,main],spatidbxa,SCInfo[mydomain+myser
    >
    ver]=(state=active),properties=({}),OwnerTransactionManager=ClientTM,Coordin
    >
    atorURL=myserver+10.1.32.81:8001+mydomain+)],numRepliesOwedMe=1,numRepliesOw
    edOthers=0,seconds
    since begin=69,seconds
    left=0,activeThread=Thread[Thread-2,5,main],spatidbxa,SCInfo[mydomain+myserv
    >
    er]=(state=active),properties=({}),OwnerTransactionManager=ClientTM,Coordina
    torURL=myserver+10.1.32.81:8001+mydomain+)
    at
    weblogic.transaction.internal.TransactionManagerImpl.sendRequest(Transaction
    ManagerImpl.java:1155)
    at
    weblogic.rmi.internal.BasicRemoteRef.getOutboundRequest(BasicRemoteRef.java:
    101)
    at
    weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:123)
    >>>>
    at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:35)
    at $Proxy1.process(Unknown Source)
    at com.cme.clearing.jta.JThread.process(JThread.java:101)
    at com.cme.clearing.jta.JThread.run(JThread.java:85)
    java.rmi.RemoteException: Message was not sent because transaction isnot
    active.
    Xid=2:a1ccd55d7f28edb9(4244097),Status=Rolled back.[Reason=weblogic.transaction.internal.TimedOutException:
    Transaction timed out after 33 seconds
    Xid=2:a1ccd55d7f28edb9(4244097),Status=Active,numRepliesOwedMe=1,numReplie
    s
    OwedOthers=0,seconds
    since begin=33,seconds
    left=30,activeThread=Thread[Thread-3,5,main],spatidbxa,SCInfo[mydomain+myser
    >
    ver]=(state=active),properties=({}),OwnerTransactionManager=ClientTM,Coordin
    >
    atorURL=myserver+10.1.32.81:8001+mydomain+)],numRepliesOwedMe=1,numRepliesOw
    edOthers=0,seconds
    since begin=68,seconds
    left=5,activeThread=Thread[Thread-3,5,main],spatidbxa,SCInfo[mydomain+myserv
    >
    er]=(state=active),properties=({}),OwnerTransactionManager=ClientTM,Coordina
    torURL=myserver+10.1.32.81:8001+mydomain+)
    at
    weblogic.transaction.internal.TransactionManagerImpl.sendRequest(Transaction
    ManagerImpl.java:1155)
    at
    weblogic.rmi.internal.BasicRemoteRef.getOutboundRequest(BasicRemoteRef.java:
    101)
    at
    weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:123)
    >>>>
    at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:35)
    at $Proxy1.process(Unknown Source)
    at com.cme.clearing.jta.JThread.process(JThread.java:101)
    at com.cme.clearing.jta.JThread.run(JThread.java:85)
    javax.naming.CommunicationException. Root exception isjava.rmi.ConnectException:
    Unable to get direct or routed connection to:
    '-736127454917455663S:10.1.32.81:[8001,8001,8002,8002,8001,8002,-1]:mydomain
    :myserver'
    at
    weblogic.rmi.internal.BasicOutboundRequest.sendReceive(BasicOutboundRequest.
    java:85)
    at
    weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java
    :255)
    at
    weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java
    :222)
    at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:35)
    at $Proxy0.lookup(Unknown Source)
    at
    weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:323)
    >>>>
    at javax.naming.InitialContext.lookup(InitialContext.java:350)
    at com.cme.clearing.jta.JContext.getTransaction(JContext.java:29)
    at com.cme.clearing.jta.JThread.startTransaction(JThread.java:67)
    at com.cme.clearing.jta.JThread.run(JThread.java:81)
    Exception null
    javax.naming.CommunicationException. Root exception isjava.rmi.ConnectException:
    Unable to get direct or routed connection to:
    '-736127454917455663S:10.1.32.81:[8001,8001,8002,8002,8001,8002,-1]:mydomain
    :myserver'
    at
    weblogic.rmi.internal.BasicOutboundRequest.sendReceive(BasicOutboundRequest.
    java:85)
    at
    weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java
    :255)
    at
    weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java
    :222)
    at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:35)
    at $Proxy0.lookup(Unknown Source)
    at
    weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:323)
    >>>>
    at javax.naming.InitialContext.lookup(InitialContext.java:350)Exception
    null
    at com.cme.clearing.jta.JContext.getTransaction(JContext.java:29)
    at com.cme.clearing.jta.JThread.startTransaction(JThread.java:67)
    at com.cme.clearing.jta.JThread.run(JThread.java:81)

  • How to generate Voucher Codes in CRM 7 EHP1

    Hallo all,
    we have currently set up a CRM7 EHP1 system to check out the latest functions. I try to get the new voucher functions working. I customized the voucher stuff as described in the documentation (http://help.sap.com/saphelp_crm700_ehp01/helpdata/EN/f1/7eb3ccd1ba4a27a8f2ecc07664f7e6/frameset.htm)
    I defined the voucher code variants, a number range for my vouchers and I implemented the BAdI.
    My question now is: how and when are the voucher codes generated? I created a campaign of my voucher type and assigned a simple segment. Then I changed the status to 'released' but nothing happened. Even after explicitly executing the campaign, nothing happened, the number range interval still starts with 0 so no codes were generated. My BAdI implementation is supposed to write the generated code into some db table but that table is empty.
    Does anyone have a clue how I get the codes to be generated?
    Thanks and best regards,
    Martin

    Have you created the mail form and attached the mail form to the campaign you created?
    In the mail form, you have to insert the coupon code attribute in the mail form. you can found that in
    mail form-> Text Element section, click on attribute button -> Attribute Category to be selected as Campaigns.
    The coupon code will be generated when you execute the campaign and the segment receives email.
    Hope this helps.
    Regards,
    Harsh

  • Not returning from the native code

    Hi,
    I am trying to access the native code using java applet. My java code seems to load the DLL(created using the VC++ 6.0) properly. Then when i call the native method called crypto, it does not seem to return from the nayive code . I am signing the applet and putting it a signed jar .Any suggestion is appreciated. I mite be wrong in the design too ...pleas ehelp. I am pasting the java code and the C code.
    cryptoJNI.java
    import java.awt.*;
    import java.io.*;
    import java.lang.*;
    import java.applet.*;
    public class cryptoJNI extends Applet {
         String uname=null;
         String b=null,ret=null;
         String a=null;
    public void init(){
              System.out.println("in init");
         public void dll_load(){
              b="before dll";
              System.loadLibrary("Msgimpl");
              a="after dll load";
         private native String crypto(String store);
    public void paint(Graphics g) {
              g.setColor(Color.blue);
              g.setColor(Color.magenta);
              load_dll();
              g.drawString(b, 5, 5);
              g.drawString(a, 15, 15);
              g.drawString("first call const", 25, 25);
              cryptoJNI app = new cryptoJNI();
              ret=app.crypto("My");
    g.drawString(ret, 75, 75);
              g.drawString("Signed 11", 120, 80);
              stop();
    CryptoJNI.c
    #define WIN32WINNT 0x0400
    #include <windows.h>
    #include <jni.h>
    #include <wincrypt.h>
    #define MY_ENCODING_TYPE (PKCS_7_ASN_ENCODING | X509_ASN_ENCODING)
    #include "cryptoJNI.h"
    BOOL APIENTRY DllMain(HANDLE hModule,
    DWORD dwReason, void** lpReserved) {
    return TRUE;
    JNIEXPORT void JNICALL
    Java_CryptoJNI_crypto(JNIEnv * jEnv,jobject obj,jstring jstore) {
    //     char               name[256];
         const char *msg;
         msg = (*jEnv)->GetStringUTFChars(jEnv, jstore,0);
         //printf("Before context\n");
         //(*jEnv)->ReleaseStringUTFChars(jEnv, jstore,msg);
         return (*jEnv)->NewStringUTF(jEnv, msg);
    In my applet, i have some debugging statements that helps me verify that the Msgimpl.dll loads properly. When i invoke the app.crypto() it just "hangs". Please help
    Thanks,
    Vivek

    Hi,
    This is the exception that i am getting?? my cryptoJNIImp.c is is in the same directory as the my java file,c:\vivek work\signedcode. and i have added this to my path env variable...If u see the output, it executes the init() and then loads the Msgimpl.dll. So its got nothing do with loading a DLL. Any pointers on this..
    in init
    before loading dll
    After loading dll
    java.lang.UnsatisfiedLinkError: crypto
    at cryptoJNI.crypto(Native Method)
    at cryptoJNI.paint(cryptoJNI.java:65)
    at sun.awt.RepaintArea.paint(Unknown Source)
    at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

  • JVM dies when JNI native code causes a SIGABRT from assertions

    Hi,
    I am wondering whether there is a way to prevent the JVM from dying when the JNI native code hits an assertion.
    #include "NativeTest.h"
    #include <assert.h>
    JNIEXPORT jstring JNICALL Java_NativeTest_sayHello (JNIEnv *env, jobject thisobject, jstring js)
    assert(0);
    return js;
    Calling this code from Java through JNI causes a SIGABRT when assert(0) is hit. This causes the java program to terminate. Is there a way for the JVM to recover from the SIGABRT from the native code?

    929919 wrote:
    I am wondering whether there is a way to prevent the JVM from dying when the JNI native code hits an assertion.There is no way to prevent the VM from exiting if native code does anything that causes an exit.
    An assertion is only one way that can happen.
    So to prevent the VM from exiting - don't run native code. The safe way to execute OS native library is to do the following.
    1. Wrap the library in an executable.
    2. Create a communications API for the executable.
    3. Manage the executable via Java Runtime.exec/ProcessBuilder.
    4. Talk to the executable using the communications API from 2 in the java code.
    The above is safe because if the library exits it exits the executable, not the VM.

  • Auto generate BP code

    I know this subject has been discussed in here several times and I have searched and tried several of theexamples. Can someone please tell me what is wrong with the following code as I receive error message internal error when I execute the FMS
    SELECT CASE WHEN OCRD.CardType = 'S' THEN 'V' ELSE 'C' END + CAST((MAX(CAST(RIGHT(T0.CardCode, (LEN(T0.CardCode)-1)) AS INT))+1) AS VARCHAR) FROM OCRD T0
    Thanks in advance for any help

    Keith,
    this is probably the solution for your problem from SAP notes :
    In order to create consecutive alphanumeric business partner codes, such as C1000, C1001 etc, please follow the procedure outlined below:
       1. Manually create the first customer, supplier and lead type business partners, e.g. C1000, S5000, L8000.
       2. Go to Reports -> Query Generator -> Click on 'Execute' without making any selection.
       3. In the 'Queries' window click on the pencil icon in the upper left area to activate the query structure area. The area appears grey when blocked, white when ready and yellow when active.
       4. Copy and paste the query from below or the attached text file (BPcode_autocreate.txt) into the window, replacing the 'SELECT *' that is present by default:
    select max(cardtype)
    + cast(substring( max(cardcode), 2, len(max(cardcode)))
    + 1 as nvarchar(10)) from ocrd
    where cardtype = $[OCRD.CARDTYPE]
       1. Click on the button 'Save',then, in the 'Save Query' window, enter an appropriate name for the query and select the appropriate category. Then click on 'Save'.
       2. Click on 'Cancel' in the window 'Queries' and 'Close' in the window 'Query Generator'.
       3. Go to Business Partners -> Business Partner Master Data, change to 'Add' mode.
       4. Map a formatted search to this field by either of the following means:
             1. Clicking in the field 'Code' to activate it, then select 'Tools' in the strip menu, select 'Search Function', then 'Define'.
             2. Pressing CtrlAltF2 in the active field.
       5. In the 'Define Formatted Search' window, click on the button for 'Search by Saved Query'
       6. Bring the cursor to the bar that will pop up just below 'Search by Saved Query' until it changes from an arrow to a pointing hand, then double-click.
       7. The 'Query Manager' window will pop up, select the category where the query above was saved under, then click on the query name to select it, click on 'OK'.
       8. Place a tick in the box for 'Auto Refresh When Field Changes' and select 'BP Name' from the drop down menu.
       9. Click on 'Cancel' in the Business Partner Master Data window and open it up again.
      10. Click on 'Refresh Regularly' and click on 'Save'.
      11. Change to 'Add' mode, select the 'Type' (Customer, Supplier, Lead) and enter a name for the new business partner. Press the 'Tab' key and the next available BP code will automatically be inserted into the BP code field.
    Rgds,

Maybe you are looking for