JNI_GetCreatedJavaVMs() returns 0 nVMs

Hello all
I am currently experiencing a very annoying problem.
I have a function CallJavaClient() that I need to call twice.
(See below for listing).
When I do the calls from within a console application, everything
works fine, but when I perform the calls from within a DLL (as required)
the second call of CallJavaClient() doesn't succeed.
The problem seems to stem from the call to JNI_GetCreatedJavaVMs().
This function always return nVMs == 0 when calling from the DLL.
So then the function JNI_CreateJavaVM() is called, which causes
the program to stop since a VM is running.
Can anyone suggest what might be going on here?
Thanks in advance
G
(JDK 1.2.2; JRE 1.3.1 / Hotspot; Windows NT/2000;)
static int CallJavaClient(
const char* tssServletURL,
const char* DTD_Spec,
const char* sessionID,
const char* requestID,
const char* userID,
const char* mechanismType,
const char* operationType,
const char* transactionData,
const char* signature,
const char* className,
const char* methodName,
const char* jvmOption_compilerMode,
const char* jvmOption_classPath,
const char* jvmOption_nativeLibPath,
const char* jvmOption_verboseMode,
char* tssString,
char* usrMessage)
int rc = SM_AUTHAPI_SUCCESS;
jint jvmCreate = 0;
JNIEnv* env = NULL;
JavaVM* jvm = NULL;
JavaVMInitArgs vm_args;
JavaVMOption options[4];
JavaVMAttachArgs attArgs;
jint res;
JavaVM* vmBuf[10];
jsize bufLen = 10;
jsize nVMs;
char jvmOptionParam_ComplierMode[128];
char jvmOptionParam_ClassPath[128];
char jvmOptionParam_NativeLibPath[128];
char jvmOptionParam_VerboseMode[128];
sprintf( jvmOptionParam_ComplierMode, "-Djava.compiler=%s", jvmOption_compilerMode );
sprintf( jvmOptionParam_ClassPath, "-Djava.class.path=%s", jvmOption_classPath );
sprintf( jvmOptionParam_NativeLibPath, "-Djava.library.path=%s", jvmOption_nativeLibPath );
sprintf( jvmOptionParam_VerboseMode, "-verbose:%s", jvmOption_verboseMode );
options[0].optionString = (char*) jvmOptionParam_ComplierMode;
options[1].optionString = (char*) jvmOptionParam_ClassPath;
options[2].optionString = (char*) jvmOptionParam_NativeLibPath;
options[3].optionString = (char*) jvmOptionParam_VerboseMode;
vm_args.version = JNI_VERSION_1_2;
vm_args.options = options;
vm_args.nOptions = 4;
vm_args.ignoreUnrecognized = TRUE;
attArgs.version = JNI_VERSION_1_2;
attArgs.name = NULL;
attArgs.group = NULL;
res = JNI_GetCreatedJavaVMs( vmBuf, bufLen, &nVMs );
printf( "JNI_GetCreatedJavaVMs() res = %d nVMs = %d\n", res, nVMs );
if (res < 0)
printf("No Java VM is created\n");
else if (nVMs == 1)
printf("A Java VM is already created.\n");
jvm = vmBuf[0];
else if (nVMs == 0)
// In JDK 1.2, there is no longer any need to call JNI_GetDefaultJavaVMInitArgs.
jvmCreate = JNI_CreateJavaVM( &jvm, (void**) &env, &vm_args );
if( jvmCreate < 0 )
sprintf( usrMessage, "Failed to create Java Virtual Machine. %d\n", jvmCreate );
rc = SM_AUTHAPI_FAILURE;
if( rc == SM_AUTHAPI_SUCCESS )
res = jvm->AttachCurrentThread( (void**) &env, &attArgs );
if (res < 0)
sprintf( usrMessage, "Can't attach current thread\n" );
rc = SM_AUTHAPI_FAILURE;
if( rc == SM_AUTHAPI_SUCCESS )
// Find class.method
jclass cls = env->FindClass( className );
// Catch Exception
if( cls != 0 )
jmethodID mid =
env->GetStaticMethodID( cls, methodName, "([Ljava/lang/String;)Ljava/lang/String;" );
      if( mid != 0 )
        jstring jstr = NULL;
        // Attempt to allocate an empty string object for later use
        if( ( jstr = env->NewStringUTF ("") ) != NULL )
          int numberOfArguments = sizeof( SM_AUTHAPI_JVM_ARGUMENT_LIST ) / sizeof( SM_AUTHAPI_JVM_ARGUMENT_LIST[0] );
