Java 1.5 JNI and C++ exception

Hello, All
I've troubles with handling C++ exceptions using JNI and shared library. I'm using Java 1.5_06, RedHat 7.3 and JBoss 4.0.5
From Java class I call JNI a method in my shared library(libx.so) which calls a method in other shared library(liby.so). Liby.so uses Xerces library. During parsing process an exception occurs. But according to Xerces sources it's a normal behavior and should be caught. But instead I've got SIGNABRT in JVM and a core dump will created. What's wrong? Backtrace shows similar something:
XXXXX  __default_terminate() ....
XXXXX  __terminate() ....
XXXXX  __throws
XXXXX C++ method ..
XXXXX.....
XXXXX.....
XXXXX  JNI methodI found similar bugs reports in the forum. But they says about Java 1.4 version and according to bugs descriptions it should be already fixed.
Message was edited by:
kostik78

The question is closed. The root cause was incorrect building of shared library.

Similar Messages

  • 'Could not create' and 'Fatal exception' while installing Java

    Win7 64bit
    latest Firefox
    Java 7.10 64 and 32 bit
    Hello!
    Since weeks i have the following problem. Every time i want to install Java (62 or 64 bit), after the installation progress bar reached 100% and the windows closes i get 2 error messages, both containing the errors:
    'Could not create Java Virtual Machine' and
    'Fatal exception occured. Program will exit'
    After closing both error messages i get the 'Installation successful' screen of Java again.
    However, if i start firefox and go to a page requiring java (the official testing page for example), firefox freezes until i kill the process manually.
    So far i reinstalled Java repeatedly, cleaning every trace of it on my system before doing so, including entrys in the microsoft uninstall wizard and the registry entrys, as described here:
    +hkey_local_machine>software>microsoft>windows>currentversion>uninstall
    search for "java"
    delete entrys+
    what is the programms problem??
    edit: i cant acess java from the windows control panel either, i get the same error messages
    Edited by: 981351 on 11.01.2013 07:04

    I don't know that I'll be able to offer up any useful advice but here goes...
    Can you enable extra verbose logging as part of the installation & post the results here or on pastebin.com?
    jre-7u11-windows-i586.exe /l*vx c:\JavaInstall.log(feel free to adjust the log path to a more suitable location)
    All of our users are local admins and tend to install whatever. This leads to a messy environment and we don't always know which version of Java is installed. So, to address that, I created a small script that scours 'HKLM\software\microsoft\windows\currentversion\uninstall' for Java entries, reads the uninstall string then runs the reported uninstall string. The assumption here is that the uninstall string will be an MSI command. (All the machines & versions of Java used the same format.)
    This is a Windows 7 Enterprise (32-bit) environment, but the script also works on 64-bit installations of Windows 7 Enterprise.
    I've tested this with 7u11 and went as far back as 6u21. It should work with just about any version that uses MSI for uninstalling.
    @echo off
    setlocal enabledelayedexpansion
    echo. & echo Checking for Obsolete Versions of Java...
    for /f "usebackq tokens=*" %%a in (`reg query HKLM\software\microsoft\windows\currentversion\uninstall`) do (
         rem echo a is %%a
         for /f "usebackq tokens=2*" %%b in (`reg query "%%a" /v DisplayName 2^>nul ^| find /i "java"`) do (
              rem echo b is %%b
              rem echo c is %%c
              for /f "usebackq tokens=3,4" %%d in (`reg query "%%a" /v UninstallString 2^>nul`) do (
                   echo.     Removing %%c
                   rem echo d is %%d
                   rem echo e is %%e
                   set uninstallcmd=%%e
                   set uninstallcmd=!uninstallcmd:^/I=^/X!
                   rem %%d %%e /qb-
                   %%d !uninstallcmd! /qb-
    :end
    endlocal
    Standard Dislaimer:*
    Neither I nor the respective owners and/or maintainers of Oracle make representations about the suitability of this software for any purpose. This material is provided "as is", with absolutely no warranty of the attached items whatsoever, whether express, implied, or statutory, including, but not limited to, any warranty of merchantability or fitness for a particular purpose or any warranty that the contents of the item will be error-free. Any use is at your own risk. Blah blah blah.

  • How to open MSWORD using JAVA/JNI and write the database entries into WORD

    Hi..
    I am searching for java codes that uses JAVA NATIVE INTERFACE (JNI) for opening MSWORD 2003.
    To be brief.
    I created HTML form called Employee_data.
    if i click on Submit button a word document should be opened.This should be using JNI.
    I have also created a servlet in jsp to process the form data and store it into database(mysql).;
    Please help me to find the codes to open MSWORD on submit click and to write the database entries into word file.Can i get the full code for that.This is so urgent.
    Thanks in advance.

    Hi Suresh,
    The easest solution I can think of is to copy the math equation from the PowerPoint then paste in the Word document directly, there's actually no way to convert it to plain text, some equation is very complext, String variable is not suitable in this case.
    For example, this code works fine:
    var powerPoint = new Application { WindowState = PpWindowState.ppWindowMinimized };
    var oPresSet = powerPoint.Presentations;
    Microsoft.Office.Interop.PowerPoint._Presentation oPres = oPresSet.Open(@"C:\test.pptx", MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
    var strObj = oPres.Slides[1].NotesPage.Shapes[2].TextFrame2.TextRange.MathZones.get_MathZones();
    strObj.Copy();
    Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
    wordApp.Visible = true;
    Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Add();
    doc.Range(0, 0).Paste();
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • JVM Crash When Using JNI and COM

    I'm trying to call a DLL compiled from VB6 source code that I do not have access to. The VB6 code simply retrieves data from a DB2 database using ADO and my client code grabs that data and marshals it to my Java code. I'm attempting to achieve this using JNI and COM (without a third-party bridge). It works 75% of the time, but the other 25% of the time, the JVM crashes with the usual Hotspot crash log containing an access violation exception. However, I don't know what in my C++ code (VC++ 8) could be causing this except for passing a "wild" pointer to the code lying underneath the COM object interface. If that is the case, I don't know how I am doing that.
    The Java code that is calling my native method is running on Tomcat 5.5.25 and just to be safe, I am not allowing multiple threads to concurrently call the method in my JNI DLL (though I realize that this will kill performance). Once I can get past this problem, I'll do the COM interfacing on a worker thread in my native code so I don't screw up CoInitialize and CoUninitialize calls in the case the same thread is concurrently executing multiple calls to my native code.
    I've noticed that in most cases, the JVM crashes during my call to the pClsAccount->OpenConnection method. However, my DLL isn't what is listed on the top of the call stack, which is why I suspect the passing of a wild pointer, though I'm just taking a guess at that. Does anyone have an idea as to what's going on ?
    JNIEXPORT jobject JNICALL Java_CustomerInfo_nGetCustomerAccountInfo(JNIEnv *env, jobject customerInfo, jstring accountNumber, jstring iniFileName)
    jboolean isCopy;
    // Account info class and instance to be instantiated
    jclass accountInfoCls = NULL;
    jobject accountInfoObj = NULL;
    // The constructor ID of the accountInfoCls
    jmethodID ctorID = NULL;
    // Pointer to the interface for the ClsAccount COM object
    _clsAccount *pClsAccount = NULL;
    HRESULT hr;
    BSTR bstrIniFileName(L"");
    try
    const char *nativeAccountNumber = NULL;
    if (accountNumber != NULL)
    nativeAccountNumber = env->GetStringUTFChars(accountNumber, &isCopy);
    else
    jclass newExcCls;
    env->ExceptionDescribe();
    env->ExceptionClear();
    newExcCls = env->FindClass("java/lang/IllegalArgumentException");
    env->ThrowNew(newExcCls, "accountNumber passed in was null !");
    return NULL;
    // Initialization
    variantt varConnectionSucceeded = variantt(false);
    variantt varGetAccountInfoSucceeded = variantt(false);
    variantt varAccountNumber = variantt(nativeAccountNumber);
    bstrt bstrLastPaymentDate = bstrt();
    bstrt bstrLastErrorMessage = bstrt();
    bstrt bstrLastErrorNumber = bstrt();
    jlong jTotalDue = NULL;
    jlong jEstablishedDueDay = NULL;
    jlong jLastPaymentAmount = NULL;
    jstring jLastPaymentDate = NULL;
    jstring jLastErrorMessage = NULL;
    jstring jLastErrorNumber = NULL;
    jthrowable jException = NULL;
    const char *chLastPaymentDate = NULL;
    const char *chLastErrorMessage = NULL;
    const char *chLastErrorNumber = NULL;
    long long totalDue;
    long long lastPaymentAmount;
    long establishedDueDateDay;
    //Convert string from Java string to C string to VB string
    const char *nativeIniFileName = NULL;
    if (iniFileName != NULL)
    nativeIniFileName = env->GetStringUTFChars(iniFileName, &isCopy);
    else
    jclass newExcCls;
    env->ExceptionDescribe();
    env->ExceptionClear();
    newExcCls = env->FindClass("java/lang/IllegalArgumentException");
    env->ThrowNew(newExcCls, "iniFileName passed in was null");
    return NULL;
    bstrIniFileName = comutil::ConvertStringToBSTR(nativeIniFileName);
    CoInitialize(NULL);
    // Create an instance of the COClass with the interface over it
    hr = CoCreateInstance(__uuidof(clsAccount), NULL, CLSCTX_INPROC_SERVER, __uuidof(_clsAccount), (void **)&pClsAccount);
    if (hr == S_OK)
    varConnectionSucceeded.boolVal = pClsAccount->OpenConnection(&bstrIniFileName);
     
    if (varConnectionSucceeded.boolVal == -1)
    varGetAccountInfoSucceeded.boolVal = pClsAccount->GetAccountPaymentInformation(&(varAccountNumber.GetVARIANT()));
    env->ReleaseStringUTFChars(accountNumber, nativeAccountNumber);
    // Extract all available account information from the ClsAccount object
    if (varGetAccountInfoSucceeded.boolVal == -1)
    totalDue = pClsAccount->TotalDue.int64;
    establishedDueDateDay = pClsAccount->EstablishedDueDateDay;
    lastPaymentAmount = pClsAccount->LastPaymentAmount.int64;
    bstrLastPaymentDate = pClsAccount->LastPaymentDate;
    chLastPaymentDate = comutil::ConvertBSTRToString(bstrLastPaymentDate.GetBSTR());
    jTotalDue = (jlong)totalDue;
    jEstablishedDueDay = (jlong)establishedDueDateDay;
    jLastPaymentAmount = (jlong)lastPaymentAmount;
    jLastPaymentDate = env->NewStringUTF(chLastPaymentDate);
    delete[] chLastPaymentDate;
    pClsAccount->CloseConnection();
    // Populate error fields if any errors occur
    bstrLastErrorMessage = pClsAccount->LastErrMessage;
    chLastErrorMessage = comutil::ConvertBSTRToString(bstrLastErrorMessage.GetBSTR());
    bstrLastErrorNumber = pClsAccount->LastErrNumber;
    chLastErrorNumber = comutil::ConvertBSTRToString(bstrLastErrorNumber.GetBSTR());
    jLastErrorMessage = env->NewStringUTF(chLastErrorMessage);
    jLastErrorNumber = env->NewStringUTF(chLastErrorNumber);
    delete[] chLastErrorMessage;
    delete[] chLastErrorNumber;
    const char* clsName = "com/nuance/merchantsmutual/businessentities/CustomerAccountInfo";
    // Find the Java class and the ID of its constructor
    accountInfoCls = env->FindClass(clsName);
    ctorID = env->GetMethodID(accountInfoCls, "<init>", "(JJJLjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
    jException = env->ExceptionOccurred();
    if (jException != NULL)
    env->ExceptionDescribe();
    env->ExceptionClear();
    //Release all resources associated with the ClsAccount instance
    pClsAccount->Release();
    //Instantiate the class with the given parameters
    accountInfoObj = env->NewObject(accountInfoCls, ctorID, jTotalDue, jEstablishedDueDay, jLastPaymentAmount, jLastPaymentDate, jLastErrorMessage, jLastErrorNumber);
    jException = env->ExceptionOccurred();
    if (jException != NULL)
    env->ExceptionDescribe();
    env->ExceptionClear();
    else if (hr == REGDB_E_CLASSNOTREG)
    cout << "COM class not registered" << endl;
    else if ( hr == CLASS_E_NOAGGREGATION)
    cout << "COM class can't be aggregated" << endl;
    else if (hr == E_NOINTERFACE)
    cout << "No interface for COM class clsAccount" << endl;
    else if (hr == E_POINTER)
    cout << "*ppv pointer was NULL !" << endl;
    else
    cout << "Error occurred while creating COM object. HR is [" << hr << "]" << endl;
    // Free the BSTR because a new one was returned with a call to comutil::ConvertStringToBSTR
    SysFreeString(bstrIniFileName);
    // Release the string when it's no longer needed. MUST call if string won't be used
    // anymore or else a memory leak will occur
    env->ReleaseStringUTFChars(iniFileName, nativeIniFileName);
    CoUninitialize();
    &#12288;
    catch (_com_error &e)
    cout << "Encountered an exception in GetCustomerAccountInfo: Error was " << e.ErrorMessage();
    pClsAccount->Release();
    catch (...)
    pClsAccount->Release();
    return accountInfoObj;
    Edited by: Cthulhu76 on Jan 5, 2010 9:18 AM

    0x49202400 JavaThread "ContainerBackgroundProcessor[StandardEngine[Catalina]]" daemon [_thread_blocked, id=5340, stack(0x49bf0000,0x49c40000)]
    0x48a7e800 JavaThread "Thread-1" [_thread_in_native, id=5976, stack(0x48f00000,0x48f50000)]
    0x48a0dc00 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=3072, stack(0x48c60000,0x48cb0000)]
    0x48a09000 JavaThread "CompilerThread0" daemon [_thread_blocked, id=4988, stack(0x48c10000,0x48c60000)]
    0x48a07c00 JavaThread "Attach Listener" daemon [_thread_blocked, id=3124, stack(0x48bc0000,0x48c10000)]
    0x48a07000 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=2572, stack(0x48b70000,0x48bc0000)]
    0x489f5c00 JavaThread "Finalizer" daemon [_thread_blocked, id=5752, stack(0x48b20000,0x48b70000)]
    0x489f4c00 JavaThread "Reference Handler" daemon [_thread_blocked, id=2596, stack(0x48ad0000,0x48b20000)]
    0x003c6000 JavaThread "main" [_thread_in_native, id=4252, stack(0x00820000,0x00870000)]
    Other Threads:
    0x489f0400 VMThread [stack: 0x48a80000,0x48ad0000] [id=5624]
    0x48a18800 WatcherThread [stack: 0x48cb0000,0x48d00000] [id=1192]
    VM state:not at safepoint (normal execution)
    VM Mutex/Monitor currently owned by a thread: None
    Heap
    def new generation total 36288K, used 12762K [0x02940000, 0x050a0000, 0x07800000)
    eden space 32256K, 34% used [0x02940000, 0x0343af58, 0x048c0000)
    from space 4032K, 37% used [0x04cb0000, 0x04e2ba28, 0x050a0000)
    to space 4032K, 0% used [0x048c0000, 0x048c0000, 0x04cb0000)
    tenured generation total 483968K, used 7518K [0x07800000, 0x250a0000, 0x42940000)
    the space 483968K, 1% used [0x07800000, 0x07f57958, 0x07f57a00, 0x250a0000)
    compacting perm gen total 14080K, used 14016K [0x42940000, 0x43700000, 0x46940000)
    the space 14080K, 99% used [0x42940000, 0x436f0320, 0x436f0400, 0x43700000)
    No shared spaces configured.
    Dynamic libraries:
    0x00400000 - 0x0040f000      C:\Program Files\Apache Software Foundation\Tomcat 5.5\bin\tomcat5.exe
    0x7c800000 - 0x7c8c0000      C:\WINDOWS\system32\ntdll.dll
    0x77e40000 - 0x77f42000      C:\WINDOWS\system32\kernel32.dll
    0x77380000 - 0x77411000      C:\WINDOWS\system32\USER32.dll
    0x77c00000 - 0x77c48000      C:\WINDOWS\system32\GDI32.dll
    0x77f50000 - 0x77feb000      C:\WINDOWS\system32\ADVAPI32.dll
    0x77c50000 - 0x77cef000      C:\WINDOWS\system32\RPCRT4.dll
    0x76f50000 - 0x76f63000      C:\WINDOWS\system32\Secur32.dll
    0x77ba0000 - 0x77bfa000      C:\WINDOWS\system32\MSVCRT.dll
    0x7c8d0000 - 0x7d0cf000      C:\WINDOWS\system32\SHELL32.dll
    0x77da0000 - 0x77df2000      C:\WINDOWS\system32\SHLWAPI.dll
    0x76290000 - 0x762ad000      C:\WINDOWS\system32\IMM32.DLL
    0x77420000 - 0x77523000      C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.3790.3959_x-ww_D8713E55\comctl32.dll
    0x6d7c0000 - 0x6da10000      C:\Program Files\Java\jre1.6.0_07\bin\client\jvm.dll
    0x76aa0000 - 0x76acd000      C:\WINDOWS\system32\WINMM.dll
    0x7c340000 - 0x7c396000      C:\WINDOWS\system32\MSVCR71.dll
    0x6d270000 - 0x6d278000      C:\Program Files\Java\jre1.6.0_07\bin\hpi.dll
    0x76b70000 - 0x76b7b000      C:\WINDOWS\system32\PSAPI.DLL
    0x6d770000 - 0x6d77c000      C:\Program Files\Java\jre1.6.0_07\bin\verify.dll
    0x6d310000 - 0x6d32f000      C:\Program Files\Java\jre1.6.0_07\bin\java.dll
    0x6d7b0000 - 0x6d7bf000      C:\Program Files\Java\jre1.6.0_07\bin\zip.dll
    0x6d570000 - 0x6d583000      C:\Program Files\Java\jre1.6.0_07\bin\net.dll
    0x71c00000 - 0x71c17000      C:\WINDOWS\system32\WS2_32.dll
    0x71bf0000 - 0x71bf8000      C:\WINDOWS\system32\WS2HELP.dll
    0x71b20000 - 0x71b61000      C:\WINDOWS\system32\mswsock.dll
    0x5f270000 - 0x5f2ca000      C:\WINDOWS\system32\hnetcfg.dll
    0x71ae0000 - 0x71ae8000      C:\WINDOWS\System32\wshtcpip.dll
    0x76ed0000 - 0x76efa000      C:\WINDOWS\system32\DNSAPI.dll
    0x76f70000 - 0x76f77000      C:\WINDOWS\System32\winrnr.dll
    0x76f10000 - 0x76f3e000      C:\WINDOWS\system32\WLDAP32.dll
    0x76f80000 - 0x76f85000      C:\WINDOWS\system32\rasadhlp.dll
    0x4a6a0000 - 0x4a6ac000      C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\MMI\WEB-INF\lib\CustomerInfoProxy.dll
    0x77670000 - 0x777a9000      C:\WINDOWS\system32\ole32.dll
    0x77d00000 - 0x77d8b000      C:\WINDOWS\system32\OLEAUT32.dll
    0x7c420000 - 0x7c4a7000      C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.4053_x-ww_E6967989\MSVCP80.dll
    0x78130000 - 0x781cb000      C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.4053_x-ww_E6967989\MSVCR80.dll
    0x777b0000 - 0x77833000      C:\WINDOWS\system32\CLBCatQ.DLL
    0x77010000 - 0x770d6000      C:\WINDOWS\system32\COMRes.dll
    0x77b90000 - 0x77b98000      C:\WINDOWS\system32\VERSION.dll
    0x75da0000 - 0x75e5d000      C:\WINDOWS\system32\SXS.DLL
    0x75e60000 - 0x75e87000      C:\WINDOWS\system32\apphelp.dll
    0x4dc30000 - 0x4dc5e000      C:\WINDOWS\system32\msctfime.ime
    0x4b0d0000 - 0x4b395000      C:\WINDOWS\system32\xpsp2res.dll
    0x71bb0000 - 0x71bb9000      C:\WINDOWS\system32\WSOCK32.dll
    0x4bbe0000 - 0x4bbea000      C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\MMI\WEB-INF\lib\ClearTranProxy.dll
    0x745e0000 - 0x7489e000      C:\WINDOWS\system32\msi.dll
    0x71c40000 - 0x71c97000      C:\WINDOWS\system32\NETAPI32.dll
    0x4bc50000 - 0x4bc6c000      C:\WINDOWS\system32\DBNETLIB.DLL
    0x71f60000 - 0x71f64000      C:\WINDOWS\system32\security.dll
    0x76c90000 - 0x76cb7000      C:\WINDOWS\system32\msv1_0.dll
    0x76cf0000 - 0x76d0a000      C:\WINDOWS\system32\iphlpapi.dll
    0x761b0000 - 0x76243000      C:\WINDOWS\system32\crypt32.dll
    0x76190000 - 0x761a2000      C:\WINDOWS\system32\MSASN1.dll
    0x4bcf0000 - 0x4bcff000      C:\Program Files\Common Files\System\Ole DB\SQLOLEDB.RLL
    0x4a8a0000 - 0x4a8aa000      C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\MMI\WEB-INF\lib\MIGI.DLL
    0x73570000 - 0x736c2000      C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\MMI\WEB-INF\lib\MSVBVM60.DLL
    0x4a950000 - 0x4a9e2000      C:\Program Files\Common Files\System\ado\msado15.dll
    0x74a50000 - 0x74a6a000      C:\WINDOWS\system32\MSDART.DLL
    0x4c850000 - 0x4c8c9000      C:\Program Files\Common Files\System\Ole DB\oledb32.dll
    0x4dbb0000 - 0x4dbc1000      C:\Program Files\Common Files\System\Ole DB\OLEDB32R.DLL
    VM Arguments:
    jvm_args: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 5.5 -Dcatalina.base=C:\Program Files\Apache Software Foundation\Tomcat 5.5 -Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\endorsed -Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat 5.5\temp -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\logging.properties -Djava.library.path=C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\MMI\WEB-INF\lib vfprintf -Xms512m -Xmx1024m
    java_command: <unknown>
    Launcher Type: generic
    Environment Variables:
    JAVA_HOME=C:\Program Files\Java\jdk1.6.0_07
    [error occurred during error reporting (printing environment variables), id 0xc0000005]
    --------------- S Y S T E M ---------------
    OS: Windows Server 2003 family Build 3790 Service Pack 2
    CPU:total 4 (4 cores per cpu, 1 threads per core) family 6 model 7 stepping 6, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3
    Memory: 4k page, physical 2097151k(2097151k free), swap 4194303k(4194303k free)
    vm_info: Java HotSpot(TM) Client VM (10.0-b23) for windows-x86 JRE (1.6.0_07-b06), built on Jun 10 2008 01:14:11 by "java_re" with MS VC++ 7.1
    time: Mon Dec 28 15:24:00 2009
    elapsed time: 600 seconds

  • JNI and Out of Memory errors

    Hi,
    At my job, we seem to have a memory leak related to JNI. We know we
    have a memory leak because we keep getting Out of Memory errors even
    after increasing the maximum heap size to more than 256 megs. And we
    know that this is the application that is eating up all the system
    memory.
    We are running under Windows 2000, with both JDK 1.3.0 and JDK 1.4.1.
    We tried looking at the problem under JProbe, but it shows a stable
    Java heap (no problems, except that the Windows task manager shows it
    growing and growing...)
    I tried a strip down version, where I set the max heap size to 1 Meg,
    and print out the total memory, memory used, and maximum memory used at
    a 5 sec interval.
    Memory used = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory().
    Well, I let that strip down version running for about a day. The
    maximum memory used has stabilized to about 1.1 Meg, and has not
    increased. The current memory used increases until it gets to some
    threshold, then it decreases again. However, the Windows task manager
    shows the memory increasing -- and currently it is at 245 Megs!
    In the lab, the behavior we see with the Windows task manager is as
    follows:
    1. Total memory used in the system increases until some threshold.
    2. Then it goes back down by about 100 Megs.
    3. This cycle continues, but at each cycle the memory goes back down
    less and less, until the app crashes.
    Now, our theory is that JNI is consuming all this memory (maybe we are
    using JNI wrong). That's the only explanation we can come up with to
    explain what we have seen (Java showing an OK heap, but the task
    manager showing it growing, until crashing).
    Does that make sense? Can the new operator throw an Out of Memory
    error if the system does not have enough memory to give it, even if
    there is still free heap space as far as the Runtime object is
    concerned? Does the Runtime object figures objects allocated through
    JNI methods into the heap used space?
    Note that I know the task manager is not a reliable indicator.
    However, I don't think a Java app is supposed to runaway with system
    memory -- the problem is not simply that the Java app is consuming too
    much memory, but that it seems to always want more memory. Besides, we
    do get the Out of Memory error.
    Thanks for your help,
    Nicolas Rivera

    Hi,
    there are two sources of memory leakage in JNI:
    - regular leaks in c/c++ code;
    - not released local/global references of java objects in JNI.
    I think that the first issue in not a problem for you. The second is more complex. In your JNI code you should check
    - how many local references alive you keep in your code as their number is restricted (about 16 and can be enlarged). The good style is not to store local references but keep only global.
    - any local reference accepted from java call in JNI are released by JVM. You should release local references you created in JNI and also global references.
    - do not use a large number of java object references. Each new reference gets new memory in JVM. Try to reuse refences.
    I guess that is your problem.
    Vitally

  • Problems creating a Java Array using JNI-HELP!

    Hi,
    I am trying to create a Java Array using JNI.I have posted the code below. The problem is that the oth element is added correctly to the Array but when the JVM gets to the next element...it goes for a toss. It is not able to create a new instance of the object in GetUGEntity() function...there seems to be some problem in creating a new instance of the object!
    Can somebody help me with this?
    jobject GetUGEntity(JNIEnv *env, UF_DISP_j3d_entity_t* entity_list)
         int numVerts=0, numStrips=0;
         jfieldID fid;
         jdoubleArray jTransform=NULL;
         jstring jstrName=NULL;
         jdoubleArray jNormals=NULL;
         //Init an Entity object
         cout<< "**Getting New Class Reference...";
         jclass jEntity = env->FindClass("Lcom/wipro/java3d/rmi/Entity;");
         cout << "**got Class reference..."<<endl;
         if (jEntity == NULL)
              return NULL;
         cout<<"Creating new object instance...";
         jmethodID mIDInit = env->GetMethodID(jEntity, "<init>", "()V");
         cout<<"Got java method id...";
         jobject javaObj = env->NewObject(jEntity, mIDInit);
         if (javaObj==NULL)
              return NULL;
         cout << "Created!" << endl;
         //Entity ID
         cout<< "**Setting eid...";
         fid=env->GetFieldID(jEntity,"eid","I");
         jint eid = (jint)(entity_list)->eid;
         env->SetIntField(javaObj, fid, eid);
         //env->DeleteLocalRef(eid);
         cout << "Done!" << endl;
         cout << "Done!" << endl;
         cout<< "**Returning jobject...";
         return javaObj;
    jobjectArray createJArray(JNIEnv* env, UF_DISP_j3d_entity_t** entity_list, int noOfEntities )
         UF_DISP_j3d_entity_t* tempVar=NULL;
         cout<<"*Creating Jobjectarray...";
         jobjectArray jEntityArray = (jobjectArray) env->NewObjectArray(noOfEntities,
              env->FindClass("Lcom/wipro/java3d/rmi/Entity;"),NULL);
         cout<<"Created!"<<endl;
         for(int i=0; i<noOfEntities;++i)
              tempVar = &(*entity_list);
              if (tempVar !=NULL)
                   cout<<"*Trying to get Entity...."<<endl;
                   jobject jEntity = GetUGEntity(env, tempVar);
                   if (jEntity!= NULL)
                        cout<<"Got Entity!" <<endl;
                        cout <<"*Setting Array Element....";
                        env->SetObjectArrayElement(jEntityArray, i, jEntity);
                        cout << "Done!" << endl;
                   else
                        printf("ERROR: Did not get Entity Reference");
              else
                   printf("ERROR: Got a NULL Reference!");
         return jEntityArray;

    Hi Deepak,
    Could you please let us know upto which line your code is going safe. Try printing the value in the structure before you send that to the method GetUGEntity().
    I am not too sure that would be a problem. But I have faced a problem like this, wherein I tried to access a structure for which I have not allocated memory and hence got exception because of that.
    Since your JNI code seems to be error free, I got doubt on your C part. Sorry.
    Dhamo.

  • How can i call a VB6 project from my java application using JNI

    hi
    can anyone tell me the procedure of calling a VB6 project from any java application using JNI
    if anyone does know then tell me the detail procedure of doing that. I know that i have to create a dll of that VB6 project then to call it from the java application.
    if anyone know that procedure of creating dll file of an existing VB6 project please reply
    please if anyone know then let me know

    Ahh, kind of a duplicate thread:
    http://forums.java.sun.com/thread.jspa?threadID=631642
    @OP. You could have clarified your original post and the relationship of your question to java. You did not need a new thread.
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Java mapping of application triggered an exception

    Hi,
    We have ascenario where a vendor will be sending us a cXML file which has the second line as <!DOCTYPE cXML SYSTEM "http://xml.cxml.org/schemas/cXML/1.2.009/InvoiceDetail.dtd">. If I open it in XMLSpy, it is saying the file as invalid. XI is unable to map this file. So we decided to remove that line using Java mapping and then do the regular graphical mapping.
    I took the java code from the SAP note 812966 and used the aii_map_api.jar, dom.jar, jaxp-api.jar to create the class of that java file and used that class file by importing that into XI as a jar file.
    I'm getting this error in the request message mapping of SXMB_MONI
    <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
      <SAP:Category>Application</SAP:Category>
      <SAP:Code area="MAPPING">STREAM_TRANSFORMATION_EX</SAP:Code>
      <SAP:P1>mypackage/DeleteDTDDeclarationWithDOM</SAP:P1>
      <SAP:P2>Failed to load resource from the context classloa~</SAP:P2>
      <SAP:P3 />
      <SAP:P4 />
      <SAP:AdditionalText />
      <SAP:ApplicationFaultMessage namespace="" />
      <SAP:Stack>Java mapping of application triggered an exception</SAP:Stack>
      <SAP:Retry>M</SAP:Retry>
      </SAP:Error>
    I'm new to this java mapping, Can you please provide me some details about what files need to be loaded into the XI along with the class file.
    Appreciate you help.
    Thanks,
    MT.

    Hi Prateek,
    Thanks for your quick reply. Yes I have downloaded the aii_map_api.jar from <SAP_install_dir>/<system_name>/<instance_name>/j2ee/cluster/server<number>/apps/sap.com/com.sap.xi.services/
    And also I have compiled my java code using the dom.jar, sax.jar, jaxp-api.jar and aii_map_api.jar.
    I took the class file of my javacode and all the class files of the above mentioned jar files and prepared one single jar file, which I imported into XI.
    It is not allowing me to make a single jar of the actual class file and all the supporting jar files.
    What is the actual method of doing it.
    Appreciate all your help. Thanks very much.
    Thanks,
    Maulik.

  • Java update (3 days ago) won't let me play yahoo games anymore.  I've tried moving java security to Medium and adding web address as "permissive use".  Still nothing.  I'd really like a fix.   Really, apple?  What's your beef with yahoo games?

    Installed Java update three days ago.  Now, can't play yahoo games as it's now blocked by security settings.  Already have tried moving Java security to Medium and adding yahoo.games.com (including web address of game) as a "Permissive exception".   Also tried removing java and installing older version.  Still nothing.  Really Apple?!?  What's your beef with yahoo games? 

    csnorth,
    all of the older update versions of Java SE 7 can be found here. If 7u45 also didn’t work with your Yahoo! games, you can choose from any of the even older versions there as well.

  • JNI and J2ME

    Hello all. These days i've been asked to make a little aplication for a PDA and while looking for information about j2me it says jni its not supported. But the app i need to make needs to use some library written in C, and my question is if there is any way o making an application in j2me that can use those libraries.
    Thanks all.

    Yes i've found a compiler for my target platform and compiling and running the C libraries doesnt seem a problem at the time. My main problem is that I can't call them from my java application because jni is not supported and i dont know how to import them.
    Thanks for your answer
    Message was edited by:
    trospito

  • Java, access database( mdb) and java.sql.date

    I having a problem querying my access database with user specified date the code is as follows
    //get results of income from database with respectto dates
         //so u first create the sql.date instances
         private void getResults(){
         String text1=from.getText();//text input is like this 01-01-2005
              String text2=to.getText();
         Date d1=new Date(Integer.parseInt(text1.substring(6)),Integer.parseInt(text1.substring(3,5)),Integer.parseInt(text1.substring(0,2)));
         JOptionPane.showMessageDialog(this,d1.toString());//traces date with 1900 added to year and 1 added to month
         try{
              //custom class DataSource used to connect to database
              Connection conn=DataSource.getConnection("RealFotoInc");
              PreparedStatement ps=conn.prepareStatement("select * from Members where date=?");
              ps.setDate(1,d1);
              ResultSet rs=ps.executeQuery();
              while(rs.next()){
                   System.out.println("going");
                   System.out.println("trial"+rs.getString(3));
         }catch(Exception se){
              JOptionPane.showMessageDialog(this,se);
         }and it prints out nothing I dont know what is wrong

    Whoever put that comment in there about "1900" and so on knew what had to be done. That "Date" class must be "java.sql.Date"; go and read the API documentation of that constructor you are using there. Then adjust the parameters you are passing to it accordingly.

  • Can not locate Java class using JNI within C++ DLL

    I am using trying to use JNI to call a Java class from C++. The Java class uses JMS to send messages to a JMS message queue. At first I coded the C++ in a console application that created the JavaVM and used JNI to access the Java class. All worked fine. Then I called the Java class using JNI from threads and ran into the problem of the Java class not able to locate the JMS related classes. This was solved by placing the following line in the constructor of the Java class.
    Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
    Then I moved the JNI code from a console application to a DLL in specific an extension DLL that is called by SQL Server or Oracle server. The DLL will use JNI to call the Java class and send messages to a JMS message queue.
    The problem I am having now when the DLL code is called by SQL Server the call to
    JNI_CreateJavaVM
    appears to work correctly but the call to find the Java class using
    jvmEnv->FindClass(pName)
    fails. It appears the is a class loading problem which occurs due to the fact JNI is called from a DLL. When the VM is created I pass the class path information using the statement
    -Djava.class.path=
    And as I stated before it all works when running from a console application. I am new to JNI and really need help in the form of some sample code that will solve this problem. I believe I need to somehow load the classpath information from the DLL but I can not find examples on how to do this using JNI. I have tried several ways using URLClassLoader and getSystemClassLoader from JNI and either it does not work or it crashes very badly.
    I used the following code to determine what the existing class path is and the string returns empty.
    jcls = jvmEnv->FindClass("java/lang/System");
    jmid = jvmEnv->GetStaticMethodID(jcls, "getProperty", "(Ljava/lang/String;)Ljava/lang/String;");
    jstrClassPath = jvmEnv->NewStringUTF("java.class.path");
    jstr = (jstring)jvmEnv->CallStaticObjectMethod(jcls, jmid, jstrClassPath);
    m_jstr = (jstring)jvmEnv->NewGlobalRef(jstr);
    pstr = jvmEnv->GetStringUTFChars(m_jstr, 0);
    Can anyone please help with example code that will solve this problem. Thanks in advance for any help.
    Charles�

    I have determined the problem occurs when the application/component is compiled using VC 6.0. The test application was compiled using VC 7.1 and works correctly by locating the class path information. If the test application is compiled using VC 6.0 it has the same problem.
    The jvm.dll I am using is version 1.4.2.80. Currently this is not an option to compile all the applications that use JNI using VC 7.1 so can someone please tell me how to solve this problem.

  • Java Audio Metronome | Timing and Speed Problems

    Hi all,
    I’m starting to work on a music/metronome application in Java and I’m running into some problems with the timing and speed.
    For testing purposes I’m trying to play two sine wave tones at the same time at regular intervals, but instead they play in sync for a few beats and then slightly out of sync for a few beats and then back in sync again for a few beats.
    From researching good metronome programming, I found that Thread.sleep() is horrible for timing, so I completely avoided that and went with checking System.nanoTime() to determine when the sounds should play.
    I’m using AudioSystem’s SourceDataLine for my audio player and I’m using a thread for each tone that constantly polls System.nanoTime() in order to determine when the sound should play. I create a new SourceDataLine and delete the previous one each time a sound plays, because the volume fluctuates if I leave the line open and keep playing sounds on the same line. I create the player before polling nanoTime() so that the player is already created and all it has to do is play the sound when it is time.
    In theory this seemed like a good method for getting each sound to play on time, but it’s not working correctly.
    At the moment this is just a simple test in Java, but my goal is to create my app on mobile devices (Android, iOS, Windows Phone, etc)...however my current method isn’t even keeping perfect time on a PC, so I’m worried that certain mobile devices with limited resources will have even more timing problems. I will also be adding more sounds to it to create more complex rhythms, so it needs to be able to handle multiple sounds going simultaneously without sounds lagging.
    Another problem I’m having is that the max tempo is controlled by the length of the tone since the tones don’t overlap each other. I tried adding additional threads so that every tone that played would get its own thread...but that really screwed up the timing, so I took it out. I would like to have a way to overlap the previous sound to allow for much higher tempos.
    I posted this question on StackOverflow where I got one reply and my response back explains why I went this direction instead of preloading a larger buffer (which is what they recommended). In short, I did try the buffer method first, but I want to also update a “beat counter” visual display and there was no way to know when the hardware was actually playing the sounds from the buffer. I mentioned that on StackOverflow and I also asked a couple more questions regarding the buffer method, but I haven’t received any more responses.
    http://stackoverflow.com/questions/24110247/java-audio-metronome-timing-and-speed-problems
    Any help getting these timing and speed issues straightened out would be greatly appreciated! Thanks.
    Here is my code...
    SoundTest.java
    import java.awt.*; 
    import java.awt.event.*; 
    import javax.swing.*; 
    import javax.swing.event.*; 
    import java.io.*; 
    import javax.sound.sampled.*; 
    public class SoundTest implements ActionListener { 
        static SoundTest soundTest; 
        // ENABLE/DISABLE SOUNDS 
        boolean playSound1  = true; 
        boolean playSound2  = true; 
        JFrame mainFrame; 
        JPanel mainContent; 
        JPanel center; 
        JButton buttonPlay; 
        int sampleRate = 44100; 
        long startTime;  
        SourceDataLine line = null;  
        int tickLength; 
        boolean playing = false; 
        SoundElement sound01; 
        SoundElement sound02; 
        public static void main (String[] args) {        
            soundTest = new SoundTest(); 
            SwingUtilities.invokeLater(new Runnable() { public void run() { 
                soundTest.gui_CreateAndShow(); 
        public void gui_CreateAndShow() { 
            gui_FrameAndContentPanel(); 
            gui_AddContent(); 
        public void gui_FrameAndContentPanel() { 
            mainContent = new JPanel(); 
            mainContent.setLayout(new BorderLayout()); 
            mainContent.setPreferredSize(new Dimension(500,500)); 
            mainContent.setOpaque(true); 
            mainFrame = new JFrame("Sound Test");                
            mainFrame.setContentPane(mainContent);               
            mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
            mainFrame.pack(); 
            mainFrame.setVisible(true); 
        public void gui_AddContent() { 
            JPanel center = new JPanel(); 
            center.setOpaque(true); 
            buttonPlay = new JButton("PLAY / STOP"); 
            buttonPlay.setActionCommand("play"); 
            buttonPlay.addActionListener(this); 
            buttonPlay.setPreferredSize(new Dimension(200, 50)); 
            center.add(buttonPlay); 
            mainContent.add(center, BorderLayout.CENTER); 
        public void actionPerformed(ActionEvent e) { 
            if (!playing) { 
                playing = true; 
                if (playSound1) 
                    sound01 = new SoundElement(this, "Sound1", 800, 1); 
                if (playSound2) 
                    sound02 = new SoundElement(this, "Sound2", 1200, 1); 
                startTime = System.nanoTime(); 
                if (playSound1) 
                    new Thread(sound01).start(); 
                if (playSound2) 
                    new Thread(sound02).start(); 
            else { 
                playing = false; 
    SoundElement.java
    import java.io.*; 
    import javax.sound.sampled.*; 
    public class SoundElement implements Runnable { 
        SoundTest soundTest; 
        // TEMPO CHANGE 
        // 750000000=80bpm | 300000000=200bpm | 200000000=300bpm 
        long nsDelay = 750000000; 
        long before; 
        long after; 
        long diff; 
        String name=""; 
        int clickLength = 4100;  
        byte[] audioFile; 
        double clickFrequency; 
        double subdivision; 
        SourceDataLine line = null; 
        long audioFilePlay; 
        public SoundElement(SoundTest soundTestIn, String nameIn, double clickFrequencyIn, double subdivisionIn){ 
            soundTest = soundTestIn; 
            name = nameIn; 
            clickFrequency = clickFrequencyIn; 
            subdivision = subdivisionIn; 
            generateAudioFile(); 
        public void generateAudioFile(){ 
            audioFile = new byte[clickLength * 2]; 
            double temp; 
            short maxSample; 
            int p=0; 
            for (int i = 0; i < audioFile.length;){ 
                temp = Math.sin(2 * Math.PI * p++ / (soundTest.sampleRate/clickFrequency)); 
                maxSample = (short) (temp * Short.MAX_VALUE); 
                audioFile[i++] = (byte) (maxSample & 0x00ff);            
                audioFile[i++] = (byte) ((maxSample & 0xff00) >>> 8); 
        public void run() { 
            createPlayer(); 
            audioFilePlay = soundTest.startTime + nsDelay; 
            while (soundTest.playing){ 
                if (System.nanoTime() >= audioFilePlay){ 
                    play(); 
                    destroyPlayer(); 
                    createPlayer();              
                    audioFilePlay += nsDelay; 
            try { destroyPlayer(); } catch (Exception e) { } 
        public void createPlayer(){ 
            AudioFormat af = new AudioFormat(soundTest.sampleRate, 16, 1, true, false); 
            try { 
                line = AudioSystem.getSourceDataLine(af); 
                line.open(af); 
                line.start(); 
            catch (Exception ex) { ex.printStackTrace(); } 
        public void play(){ 
            line.write(audioFile, 0, audioFile.length); 
        public void destroyPlayer(){ 
            line.drain(); 
            line.close(); 

    Thanks but you have never posted reply s0lutions before ?? And F 4 is definitely not 10 times faster as stated before I upgraded !!

  • JNI and Threads Crashes

    Hi,
    I am creating a Java app using JNI to call C++ libraries a vendor has provided for us. I used a pointer upon instantiation of the C++ object, store it in the Java side, and when I need to call a method in C, would de-reference that pointer to make function call.
    This works well in a standalone Java application. However, when I use a thread to call this object, or a servlet, it will get as far as letting me make one function call in C, but other calls afterwards will cause a core dump.
    Anyone experience this before? Please share any insight you might have. Thanks in advance.
    -Justin
    Here's the code:
    =======================================
    #include <jni.h>
    #include <iostream.h>
    #include "com_jni_JNIDSM_0005fServer.h"
    #include "DSMC_Server.h"
    //Java side: public static int cObjectID
    static jobject cls = 0;
    static jfieldID fid;
    * Class: JNIDSM_0005fServer
    * Method: DSM_Server
    * Signature: ()I
    * Create an instance of this object and return a reference handler (pointer).
    * REQUIRED: Need to call this method first before DSM_Server object can be used.
    JNIEXPORT jint JNICALL Java_com_jni_JNIDSM_1Server_DSM_1Server
    (JNIEnv* p_env, jobject p_obj)
    DSMC_Server* server;
    server = new DSMC_Server();
    cout << "ServerPtr Created = " << (jint)server << endl;
    Java_com_jni_JNIDSM_1Server_setCID(p_env, p_obj, (jint) server);
    return ((jint) server);
    * Class: JNIDSM_0005fServer
    * Method: connect
    * Signature: (Ljava/lang/String;ILjava/lang/String;I)I
    * Create connection from the DSM Client to the Server. Pass in host & port of Server and
    * name assigned to the module of the DSM Client.
    JNIEXPORT jint JNICALL Java_com_jni_JNIDSM_1Server_connect
    (JNIEnv* p_env, jobject p_obj, jstring p_host, jint p_port, jstring p_serverModuleName)
    // Obtain pointer reference to corresponding DSM objects
    DSMC_Server* serverPtr = (DSMC_Server*)
    Java_com_jni_JNIDSM_1Server_getCID (p_env, p_obj);
    // Convert the Java String to a Char pointer for use
    cout << "ServerPtr in JNI_connect() begin = " << (jint) serverPtr << endl;
    jboolean isModCopy, isHostCopy;
    const char* host = p_env->GetStringUTFChars(p_host, &isHostCopy);
    const char* serverModuleName = p_env->GetStringUTFChars(p_serverModuleName, &isModCopy);
    // Call the DSM_Server object's Connect() function
    jint status = (*serverPtr).Connect (host, p_port, serverModuleName);
    // Clean up object allocation for string copy after method is done
    if (isHostCopy == JNI_TRUE)
    p_env->ReleaseStringUTFChars(p_host, host);
    if (isModCopy == JNI_TRUE)
    p_env->ReleaseStringUTFChars(p_serverModuleName, serverModuleName);
    cout << "ServerPtr in JNI_connect() after = " << (jint) serverPtr << endl;
    return status;
    * Class: JNIDSM_0005fServer
    * Method: disconnect
    * Signature: (I)V
    * Disconnect from the Server.
    JNIEXPORT void JNICALL Java_com_jni_JNIDSM_1Server_disconnect
    (JNIEnv* p_env, jobject p_obj)
    // Obtain pointer reference to corresponding DSM objects
    DSMC_Server* serverPtr = (DSMC_Server*)
    Java_com_jni_JNIDSM_1Server_getCID (p_env, p_obj);
    cout << "ServerPtr in disconnect = " << (jint) serverPtr << endl;
    // Call the DSM_Server object's Disconnect() function
    (*serverPtr).Disconnect();
    * Class: JNIDSM_0005fServer
    * Method: doHeartbeat
    * Signature: (I)I
    * Check the status of the Server. Return status code that tells the caller Server' status.
    JNIEXPORT jint JNICALL Java_com_jni_JNIDSM_1Server_doHeartbeat
    (JNIEnv* p_env, jobject p_obj, jint p_serverPtr)
    // Obtain pointer reference to corresponding DSM objects
    DSMC_Server* serverPtr = (DSMC_Server*)
    Java_com_jni_JNIDSM_1Server_getCID (p_env, p_obj);
    // Call the DSM_Server object's DoHeartbeat() function
    jint status = (*serverPtr).DoHeartbeat();
    return status;
    * Class: JNIDSM_0005fServer
    * Method: getMaxPacketSize
    * Signature: (I)I
    * Return the packet size that are being sent through this network connection.
    JNIEXPORT jint JNICALL Java_com_jni_JNIDSM_1Server_getMaxPacketSize
    (JNIEnv* p_env, jclass p_class)
    // Obtain pointer reference to corresponding DSM objects
    DSMC_Server* serverPtr = (DSMC_Server*)
    Java_com_jni_JNIDSM_1Server_getCID (p_env, p_obj);
    // Call the DSM_Server object's GetMaxPacketSize() function
    jint packetSize = (*serverPtr).GetMaxPacketSize();
    return packetSize;
    * Class: com_jni_JNIDSM_0005fServer
    * Method: getCID
    * Signature: ()J
    JNIEXPORT jlong JNICALL Java_com_jni_JNIDSM_1Server_getCID
    (JNIEnv* p_env, jobject p_obj)
         jclass clazz;
         clazz = p_env->GetObjectClass(cls);
         fid = p_env->GetStaticFieldID(clazz, "cObjectID", "J");
    jint id = p_env->GetStaticLongField(clazz, fid);
    cout << "ServerPtr retrieved w/ getCID = " << id << endl;
    return id;
    * Class: com_jni_JNIDSM_0005fServer
    * Method: setCID
    * Signature: (J)V
    JNIEXPORT void JNICALL Java_com_jni_JNIDSM_1Server_setCID
    (JNIEnv* p_env, jobject p_obj, jint p_hndlr)
         jclass clazz;
         //create global reference
         if (cls == 0) {
              clazz = p_env->GetObjectClass(p_obj);
              if (clazz == 0) {
    cout << "Error occurred while getting class ref..."<< endl;
              cls = p_env->NewGlobalRef(p_obj);
              if (cls == 0) {
    cout << "Error occurred trying to create Global ref..."<< endl;
              fid = p_env->GetStaticFieldID(clazz, "cObjectID", "J");
         } else
              clazz = p_env->GetObjectClass(cls);
    p_env->SetStaticLongField(clazz, fid, p_hndlr);
    cout << "ServerPtr saved in setCID = " << p_hndlr << endl;
    }

    Thanks Tom for your help.
    After further debugging and trying new ideas, it turns out to be something really weird within the actual C++ object. I did a very basic execution to just connect and disconnect from the server all within one function. Even with one function call, it would crash. I'm going back to the vendor to let them figure it out.
    I've done my own examples of allocating dynamic arrays, setting & getting values, then deallocating it. There were no problems with threads then.
    I know I'm not going wacky, hopefully not, but who knows. Thanks again.
    Here's the simple code that crashed within a Java thread:
    void SomeJNIFunction(<params>) {
    jboolean isModCopy, isHostCopy, isAppCopy;
    const char* host = p_env->GetStringUTFChars(p_sHost, &isHostCopy);
    const char* sModuleName = p_env->GetStringUTFChars(p_sModName, &isModCopy);
    const char* sAppName = p_env->GetStringUTFChars(p_sAppName, &isAppCopy);
    jint status = 0;
    DSMC_Server serverPtr;
    DSMC_Event eventPtr;
    cout << "In JNI, ready to connect. Host=" << host << "|ModName=" << sModuleName
    << "|AppName=" << sAppName << endl;
    // connection attempt
    status = serverPtr.Connect (host, p_iPort, sModuleName);
    cout << "(JNI) Connected ..." << endl;
    //*************crash!!!!!!!********
              serverPtr.Disconnect();
    }

  • Compile and Runtime Exceptions

    Hi all,
    What are Compile-time Exceptions and Runtime Exceptions.
    and by the way,
    What are Checked Exceptions and Unchecked Exceptions
    Thanks in advance

    http://java.sun.com/docs/books/tutorial/essential/exceptions/index.html
    There isn't really such a thing as a "compile time excepitons." "Exceptions" are when something goes wrong at runtime. You can, of course, get compilation errors because your code doesn't follow Java's syntactical rules, but we don't call those exceptions.
    And of course, if your compiler is written in Java, then compile time for you is runtime for the compiler. (The compiler is a Java program that's running.) So it could throw an exception. But that's not your code.

Maybe you are looking for

  • Help needed(urgent)

    hi all, happy belated dusshera to all, check the code . i have problem that i am not getting offsetting item after clicking my 2nd radio button. by clicking on this i am getting datathat is aslo reqired but alon with it i should get offsetting item d

  • How can I filter data by row contents? Similar to Excel's filter feature.

    I would like to view only the rows in which the data in column x is some particular value. For instance, I'd like to view (and create a group of channels) containing only data from rows where the text in column 2 is MC1. ... guess I can't put a pictu

  • JMS Sender reconnect

    Hi, I´m using the JMS adapter as a Sender and want to know how the connection to the MQ is done. If i.ex. the external MQ is shut down for maintenance - how does the the JMS adapter in SAP XI reconnect when the MQ is up again? Do we need to deactivat

  • How do Firefox 28 and Internet Explorer 11 features compare against each other?

    I need a head-to-head comparison of these two browsers. Firefox 26 and IE 9 would be acceptable as well, if the first two have not been out long enough to get a comparison history.

  • No songs now in i-tunes library but all still on i pod

    help dont know what has happened cant play any songs on i tunes, all still on i pod. on i tunes still has song names but most with ! beside it. i cant locate these songs as they are empty. any help or suggestions would be appreciated thansk pter