jobjectArray args = env->NewObjectArray( numberOfArguments, env->FindClass("java/lang/String"), jstr );
env->SetObjectArrayElement( args, SM_AUTHAPI_JVM_ARGUMENT_INDEX_URL, env->NewStringUTF( tssServletURL ) );
env->SetObjectArrayElement( args, SM_AUTHAPI_JVM_ARGUMENT_INDEX_DTD, env->NewStringUTF( DTD_Spec ) );
env->SetObjectArrayElement( args, SM_AUTHAPI_JVM_ARGUMENT_INDEX_SESSIONID, env->NewStringUTF( sessionID ) );
env->SetObjectArrayElement( args, SM_AUTHAPI_JVM_ARGUMENT_INDEX_REQUESTID, env->NewStringUTF( requestID ) );
env->SetObjectArrayElement( args, SM_AUTHAPI_JVM_ARGUMENT_INDEX_USERID, env->NewStringUTF( userID ) );
env->SetObjectArrayElement( args, SM_AUTHAPI_JVM_ARGUMENT_INDEX_MECHANISMTYPE, env->NewStringUTF( mechanismType ) );
env->SetObjectArrayElement( args, SM_AUTHAPI_JVM_ARGUMENT_INDEX_OPERATIONTYPE, env->NewStringUTF( operationType ) );
env->SetObjectArrayElement( args, SM_AUTHAPI_JVM_ARGUMENT_INDEX_TRANSACTIONDATA, env->NewStringUTF( transactionData ) );
env->SetObjectArrayElement( args, SM_AUTHAPI_JVM_ARGUMENT_INDEX_SIGNATURE, env->NewStringUTF( signature ) );
// Call the Java method
//jstr = (jstring) env -> CallStaticObjectMethod( cls, mid, "c:\\tss\\testdata\\verify.xml", "http://nsmse80:450/servlet/verifysig" );
jstr = (jstring) env->CallStaticObjectMethod( cls, mid, args );
if( jstr != 0 )
// Java String to C++ char array (warning: error checking omitted)
const char* cstr = env->GetStringUTFChars( jstr, 0 );
strcpy( tssString, cstr );
env->ReleaseStringUTFChars( jstr, cstr );
env->DeleteLocalRef( jstr );
ParseTSSString( tssString, usrMessage );
rc = SM_AUTHAPI_SUCCESS;
else
sprintf( usrMessage, "Error retieving value from TSS\n" );
rc = SM_AUTHAPI_FAILURE;
else //if( ( jstr = env->NewStringUTF ("") ) == NULL )
sprintf( usrMessage, "Memory allocation error (jstr)\n" );
rc = SM_AUTHAPI_FAILURE;
else //if( mid == 0 )
sprintf( usrMessage, "Error calling static method %s\n", methodName );
rc = SM_AUTHAPI_FAILURE;
else
sprintf( usrMessage, "Can't find class %s\n", className );
rc = SM_AUTHAPI_FAILURE;
res = jvm->DetachCurrentThread();
printf( "DetachCurrentThread() res = %d\n", res );
res = JNI_GetCreatedJavaVMs( vmBuf, bufLen, &nVMs );
printf( "res = %d nVMs = %d\n", res, nVMs );
printf( "Calling DestroyJavaVM() ...\n" );
res = jvm->DestroyJavaVM();
printf( "DestroyJavaVM() res = %d nVMs = %d\n", res, nVMs );
else
sprintf( usrMessage, "Failed to create Java Virtual Machine. %d\n", jvmCreate );
rc = SM_AUTHAPI_FAILURE;
return( rc );

Not making the call to DestroyJavaVM() seems to solve the problem.

Similar Messages

  • JNI_GetCreatedJavaVMs not working

    I was trying to use the JNI_GetCreatedJavaVMs to work and it gives me an error within my C++ program:
    C:\Examples\Conversation\MSGpumper\MSGpumperDlg.cpp(193) : error C2039: 'JNI_GetCreatedJavaVMs' : is not a member of 'JNIEnv_'
    c:\jbuilder8\jdk1.4\include\jni.h(750) : see declaration of 'JNIEnv_'
    I have placed jvm.dll in my debug and jvm.lib in my source directory ...everything is linked correctly but it does't know what JNI_Get... is
    JavaVM * jvm;
         JNIEnv * env;
         jsize buflen;
         jsize * nVMs;
         env->JNI_GetCreatedJavaVMs(&jvm, buflen, nVMs);any suggestions?

    The error message tells you exactly what the problem is.
    The method is not part of the JNIEnv.
    Instead of
       env->JNI_GetCreatedJavaVMs(&jvm, buflen, nVMs);Use
       JNI_GetCreatedJavaVMs(&jvm, buflen, nVMs);

  • Using Swing as interface to a dll

    I am trying to use Swing as my cross platform GUI for c++ dll's. Each dll has its own GUI. However, one of my dll's controls what other dlls are loaded. This works fine until I try to load a second instance of the control dll. I get an access violation message when I try to update my gui. If I try to load the two dlls from the c++ everything works fine, but if I load one from the Java GUI I get an null access exception. I'm guessing its caused by one of two problems:
    1) The DLL loading is trashing the executing stack of either the JAVA or the native code.
    2) As the code returns from the constructor call to the newly loaded dll JNI is deleting the interface objects that it is creating on the heap.
    Any ideas would be greatly appreciated.
    Unfortunately I don't get an error log from JAVA.
    VisualStudio gives me:
    Unhandled exception at 0x10014a7d (nativedll.dll) in testjava.exe: 0xC0000005: Access violation reading location 0xfeeefef6.
    The print out reads:
    Creating Java VM
    No. Created VMs 0
    Creating Frame
    Created frame
    Begin master update loop
    Calling Update
    Updated Frame 0
    Creating Java VM
    No. Created VMs 1
    Creating Frame
    Created frame
    Calling Update
    I am using Visual Studio .Net 2003 and jdk 1.4.4, 1.5.0_08 and 1.6.0.
    Main application:
    #include "Windows.h"
    #include "nativelibrary.h"
    #include <stdlib.h>
    #include <string.h>
    #include "jni.h"
    int main(int argc, char* argv[])
           //Load first library
         HMODULE handle = LoadLibrary( "../../nativedll/debug/nativedll.dll");
         nativelibrary* (*funcPtr)();
         funcPtr = (nativelibrary*(*)())GetProcAddress( handle, "createObj");
         nativelibrary* newObj = (*funcPtr)();
            // update each library
         for (int i = 0; i < 10000; i++)
              printf ("Begin master update loop\n");
              void (*funcPtr2)();
              funcPtr2 = (void(*)())GetProcAddress( handle, "update");
              (*funcPtr2)();
              printf ("End master update loop\n");
              Sleep(10);
         // Sleep(100000);
         return 0;
    }Main Library
    #include <iostream>
    #include "jni.h"
    #include "MyFrame.h"
    #include "StaticFunc.h"
    #include <stdlib.h>
    #include <vector>
    #include "Windows.h"
    using namespace std;
    class nativelibrary
    public:
         JavaVM *jvm;
         JNIEnv *env;
         jclass cls;
         jobject myFrame;
         nativelibrary();
         void locupdate();
         static vector<nativelibrary*> objects;
    vector<nativelibrary*> nativelibrary::objects;
    nativelibrary* createObj()
         return new nativelibrary();
    nativelibrary::nativelibrary()
         // JavaVMOption options[0];
         JavaVMInitArgs vm_args;
         memset(&vm_args, 0, sizeof(vm_args));
         vm_args.version = JNI_VERSION_1_4;
         vm_args.nOptions = 0;
         vm_args.ignoreUnrecognized = true;
         vm_args.nOptions = 0;
         // vm_args.options = options;
         JavaVM** jvmBuf = (JavaVM**)malloc(sizeof(JavaVM*));
         jsize buflen = 1;
         jsize nVMs =0;
         // vm_args.options[0].optionString = "-Djava.class.path=../../bin/Debug";
         // Create the Java VM
         printf("Creating Java VM\n");
         jint res = JNI_GetCreatedJavaVMs(jvmBuf, buflen, &nVMs);
         if ( res >= 0)
              printf("No. Created VMs %i\n", nVMs);
              if ( nVMs > 0)
                   jvm = jvmBuf[0];
                   res = jvm->GetEnv((void**)&env,vm_args.version);
              else
                   res = JNI_CreateJavaVM(&jvm,(void**)&env,&vm_args);
         else
              res = JNI_CreateJavaVM(&jvm,(void**)&env,&vm_args);
         cls = env->FindClass("LMyFrame;");     
         if ( cls == 0 ) printf("Cannot find MyFrame");
         jmethodID mid = env->GetMethodID(cls, "<init>", "()V");
         if ( mid == 0 ) printf("Cannot find constructor");
         printf("Creating Frame\n");
         myFrame = env->NewObject(cls, mid);
         if (env->ExceptionOccurred())
              env->ExceptionDescribe();
         printf("Created frame\n");
         objects.push_back(this);
    void nativelibrary::locupdate()
         printf("Calling Update\n");
         jmethodID updatemid = env->GetMethodID(cls, "update", "()V");
         if ( updatemid == 0 ) printf("Cannot find update");
         env->CallVoidMethod(myFrame, updatemid);
         if (env->ExceptionOccurred())
              env->ExceptionDescribe();
    void update()
         vector<nativelibrary*>::iterator it = nativelibrary::objects.begin();
         while (it != nativelibrary::objects.end())
              nativelibrary* lib = *it;
              lib->locupdate();
              it++;
    JNIEXPORT void JNICALL Java_MyFrame__1createObj
      (JNIEnv *, jclass)
         createObj();
    }Java Class (User interface)
    class MyFrame
         static native void _createObj();
         static int creations = 0;
         int framenum;
         MyFrame()
              System.loadLibrary("../../nativedll/Debug/nativedll");
              framenum = creations++;
         void update()
              System.out.println("Updated Frame " + framenum);
              if ( creations == 1)
                   // load dll as a result of the user clicking on the interface
                   createObj();
         public static void createObj()
              _createObj();
    }

    I am trying to use Swing as my cross platform GUI for c++ dll's. Each dll has its own GUI. However, one of my dll's controls what other dlls are loaded. This works fine until I try to load a second instance of the control dll. I get an access violation message when I try to update my gui. If I try to load the two dlls from the c++ everything works fine, but if I load one from the Java GUI I get an null access exception. I'm guessing its caused by one of two problems:
    1) The DLL loading is trashing the executing stack of either the JAVA or the native code.
    2) As the code returns from the constructor call to the newly loaded dll JNI is deleting the interface objects that it is creating on the heap.
    Any ideas would be greatly appreciated.
    Unfortunately I don't get an error log from JAVA.
    VisualStudio gives me:
    Unhandled exception at 0x10014a7d (nativedll.dll) in testjava.exe: 0xC0000005: Access violation reading location 0xfeeefef6.
    The print out reads:
    Creating Java VM
    No. Created VMs 0
    Creating Frame
    Created frame
    Begin master update loop
    Calling Update
    Updated Frame 0
    Creating Java VM
    No. Created VMs 1
    Creating Frame
    Created frame
    Calling Update
    I am using Visual Studio .Net 2003 and jdk 1.4.4, 1.5.0_08 and 1.6.0.
    Main application:
    #include "Windows.h"
    #include "nativelibrary.h"
    #include <stdlib.h>
    #include <string.h>
    #include "jni.h"
    int main(int argc, char* argv[])
           //Load first library
         HMODULE handle = LoadLibrary( "../../nativedll/debug/nativedll.dll");
         nativelibrary* (*funcPtr)();
         funcPtr = (nativelibrary*(*)())GetProcAddress( handle, "createObj");
         nativelibrary* newObj = (*funcPtr)();
            // update each library
         for (int i = 0; i < 10000; i++)
              printf ("Begin master update loop\n");
              void (*funcPtr2)();
              funcPtr2 = (void(*)())GetProcAddress( handle, "update");
              (*funcPtr2)();
              printf ("End master update loop\n");
              Sleep(10);
         // Sleep(100000);
         return 0;
    }Main Library
    #include <iostream>
    #include "jni.h"
    #include "MyFrame.h"
    #include "StaticFunc.h"
    #include <stdlib.h>
    #include <vector>
    #include "Windows.h"
    using namespace std;
    class nativelibrary
    public:
         JavaVM *jvm;
         JNIEnv *env;
         jclass cls;
         jobject myFrame;
         nativelibrary();
         void locupdate();
         static vector<nativelibrary*> objects;
    vector<nativelibrary*> nativelibrary::objects;
    nativelibrary* createObj()
         return new nativelibrary();
    nativelibrary::nativelibrary()
         // JavaVMOption options[0];
         JavaVMInitArgs vm_args;
         memset(&vm_args, 0, sizeof(vm_args));
         vm_args.version = JNI_VERSION_1_4;
         vm_args.nOptions = 0;
         vm_args.ignoreUnrecognized = true;
         vm_args.nOptions = 0;
         // vm_args.options = options;
         JavaVM** jvmBuf = (JavaVM**)malloc(sizeof(JavaVM*));
         jsize buflen = 1;
         jsize nVMs =0;
         // vm_args.options[0].optionString = "-Djava.class.path=../../bin/Debug";
         // Create the Java VM
         printf("Creating Java VM\n");
         jint res = JNI_GetCreatedJavaVMs(jvmBuf, buflen, &nVMs);
         if ( res >= 0)
              printf("No. Created VMs %i\n", nVMs);
              if ( nVMs > 0)
                   jvm = jvmBuf[0];
                   res = jvm->GetEnv((void**)&env,vm_args.version);
              else
                   res = JNI_CreateJavaVM(&jvm,(void**)&env,&vm_args);
         else
              res = JNI_CreateJavaVM(&jvm,(void**)&env,&vm_args);
         cls = env->FindClass("LMyFrame;");     
         if ( cls == 0 ) printf("Cannot find MyFrame");
         jmethodID mid = env->GetMethodID(cls, "<init>", "()V");
         if ( mid == 0 ) printf("Cannot find constructor");
         printf("Creating Frame\n");
         myFrame = env->NewObject(cls, mid);
         if (env->ExceptionOccurred())
              env->ExceptionDescribe();
         printf("Created frame\n");
         objects.push_back(this);
    void nativelibrary::locupdate()
         printf("Calling Update\n");
         jmethodID updatemid = env->GetMethodID(cls, "update", "()V");
         if ( updatemid == 0 ) printf("Cannot find update");
         env->CallVoidMethod(myFrame, updatemid);
         if (env->ExceptionOccurred())
              env->ExceptionDescribe();
    void update()
         vector<nativelibrary*>::iterator it = nativelibrary::objects.begin();
         while (it != nativelibrary::objects.end())
              nativelibrary* lib = *it;
              lib->locupdate();
              it++;
    JNIEXPORT void JNICALL Java_MyFrame__1createObj
      (JNIEnv *, jclass)
         createObj();
    }Java Class (User interface)
    class MyFrame
         static native void _createObj();
         static int creations = 0;
         int framenum;
         MyFrame()
              System.loadLibrary("../../nativedll/Debug/nativedll");
              framenum = creations++;
         void update()
              System.out.println("Updated Frame " + framenum);
              if ( creations == 1)
                   // load dll as a result of the user clicking on the interface
                   createObj();
         public static void createObj()
              _createObj();
    }

  • Access Violation in CallStaticVoidMethod() using JNI

    Hey all,
    I have a C++ app which I successfully used about a year ago to put up a Java dialog from within QuarkXPress, which has a C/C++ API. I got it out and rebuilt it and ran it, and I am now getting an Access Violation (0xC0000005) exception in JVM.dll somewhere. I am getting the exception in the CallStaticVoidMethod() call. Here is the relevant snippet from the method I am using: if anyone can spot anything obviously amiss, I would appreciate knowing about it! (This snippet borrows heavily from the "invoke.c" example program in the JNI tutorial.)
      JavaVM *jvm;
      jint res;
      jclass cls;
      jmethodID mid;
      jthrowable except = NULL;
      JavaVMInitArgs vm_args;
      JavaVMOption options[2];
      char newcpath[512];
      char newlibpath[512];
      sprintf (newcpath, "-Djava.class.path=.;C:\\Program Files\\QuarkXpress 4.0\\XTENSION"); 
      sprintf (newlibpath, "-Djava.library.path=.;C:\\Program Files\\QuarkXpress 4.0\\XTENSION");
      options[0].optionString = newcpath;
      options[1].optionString = newlibpath;
      vm_args.version = 0x00010002;
      vm_args.options = options;
      vm_args.nOptions = 2;
      vm_args.ignoreUnrecognized = JNI_TRUE;
      /* Create the Java VM */
      res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
      if (res == JNI_EEXIST)
        JavaVM *jvms[1];
        jsize nVMs;
        res = JNI_GetCreatedJavaVMs(jvms, 1, &nVMs);
        jvm = jvms[0];
        jvm->AttachCurrentThread((void**)&env, NULL);
      else if (res < 0)
        return UNKNOWN_ERROR;
      cls = env->FindClass(g_javaName);
      if (cls == 0)
        checkException();
        destroy(jvm);
        return MISSING_CLASS;
      mid = env->GetStaticMethodID(cls, "main", "([Ljava/lang/String;)V");
      if (mid == 0)
        destroy(jvm);
        return MISSING_METHOD;
      env->CallStaticVoidMethod(cls, mid);

    Hi ,
    The method id that you get is for the public static void main(String args[]) of a class.
    mid = env->GetStaticMethodID(cls, "main", "([Ljava/lang/String;)V");  if (mid == 0)  
    destroy(jvm);   
    return MISSING_METHOD; 
    env->CallStaticVoidMethod(cls, mid);
    Change the above line to
    jstring jStringArgs[];
    env->CallStaticVoidMethod(cls, mid, jStringArgs);
    You need to pass an argument i.e. an array of jstring .
    It is immaterial that they possess valid value or not .
    LathaDhamo

  • AttachCurrentThread SEGV linux Itanium 64 Java 6

    I have a Java application which is core dumping. This application has a JNI component. The JNI component tries to attach a native thread to VM to do a call back to Java method. SEGC occurs while doing AttachCurrentThread. Here is a code snippet.
    JNIEnv *env;
    JavaVM *jvm_local;
    jsize nVMs;
    /* Get the JNI Env from the JVM */
    /* JNI_GetCreatedJavaVMs(JavaVM **vmBuf, jsize bufLen, jsize nVMs); /
    if(JNI_GetCreatedJavaVMs(&jvm_local, 1, &nVMs) != JNI_OK) return -1;
    (*jvm_local)->AttachCurrentThread(jvm_local, (void **)&env, NULL);
    Java dump
    # A fatal error has been detected by the Java Runtime Environment:
    # SIGSEGV (0xb) at pc=0x2000000000b30560, pid=7537, tid=2305843011812471424
    # JRE version: 6.0_17
    # Java VM: Java HotSpot(TM) 64-Bit Server VM (14.3-b01 mixed mode linux-ia64 )
    # Problematic frame:
    # V [libjvm.so+0x7dc560]
    # If you would like to submit a bug report, please visit:
    # http://java.sun.com/webapps/bugreport/crash.jsp
    --------------- T H R E A D ---------------
    Current thread (0x60000000002bf000): JavaThread "<no-name - thread is attaching>" [_thread_in_vm, id=7737, stack(0x200000009ae50000,0x200000009ae64000)]
    siginfo:si_signo=SIGSEGV: si_errno=0, si_code=2 (SEGV_ACCERR), si_addr=0x0000000000000030
    I looked at the core generated. See below:
    (gdb) where
    #0 0xa000000000010640 in __kernel_syscall_via_break ()
    #1 0x20000000001274b0 in raise () from /lib/tls/libc.so.6.1
    #2 0x2000000000129db0 in abort () from /lib/tls/libc.so.6.1
    #3 0x200000000115dff0 in os::abort ()
    from /strnas02/local/java/jdk1.6.0_17/jre/lib/ia64/server/libjvm.so
    #4 0x200000000143c540 in VMError::report_and_die ()
    from /strnas02/local/java/jdk1.6.0_17/jre/lib/ia64/server/libjvm.so
    #5 0x200000000116a720 in JVM_handle_linux_signal ()
    from /strnas02/local/java/jdk1.6.0_17/jre/lib/ia64/server/libjvm.so
    #6 0x200000000115adb0 in signalHandler ()
    from /strnas02/local/java/jdk1.6.0_17/jre/lib/ia64/server/libjvm.so
    #7 <signal handler called>
    #8 0x2000000000b30560 in frame::compiled_sender_sp ()
    from /strnas02/local/java/jdk1.6.0_17/jre/lib/ia64/server/libjvm.so
    #9 0x2000000000b334b0 in frame::sender ()
    from /strnas02/local/java/jdk1.6.0_17/jre/lib/ia64/server/libjvm.so
    #10 0x2000000000cfc230 in java_lang_Throwable::fill_in_stack_trace ()
    from /strnas02/local/java/jdk1.6.0_17/jre/lib/ia64/server/libjvm.so
    #11 0x2000000000cfc850 in java_lang_Throwable::fill_in_stack_trace ()
    from /strnas02/local/java/jdk1.6.0_17/jre/lib/ia64/server/libjvm.so
    #12 0x2000000000b17900 in Exceptions::throw_stack_overflow_exception ()
    from /strnas02/local/java/jdk1.6.0_17/jre/lib/ia64/server/libjvm.so
    #13 0x2000000000ce6f00 in JavaCalls::call_helper ()
    from /strnas02/local/java/jdk1.6.0_17/jre/lib/ia64/server/libjvm.so
    #14 0x2000000001157d40 in os::os_exception_wrapper ()
    from /strnas02/local/java/jdk1.6.0_17/jre/lib/ia64/server/libjvm.so
    #15 0x2000000000ce48d0 in JavaCalls::call ()
    from /strnas02/local/java/jdk1.6.0_17/jre/lib/ia64/server/libjvm.so
    #16 0x2000000000ce4ca0 in JavaCalls::call_special ()
    from /strnas02/local/java/jdk1.6.0_17/jre/lib/ia64/server/libjvm.so
    #17 0x2000000000ce5130 in JavaCalls::call_special ()
    from /strnas02/local/java/jdk1.6.0_17/jre/lib/ia64/server/libjvm.so
    #18 0x200000000138aee0 in JavaThread::allocate_threadObj ()
    from /strnas02/local/java/jdk1.6.0_17/jre/lib/ia64/server/libjvm.so
    #19 0x2000000000d00780 in attach_current_thread ()
    from /strnas02/local/java/jdk1.6.0_17/jre/lib/ia64/server/libjvm.so
    #20 0x2000000000d00c80 in jni_AttachCurrentThread ()
    from /strnas02/local/java/jdk1.6.0_17/jre/lib/ia64/server/libjvm.so
    #21 0x200000008b33bd30 in genericACFConnectionCallback (
    hdbc=0x60000000003b6bd0, param=0x0, foType=0, foEvent=1) at JdbcOdbc.c:4627
    #22 0x200000008b3ada40 in FailoverCallbackThread (a=0x600000000021cf60)
    at /ade/mardhana_him_gcia64linux1/timesten/VisiChannel/oc/src/vocctx.cpp:666
    #23 0x200000000006d7f0 in start_thread () from /lib/tls/libpthread.so.0
    #24 0x200000000026f9f0 in __clone2 () from /lib/tls/libc.so.6.1
    I see Exceptions::throw_stack_overflow_exception (). Is this a "reliable" indication that there was stack overflow? Here is the VM info:
    OS:Red Hat Enterprise Linux AS release 4 (Nahant Update 3)
    uname:Linux 2.6.9-34.0.1.0.11.EL #1 SMP Mon Dec 4 14:42:32 PST 2006 ia64
    libc:glibc 2.3.4 NPTL 2.3.4
    rlimit: STACK 16000k, CORE infinity, NPROC 16315, NOFILE 1024, AS infinity
    load average:1.37 1.24 1.23
    CPU:total 4 Itanium 2 Madison 9M, family 31 model 2 revision 1, lb
    Memory: 16k page, physical 8244064k(688096k free), swap 2097120k(2095872k free)
    vm_info: Java HotSpot(TM) 64-Bit Server VM (14.3-b01) for linux-ia64 JRE (1.6.0_17-b0405), built on Oct 14 2009 21:17:59 by "lab_ipfjbld" with gcc 4.2.0
    I will appreciate any pointers.
    With regards,
    mp

    jschell wrote:
    # SIGSEGV The most likely cause of that in an app with JNI code is a C/C++ pointer bug. That is followed by a misuse of an API (which is going to end up resolving to a pointer error too.)
    Pointer bugs do not necessarily produce immediate errors. They can cause the app to fail in unexpected ways almost anywhere after the point where the bug occurred. A common indicator of this is if the code changes or the execution through the code changes then a different bug (location) occurs.I suspected that "stack overflow" is not a good indicator (especially based on some of your older posts). I do not understand what you mean by -- That is followed by a misuse of an API (which is going to end up resolving to a pointer error too.). I am using the VM pointer and am attaching a native thread to it to call back into Java layer. Can you please elaborate on the misuse?
    Edited by: coffeeguy on Apr 8, 2010 1:11 PM
    Edited by: coffeeguy on Apr 8, 2010 1:27 PM

  • Attach native thread to JVM

    Hi,
    I use JNI to extend my Java class with some Windows specific functions.
    In the native code I have to check the value of a variable from Java and for this I created a new native thread.
    The documentation says that "the JNI interface pointer is valid only in current thread", so one must attach the new thread to the JVM in order to get a new interface pointer. But for attaching a thread to the JVM you need the ORIGINAL JNI INTERFACE POINTER. On the other hand, the documentation says that you "must not pass the interface pointer from one thread to another". So, I don't understand how to do it?
    Here is a sample from my code:
    JNIEXPORT jint JNICALL
    Java_com_cts__TestJNI_startTask(JNIEnv *env, jobject obj, jstring name)
    //creating a global reference
    jobject globalObj = env->NewGlobalRef(obj);
    //create the new thread
    hThread = CreateThread(NULL,
    0,
    (LPTHREAD_START_ROUTINE) WaitForStop,
    (LPVOID) env,//=>>> it mustn't be passed!
    0,
    &tid);
    //the thread method, which check the value of "status" field from Java
    void WINAPI WaitForStop(LPARAM lparam)
    JavaVM *jvm;
    JNIEnv *jenv;
    pInitData->lparam->env->GetJavaVM(&jvm);
    jint res = jvm->AttachCurrentThread((void**) &jenv, NULL);
    if (res < 0) {
    return;
    jclass jclasjni = jenv->GetObjectClass(globalObj);
    jfieldID jfid = jenv->GetFieldID( jclasjni, "status", "I");
    jint jstatus = 0;
    do
         Sleep(1000);
         jstatus = jenv->GetIntField(globalObj, jfid);
    } while (jstatus == 0);
    jvm->DetachCurrentThread();
    Is it correct the way I attached the thread?
    Because I don't quite understand this JNI interface pointer issue.
    Thanks in advance

    Ahhh - ha - got it working.
    Here is how I did it:
    dynamically link to the GetCreatedJavaVMs() function in the jni library (hJVM is the result of an earlier call to LoadLibrary):
         // type definitions for function addresses returned by loading jvm.dll
         typedef jint (JNICALL GetCreatedJavaVMs_t)( JavaVM**, jsize, jsize* );
         // function definitions for functions used in jvm.dll
         GetCreatedJavaVMs_t *GetCreatedJavaVMs;
         GetCreatedJavaVMs = (GetCreatedJavaVMs_t*)GetProcAddress( hJVM, "JNI_GetCreatedJavaVMs" );
         return GetCreatedJavaVMs( jvm, bufLen, nVMs);Get an appropriate instance on the JVM by called GetCreatedJavaVMs and pulling the first one. Once we have that, call AttachCurrentThread to get a JNIEnv pointer that we can use for doing work:
         JavaVM *jvm;
         JNIEnv *jenv;
         jint nSize = 1;
         jint nVms;
         jint nStatus = JAVAVM.GetCreatedJavaVMs( &jvm, nSize, &nVms );
         jint res = jvm->AttachCurrentThread((void**) &jenv, NULL);
        jclassStartup =
           jenv->FindClass(sStartupClass); // do some workWhen all done with the invocation, detach the jenv pointer from the current thread:
         jvm->DetachCurrentThread();Works like a charm.
    - K

  • JNI_GetCreatedJavaVMs always return zero

    Why does pfnGetCreatedJavaVMs(&jvmBuf, 1, &no_vms) always return 0(success) even though there is no created JVM?
    typedef jint (JNICALL GetCreatedJVMs_t)(JavaVM *vmBuf, jsize bufLen,jsize *nVMs);
    GetCreatedJVMs_t pfnGetCreatedJavaVMs=(GetCreatedJVMs_t)GetProcAddress(handle,"JNI_GetCreatedJavaVMs");
              JavaVM* jvmBuf=NULL;
              jsize no_vms=0;
              if(pfnGetCreatedJavaVMs(&jvmBuf, 1, &no_vms)==JNI_OK)
                   OutputDebugString("VM Found!! Trying to attach to it..");
                   jvm = &jvmBuf[0];
                   if(jvm!=NULL && no_vms!=0)
                        (*jvm).AttachCurrentThread((void **)&env, NULL);
              else{
                   OutputDebugString("Cannot find created VMs");
    /*****************************************************

    Here is sample code:
    if (m_vm == NULL){
         env->GetJavaVM(&mvm);
    jobj = env->NewGlobalRef(_jobj);
    m_vm->AttachCurrentThread((void **)&_env, NULL);
    jclass jcls = env->GetObjectClass(_jobj);
    jmethodID id = env->GetMethodID(_jcls, "OnRecvData", "(Ljava/lang/String;)V");
    jint jint = env->CallIntMethod(_jobj, id, jstr);

  • Materials Return to Vendor

    Hi All,
    How do I return Non valuated materials to a Vendor? (Without reference to a Purchase Order)
    Which movement type do I use and what transaction do i use?
    Thanks
    Adeel

    Hi Rahul,
    For booking in NVM (Free Materials)  i will be using movement type 511 as no financial postings are made using this movemnt type. For Returns, I will be creating a returns PO with Returns and Free Item Ticked. This again doesn't give any financial postings as doesn't expect an invoice and is perfect for what I am looking for.
    This has all been tested and works.
    Regards
    Adeel

  • Under what circumstances JNI_CreateJavaVM will return 0

    Hello all,
    Can any one please tell me "under what cicumstances JNI_CreateJavaVM returns 0" ?
    The following code segment returns 0.
    when I try to debug the code segment using VC++ 6.0. jdk 1.4.1 ON WINDOWS 2000 Prof. The debugger first shows status = -1 but once JNI_CreateJavaVM is executed the status changes to 0.
    // ----- code segment ----------------
    JavaVMOption options[3];
    JavaVMInitArgs vm_args;
    JavaVM *jvm;
    JNIEnv *env;
    options[0].optionString = "-Djava.compiler=NONE";
    options[1].optionString = "-Djava.class.path=CLASSPATH";
    options[2].optionString = "-verbose:jni";
    vm_args.version=JNI_VERSION_1_4;
    vm_args.options = options;
    vm_args.nOptions = 3;
    vm_args.ignoreUnrecognized = JNI_FALSE;
    int status = -1;
    status = (jint)JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
    if (status < 0)
    printf("\nERROR : Creating JVM with status : %d.\n");
    else if (status == JNI_ERR)
         printf("\nERROR : Creating Java Virtual Machine (JVM).\n");
    else if (status == 0)
    printf("\nJVM status is 0.\n\n");
    else
    printf("\nVM is created.");
    Please help I could not get any clue.
    Thanks.

    Hello folks,
    Now it is ok, it was not ststus=0 but it was some junk number
    forget it

  • [HP Photosmart C4480] Resetting NVM

    Hi, I've always been satisfied by this printer, simple to setup and really "plug and play". I recently started to print more often and suddenly, the printer complained about an "Incompatible cartridge".It was very weird because I was printing a 50 pages document and the error occured at the 9th or 10th page without any reason. I tried replacing the cartridge with another one, cleaning them up and rebooting the printer : no change.I googled the error message and found doing a "Semi-Full Reset" could help .. without success. I tried every combination at the "Enter Special Key Combo" and found several menus.I found some jokes like "Underware" and "Fix me!" (I love easter eggs) but also some very promising items like "clear nvm", several "disp xXx ID", "selftest", "counter", "enter serial number"... As my title suggests, my last attempt to solve my issue is to reset the NVM.Doing it should reset all parameters to their default value and the printer should return to the same state as when I bought it. The fact is that when I do "clear NVM", the printer displays the following message : "It is not default serial number. Failed to reset NVM".I checked the serial number printed on the back of the printer and compared it with what "serial number" (Information menu) displays.They match but the latter is longer and I don't know where the last 4 numbers come from. I found the menu which let me change the serial number but as I don't know what "default" serial to enter, I'm stuck. So I would like to know what serial number to input or more generally how to reset the non volatile memory of my printer.Should the instructions depends on the serial number of my printer, you can send me a PM. I hope my post is clear enough and may help other people solving this infamous "Incompatible cartridge" error.If you need more info, just let me know. Regards,

    I finally found an easy way to reset the NVM. I put an SD card in the printer, held on the Cancel (red X) and the Power Button and pressed the Blue, Grey and Green button (in that order) to have access to the "Underware" menu.There, I went into the "photo menu" and pressed OK on the "dump nvm=>file" item.I put the SD card in my laptop and edited the NVM_0001.DMP file (in the NVM2 folder) with an hexadecimal editor.I replaced every value by 0 so the NVM dump was full of zeroes.I renamed the file to NVM_RAW.DMP and put the SD card in the printer.I did the same as above to get access to the "photo menu" but instead of dumping the NVM to a file, I did the opposite with "dump file=>nvm". I restarted the printer and voilà! NB: It didn't solve the "Incompatible cartridge" issue but at least, internal counters are now at 0 !!

  • Can I return my laptop

    I bought my laptop around the beginning of March 2011. I am very dissatisfied with it and was wondering if I could bring it in for a refund.The computer is a Dell Inspiron. 

    I'm sorry, but you only have 14 days to return a laptop. You could send it in for repair if there is an issue with the device.
    I am a Bestbuy employee who volunteers on these boards on my own time. I am not paid for posting here, and you should understand that my opinions are exactly that - opinions. I do not represent Bestbuy in any way.
    : Open Mailbox

  • Return of Free goods item - Problem in item category

    I am trying to create return order of Free sample billing
    (ZFDP). The return order type for the free sample is ZFDR.
    We have specified Item category for the ZFDR is RENN (Free good item) in IMG Activity -> Assign Item categories.
    When I create order and save it, it prompts me to enter G/L Account.
    This material is free. It should not prompt G/L Account for it. There is no revenue recognition specified for the item category. I tried changing item category to ZKLN i.e Free of charge item. This item category does not prompt for G/L Account while creating order. but I can not use this item category because it prompts me for Avialability. I can not remove the Avaialabilty check for it because the same item category is used in the Free sample order where availability check is required
    In ZFDP order type, we are issuing 100% discount by using R100
    discount condition.  Please let me know how can I solve this problem.
    I think there is some problem in my item category itself. .
    My setting for Item category in IMG - Define item category is
    same for both ZKLN and RENN. Only difference is RENN has returns
    tick and pricing field is blank. In ZKLN pricing is defined as B- 100%
    discount. I also tried changing the pricing option of RENN to B.
    But still it is asking for G/L Account.
    I can not use ZKLN instead of RENN because my ZKLN is used in the
    Free item Sales order.
    Please help.
    Regards
    Saurabh Gothivrekar

    Hi
    I got answer to my query. YOu need to specify the bill type while defining sales document type. This bill type should not have account assignment mentioned in it.
    I changed the bill type, which does not have Account assignment procedure attached to it.
    It has solved my problem

  • Query help: query to return column that represents multiple rows

    I have a table with a name and location column. The same name can occur multiple times with any arbitrary location, i.e. duplicates are allowed.
    I need a query to find all names that occur in both of two separate locations.
    For example,
    bob usa
    bob mexico
    dot mexico
    dot europe
    hal usa
    hal europe
    sal usa
    sal mexico
    The query in question, if given the locations usa and mexico, would return bob and sal.
    Thanks for any help or advice,
    -=beeky

    How about this?
    SELECT  NAME
    FROM    <LOCATIONS_TABLE>
    WHERE   LOCATION IN ('usa','mexico')
    GROUP BY NAME
    HAVING COUNT(DISTINCT LOCATION) >= 2Results:
    SQL> WITH person_locations AS
      2  (
      3          SELECT 'bob' AS NAME, 'USA' AS LOCATION FROM DUAL UNION ALL
      4          SELECT 'bob' AS NAME, 'Mexico' AS LOCATION FROM DUAL UNION ALL
      5          SELECT 'dot' AS NAME, 'Mexico' AS LOCATION FROM DUAL UNION ALL
      6          SELECT 'dot' AS NAME, 'Europe' AS LOCATION FROM DUAL UNION ALL
      7          SELECT 'hal' AS NAME, 'USA' AS LOCATION FROM DUAL UNION ALL
      8          SELECT 'hal' AS NAME, 'Europe' AS LOCATION FROM DUAL UNION ALL
      9          SELECT 'sal' AS NAME, 'USA' AS LOCATION FROM DUAL UNION ALL
    10          SELECT 'sal' AS NAME, 'Mexico' AS LOCATION FROM DUAL
    11  )
    12  SELECT  NAME
    13  FROM    person_locations
    14  WHERE   LOCATION IN ('USA','Mexico')
    15  GROUP BY NAME
    16  HAVING COUNT(DISTINCT LOCATION) >= 2
    17  /
    NAM
    bob
    salHTH!
    Edited by: Centinul on Oct 15, 2009 2:25 PM
    Added sample results.

  • Unable to capture return values in web services api

    At the time of login to web services if my server is down ,
    it returns following error :
    java.lang.StringIndexOutOfBoundsException: String index out of range: -1
            at java.lang.String.substring(String.java:1438)
            at java.lang.String.substring(String.java:1411)
    I want to capture this error so that i can try another server to login. how do i capture this error
    Another place where i want to capture the return Value is when i look for a report on the server
    rh = boBIPlatform.get("path://InfoObjects/Root Folder/"src_folder"/" + reportName +
                               "@SI_SCHEDULEINFO,SI_PROCESSINFO" ,oGetOptions);
    oInfoObjects = rh.getInfoObjects();
    CrystalReport = (CrystalReport)oInfoObjects.getInfoObject(0);
    Here if the report is not there on the server , it returns a null handler exception.
    but if i try catching it by checking my responsehandler is null  like rh == null  it does not catch it.
    Any help will be appreciated
    thanks
    Rakesh Gupta

    Ted : i have two cases
    1)   server = server_st.nextToken();
        providerURL = "http://"server"/dswsbobje/services";
        sessConnURL = new URL(providerURL + "/session");
       Connection boConnection = new Connection(sessConnURL);
       Session boSession = new Session(boConnection);
      EnterpriseCredential boEnterpriseCredential = new    EnterpriseCredential();
                  boEnterpriseCredential.setLogin(userid);
      boEnterpriseCredential.setPassword(pwd);
      boEnterpriseCredential.setAuthType(auth);
    SessionInfo boSI = boSession.login(boEnterpriseCredential);
    I have got a list of servers running web servcies stored in my tokens. when i pass the first server name say " test:8080" and that server is down , i want to catch somewhere in the code above that it did not get the connection so that i can loop back and try with the second server say test1:8080
    This is for failover purposes.
    at present when i was trying to capture return value of boSI it  breaks giving the error
    java.lang.StringIndexOutOfBoundsException: String index out of range: -1
    at java.lang.String.substring(String.java:1438)
    at java.lang.String.substring(String.java:1411)
    2nd case :
    I am geeting reports from the server and scheduling them:
    i run the following code which works fine if reports is there
    rh = boBIPlatform.get("path://InfoObjects/Root Folder/"src_folder"/" + reportName +
    "@SI_SCHEDULEINFO,SI_PROCESSINFO" ,oGetOptions);
    oInfoObjects = rh.getInfoObjects();
    CrystalReport = (CrystalReport)oInfoObjects.getInfoObject(0);
    Here if  the  report  is not there on the server  then i should be able to catch from the response handle rh that it has got a null value.
    but rh does not return a null value 
    the code ultimately throws a null handle at the following line
    CrystalReport = (CrystalReport)oInfoObjects.getInfoObject(0);
    i am not able to catch the null value there also.
    hope you got my issue.

  • Generate prov.xml for Creative Cloud. Return Code 27

    We're trying to follow this guide (Creative Cloud Help | Using Adobe Provisioning Toolkit Enterprise Edition) to serialize a package (or something). We're stuck on generating prov.xml. My best attempt at an entry is:
    C:\Program Files (x86)\Common Files\Adobe\OOBE\PDApp\CCP\utilities\APTEE>adobe_prtk.exe --tool=VolumeSerialize --generate --serial=xxxx-xxxx-xxxx-xxxx-xxxx-xxxx --regsuppress=ss --eulasuppress --locales=en_US --provfilepath=C:\Program Fil
    es (x86)\Common Files\Adobe\OOBE\PDApp\CCP
    It says half of this is optional, but I'm skeptical.
    Anyway, I'm getting return code 27. This indicates that it is unable to edit the prov.xml file specified. I didn't specify a prov.xml file, I'm trying to make one. The syntax I'm using differs from what I found on the page I linked, as that was giving me syntax errors. I lifted this off someone else's code. I've tried just about every variation I can think of. Any help would be appreciated.
    This is on Windows

    One of these links may help
    http://helpx.adobe.com/creative-cloud/packager.html
    http://forums.adobe.com/community/download_install_setup/creative_suite_enterprise_deploym ent

Maybe you are looking for