Problem with Jni on Solaris

Hello I am using a Native code that is working perfect on Windows .
I have used DllMain calls to initialize my threads .
I attach my lower stack threads to the JNI by using these methods.
Well I want to know what is way to put the same functionality on Solaris.As this particular method is specific to Windows Platform only.
BOOL APIENTRY DllMain( HANDLE hModule,                     // handle to DLL module
DWORD ul_reason_for_call,      // reason for calling function
LPVOID lpReserved                // reserved
     BOOL returnValue = FALSE;
switch (ul_reason_for_call)
          case DLL_PROCESS_ATTACH:
               // We do not perform any initialization
               // within this section. Instead we have
               // chosen to use the JNI_OnLoad function
               // as the library initialization point.
               returnValue = TRUE;
               break;
          case DLL_THREAD_ATTACH:
               // We are to initialize the thread local storage
               // variables in this call.
               if( BridgeUtility::getInstance() -> threadInitialize() != 0 ) {
                    returnValue = FALSE;
                    printf(" Thread initialize failed..\n");
               }else {
                    printf(" Thread initialize succed..\n");
                    returnValue = TRUE;
               break;
          case DLL_THREAD_DETACH:
               // We are to uninitialize the thread local storage
               // variables in this call.
               if( BridgeUtility::getInstance() -> threadUninitialize() != 0 )
                    returnValue = FALSE;
               else
                    returnValue = TRUE;
               break;
          case DLL_PROCESS_DETACH:
               // We do not perform any uninitialization
               // within this section. Instead we have
               // chosen to use the JNI_OnUnload function
               // as the library initialization point.
               returnValue = TRUE;
               break;

If your aim is to load the library and initialize it
that one time, consider using the pthread once routines
to handle library initialization. See, for example,
chapter 5 of Butenhof's "Programming with POSIX
threads".

Similar Messages

  • Problem with IPSec on  solaris 9

    Hi all
    I'm facing a problem with IPSec on solaris 9 that I didn't have with Solaris 8 (With the Security package installed).
    I've an application that creates SA's by using the pf-key interface.
    What it does is first doing a GETSPI to a specific SPI and a specific Destination IP Address.
    This will create an SA and put it in a LARVAL state. After about a minute my application will do an UPDATE to this SPI and that command should change the state of the SA from LARVAL to MATURE but instead I get an error saying that this SPI & IP address already exist (errno = 17).
    Well of course it's already exist that's the all point it should just change the state of an existing SA.
    This exact scenarion was is working fine on Solaris 8.
    Am I doing somthing wrong (maybe there is a package on the solaris 9 that I need to install ?)
    or is this a bug in solaris 9.
    If anyone has any idea on how to do that (without using a one step ADD for a new SA) I will be very thankfull.

    Sorry for using reply for querying.
    I got a problem in creating a Security Association using the PF_KEY Socket (first used SADB_GETSPI and got SPI,with SPI tried to update SADB_UPDATE).
    Getting this problem on Sun Solaris 8.
    It returns errno 122 . operation not supported.
    Here is my mailId [email protected]
    I got few more queries regarding PF_KEY socket.
    Not much directions are available also for pf_key socket in internet.
    Monitor produces the following error.
    # ipseckey monitor
    "Base message (version 2) type UPDATE, SA type AH.
    Error Operation not supported on transport endpoint from PF_KEY.
    Message length 16 bytes, seq=4294967294, pid=450."
    Here is my mailId [email protected]
    Thanks in Advance.
    ssundar.

  • Awkward problems with JNI on J2SE 5.0

    I'm experiencing a strange problem with JNI and I hope someone can help me out.I've installed Cygwin, MinGW and then the CDT plug-in for Eclipse C/C++ development. This means I've used the MinGW make utility. It successfully creates the DLL file, but for some awkward reason, function www_tutorial_jni_HelloWorld_displayHelloWorld cannot be found (UnsatisfiedLinkError: displayHelloWorld).
    The Java class looks like this:
    package www.tutorial.jni;
    public class HelloWorld {
        public native void displayHelloWorld();
        static {
            System.loadLibrary("hello");
        public static final void main(String[] args) {
             try {
                  HelloWorld hw = new HelloWorld();
                  hw.displayHelloWorld();
             } catch (Exception e) {
                  System.out.println(e.toString());
    }The header that was generated by javah.exe (version 1.5.0_01) looks like this:
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class www_tutorial_jni_HelloWorld */
    #ifndef _Included_www_tutorial_jni_HelloWorld
    #define _Included_www_tutorial_jni_HelloWorld
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class:     www_tutorial_jni_HelloWorld
    * Method:    displayHelloWorld
    * Signature: ()V
    JNIEXPORT void JNICALL
    Java_www_tutorial_jni_HelloWorld_displayHelloWorld
      (JNIEnv *, jobject);
    #ifdef __cplusplus
    #endif
    #endifThe C++ implementation looks like this:
    #include <jni.h>
    #include "www_tutorial_jni_HelloWorld.h"
    #include <stdio.h>
    JNIEXPORT void JNICALL
    Java_www_tutorial_jni_HelloWorld_displayHelloWorld(JNIEnv
    *env, jobject obj)
        printf("Hello world!\n");
        return;
    }I've made sure that the fully qualified name of the implementation function is identical to the one in the header. I don't understand why I still get the error; especially since checking the DLL reveals that a function called "Java_www_tutorial_jni_HelloWorld_displayHelloWorld" exists.
    Could someone try and produce a successfull DLL/SO from the C++ code and then try and run the Java part on a 5.0 version of Java? I'm really curious as to what on Earth is going on...

    ... Otherwise, I would have
    to add whatever directory I put my DLL into to the
    PATH variable.Not necessarily. I believe the "PATH" also implicitly includes the "current directory". I also think that most JNI users put their DLL in a directory from which they also launch java (so it's in the current directory).
    >
    ... a java.library.path set.
    If I don't explicitly set a Java library path,
    Eclipse can't even find the DLL. I'm beginning to
    believe that Eclipse somehow screws up running Java
    programs with native code...I don't know about that... Probably just something extra you have to do with your Eclipse project so that it can find the DLL.
    But like I said, I don't really know - just trying to throw out ideas, small as they may be.

  • Problem with JNI and Parallel Port dll

    Hi. I'm doing some testes with JNI. Firs i followed the netbeans tutorial for doing a C programa that prints somthing for java.. like.. "Hello java from C".
    So i tried to load a dll from my dll. Like, I have this dll to use the parallel port on windows Xp. So i created a dll to access it an comunicates eoth java.
    I did everything just fine.
    When I start my Java app, the first thing it does is to load this parallel port dll and configure the functions of it.
    After that .. I get this error
    EXCEPTION_FLT_STACK_CHECK (0xc0000092) at pc=0x0093d269, pid=2284, tid=3000
    Can someone explain why ?
    (Sorry if i wasn't clear enough, english is not my native language, so ask if you don't understand something.. )

    hi ,
    I met the same problem this morning, and searched the www.google.com in order to solve it, as a result, your article was shown on my screen. :)
    Till now I have read some technical information and solved my problems. Maybe the solution be useful to you:
    ==============================
    error message : (Environment : Tomcat 5, Windows 2003, Mysql5)
    2006-3-29 11:53:48 org.apache.catalina.core.StandardWrapper unload
    message: Waiting for 2 instance(s) to be deallocated
    ==============================
    cause: the number of connection to database exceeded.another word,too many connections.
    ==============================
    solution: close the connection when it becomes useless for your program. :)
    ==============================
    ps. Sorry for my weak English . hehe ....

  • Problem with JNI hello world

    I found some tutorial on SUN site on how to use JNI. I'm using Eclipse to compije Java and C (via Cygwin) files. Here are complete files:
    Hello.java:
    class Hello
         public native void sayHello();
         static
              try
              System.loadLibrary("hello");
              catch(Exception e)
                   System.out.println("exc");
         public static void main(String[] args)
              Hello h = new Hello();
              h.sayHello ();
    }Hello.c:
    #include <mingw/_mingw.h> //because there are some types needed for JNI
    #include <jni.h>
    #include "Hello.h"
    #include <stdio.h>
    JNIEXPORT void JNICALL Java_Hello_sayHello
      (JNIEnv *env, jobject obj)
         printf("Hello world!\n");
         return;
    }Makefile:
    hello.dll : Hello.o Hello.def
         gcc -g -shared -Wl,--kill-at -o hello.dll Hello.o hello.def
    Hello.o : Hello.c Hello.h
         gcc -c -g -I"$(JAVA_HOME)\include" -I"$(JAVA_HOME)\include\win32" Hello.c -o Hello.o
    Hello.h : Hello.class
         javah -jni Hello
    clean :
         rm Hello.h
         rm Hello.o
         rm hello.dllHello.def
    EXPORTS
    Java_Hello_sayHelloEverything goes well, but when I run java program it does nothin (it should print message, but it just exit without any error).I'm sure that it's something stupid, but I cant see what. Can anyone tell me what am I doing wrong?
    Thenks.

    Answer 1: yes, there was no problem. I compiled and started simple 'hello world' program from Cygwin and from WinXP console, and it worked well.
    Answer 2: This is weird, I changed code to this:
    Hello.java:
         public native int getInt();
              System.out.println("Returned int is " + h.getInt());Hello.c:
    JNIEXPORT jint JNICALL Java_Hello_getInt
      (JNIEnv *env, jobject obj)
         return 25;
    }It does not print anything. I started this program from Cygwin and from WinXP console, and from Eclipse. Only if I debug in Eclipse (step by step) I get:
    Returned int is 25and still I don't get Hello string printed (even if I go step by step). It looks like cygwin has some problem with OS. Do you have any idea what to do, I'm a bit confused?
    Thank you.
    Message was edited by:
    zly

  • Problem with JNI for target armlinux

    Dear friends,
    We have compiled CVM for ARM Linux and it is working fine for java programs as well as C programs.
    But when I try to make shared library out of a sample hello world JNI program for arm linux it says 'jni.h: No such file or directory' and after that many lines 'syntax error' and 'parse error' etc.
    But the same program is running fine on x86 linux. Problem only while cross compiling for arm linux. It is not problem with arm-v5t-le-gcc because that is working fine. Problem is with what I need to include in makefiles.
    As I am new to this domain could anyone help me where I am missing?
    Regards
    Kishore

    I'm not exactly sure what you're talking about, but it sounds like you may need to look into global references. Look at NewGlobalRef() and DeleteGlobalRef() and see if those help you out.
    God bless,
    -Toby Reyelts
    For all your JNI woes, check out Jace - http://jace.reyelts.com/jace

  • Problem with JNI

    i have to implement a few standard APIs. As a part of the implementation I have to provide references to an object I create. Now my underlying code is C++ with JNI used to throw the Java APIs. Problem is JNI now returns different references for the same object and hence my prupose id defeated. Could anyone suggest how this problem can be overcome.

    I tried to figure out what your problem is, but can't. Please rephrase it and give a bit more detail on what you are doing and what is going wrong.

  • Problem with jni references

    i have to implement a few standard APIs. As a part of the implementation I have to provide references to an object I create. Now my underlying code is C++ with JNI used to throw the Java APIs. Problem is JNI now returns different references for the same object and hence my prupose id defeated. Could anyone suggest how this problem can be overcome.

    I'm not exactly sure what you're talking about, but it sounds like you may need to look into global references. Look at NewGlobalRef() and DeleteGlobalRef() and see if those help you out.
    God bless,
    -Toby Reyelts
    For all your JNI woes, check out Jace - http://jace.reyelts.com/jace

  • Problem with JNI form C++

    Hi all,
    I'm fairly new to programming with JNI, so please excuse me if I ask a dumb question.
    I'm trying to call a Java method from a C++ class, but when I run the program, it throws an error, crashing the program. I'm pretty sure the problem is that the call to env->getMethodID() is throwing an error. I have looked around to try and find a way call a function with no arguments, but all of the examples that I have found all call a Java main.
    I'll post my code and the error message below so that things are a bit clearer.
    Thanks,
    Robert.
    Here is the main.cpp. This is where the program is started.
    #include "/usr/lib/jvm/java-6-sun-1.6.0.06/include/jni.h"
    int main()
       JNIEnv *env;
       JavaVM *jvm;
       jint res;
       jclass cls;
       jmethodID mid;
       // creation of the JVM
       JavaVMInitArgs vm_args;
       JavaVMOption options[1];
       options[0].optionString = "-Djava.class.path= .";
       vm_args.version = 0x00010002;
       vm_args.options = options;
       vm_args.nOptions = 1;
       vm_args.ignoreUnrecognized = JNI_TRUE;
       res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
       // now the rest of the code can work
       cls = env->FindClass("Test");
       mid = env->GetMethodID(cls, "run", "()V");
       env->CallVoidMethod(cls, mid);
       jvm->DestroyJavaVM();
    }Here is Test.java
    public class Test
       public void run()
          System.out.println("stuff");
          foo();
       public void foo()
          System.out.println("asdfasdf");
    }And here is the error message.
    # An unexpected error has been detected by Java Runtime Environment:
    #  SIGSEGV (0xb) at pc=0x06245f7d, pid=9054, tid=1076641792
    # Java VM: Java HotSpot(TM) Client VM (10.0-b22 mixed mode, sharing linux-x86)
    # Problematic frame:
    # V  [libjvm.so+0x245f7d]
    # An error report file with more information is saved as:
    # /media/MY STICK/jni/cpp/hs_err_pid9054.log
    # If you would like to submit a bug report, please visit:
    #   http://java.sun.com/webapps/bugreport/crash.jsp
    AbortedEdited by: metaldrummer610 on Apr 23, 2008 8:35 PM

    Yeah, so I just figured out what was wrong. I wasn't calling main from in Java. My bad guys.

  • Problem with telnet on solaris 9

    Hi all,
    I have a problem with telnet on my sun fire v440 server with solaris 9 system, whenever I telnet to this server as a normal user ,after entering the username and password ,the user environment will switch to root. but i have checked the 'id' as i telnet the system ,it was not root. Pls refer the below message as i login the server:
    SunOS 5.9
    login: prad
    Password:
    Last login: Thu Apr 14 11:14:54 from 10.60.64.59
    Sun Microsystems Inc.   SunOS 5.9       Generic May 2002
    You have mail.
    root@T-Server02 # id
    uid=1017(prad) gid=10(staff)
    root@T-Server02 # cat /etc/passwd | grep prad
    prad:x:1017:10::/export/home/prad:/bin/sh
    root@T-Server02 # ls -lrt profile*
    -rwxrwxrwx   1 prad     other        174 Feb  7  2008 local.profile
    -rw-r--r--   1 prad     other        144 Feb  7  2008 backupprofile
    root@T-Server02 # pwd
    */export/home/prad*
    root@T-Server02 #
    Does any one have idea on how to solve this problem?

    Thanks . I'm pretty new in SUN OS, and not quite get your point . Here is the local.profile showed as below:
    This is a newly happened issue, I think we haven't change any profile setting in server:
    SunOS 5.9
    login: prad
    Password:
    Sun Microsystems Inc.   SunOS 5.9       Generic May 2002
    You have mail.
    root@T-Server02 # more local.profile
    *# Copyright (c) 2001 by Sun Microsystems, Inc.*
    *# All rights reserved.*
    *# ident "@(#)local.profile 1.10 01/06/23 SMI"*
    stty istrip
    PATH=/usr/bin:/usr/ucb:/etc:.
    export PATH
    root@T-Server02 #

  • Problem with JNI in a Solaris shared library

    Hi,
    I have a problem.
    I have used JNI in my .dll on Windows & .so on Solaris . I have also used the same JNI code in a .exe on Windows & an executable on Solaris. 3 out of the above 4 combinations work & 1 doesen't. When I use JNI from a .so on Solaris 8(with/without the J2SE recommended patch), the JVM seems to have some exception & dumps core when I invoke CreateJavaVM(). See Below - I've included the output on the screen & the output from 'pstack core' :
    Unexpected Signal : 11 occurred at PC=0xFED29D44
    Function=[Unknown. Nearest: JVM_GetMethodIxExceptionIndexes+0x1994]
    Library=/usr/java/jre/lib/sparc/libjvm.so
    Current Java thread:
    Dynamic libraries:
    0x10000 SblSim
    0xff280000 /usr/lib/libnsl.so.1
    0xfec00000 /usr/java/jre/lib/sparc/libjvm.so
    0xff370000 /usr/lib/libpthread.so.1
    0xff350000 /usr/lib/librt.so.1
    0xff260000 /usr/lib/libsocket.so.1
    0xff390000 /usr/lib/libdl.so.1
    0xff230000 /usr/lib/libCrun.so.1
    0xff200000 /usr/lib/libm.so.1
    0xff340000 /usr/lib/libw.so.1
    0xff1b0000 /usr/lib/libthread.so.1
    0xff080000 /usr/lib/libc.so.1
    0xff180000 /usr/lib/libmp.so.2
    0xff160000 /usr/lib/libaio.so.1
    0xff1f0000 /usr/platform/SUNW,Sun-Blade-1000/lib/libc_psr.so.1
    0xfebd0000 /usr/j2se/jre/lib/sparc/native_threads/libhpi.so
    0xfeba0000 /usr/j2se/jre/lib/sparc/libverify.so
    0xfeb60000 /usr/j2se/jre/lib/sparc/libjava.so
    0xfeb40000 /usr/j2se/jre/lib/sparc/libzip.so
    0xfe920000 /usr/lib/locale/en_US.ISO8859-1/en_US.ISO8859-1.so.2
    0xf1400000 ./libaicd.so
    0xfc480000 ./libmttoolkit.so
    0xfdfe0000 ./libmttlogger.so
    0xfdfb0000 /usr/j2se/jre/lib/sparc/libnet.so
    Local Time = Tue Nov 12 09:51:37 2002
    Elapsed Time = 29
    # HotSpot Virtual Machine Error : 11
    # Error ID : 4F530E43505002D5 01
    # Please report this error at
    # http://java.sun.com/cgi-bin/bugreport.cgi
    # Java VM: Java HotSpot(TM) Client VM (1.4.0_01-b03 mixed mode)
    # An error report file has been saved as hs_err_pid3120.log.
    # Please refer to the file for further information.
    Abort(coredump)
    Below is the output of 'pstack core'
    $ pstack core
    core 'core' of 3120: SblSim libaicd.so 127.0.0.1 9999
    ----------------- lwp# 1 / thread# 1 --------------------
    ff1c9764 __sigprocmask (ff1cbf60, 0, 0, 565f8, ff1de000, 0) + 8
    ff1be110 _sigon   (565f8, ff1e5930, 6, ffbedba4, 565f8, 6) + d0
    ff1c1150 thrpkill (0, 1, 6, ff1de000, 1, ff140450) + f8
    ff0cb900 raise (6, 0, 0, ffffffff, ff1403bc, 4) + 40
    ff0b58ec abort (ff13c000, ffbedcf8, 0, fffffff8, 4, ffbedd19) + 100
    feee2700 ???????? (1, fef98e50, ffbedd98, 0, feffc130, feee1258)
    feee12c8 ???????? (60650, b, fed29d44, ffbeeab8, b, 0)
    fede77c0 ???????? (fed29d44, ffbeeab8, ffbee800, fed29d44, fed03744, 0)
    ff1cb824 __sighndlr (b, ffbeeab8, ffbee800, fede6f38, 5669c, 5668c) + c
    ff1c84d8 sigacthandler (b, 565f8, 0, 0, 0, ff1de000) + 708
    --- called from signal handler with signal 11 (SIGSEGV) ---
    fed29d44 ???????? (0, 60650, 0, 0, 0, 0)
    fed2d7d4 ???????? (606e4, 0, 0, ffbeed00, 0, 0)
    f172e818 __1cHJNIEnv_JNewObject6MpnH_jclass_pnK_jmethodID_E_pnI_jobject__ (606e4, 0, 0, ffbeed70, 39, 107f90) + 70
    f172dbf8 __1cGJEvent2t5B6M_v_ (107f60, f1a877f4, db088, ff0c1c44, 107f48, 0) + 80
    f16f2864 __1cGCEvent2t6Mii_v_ (107f60, 0, 1, ff13c000, 107f48, 0) + 7c
    f16e62e8 __1cVCISCHelperThreadMutex2t6M_v_ (107f50, 0, 560ac, 30f68, fefe4000, 0) + c0
    f16ddc34 __1cLinitGlobals6F_v_ (0, 1, 19a, f1a198ec, f1a198ec, 0) + 5c
    f16de4e4 CreateISCDriverInstance (0, 5cc40, 0, 57608, 565e8, 0) + 554
    00034f08 __1cJRunSblSim6F_v_ (1, ffbef322, ffbef32c, ff13fc70, 100d4, 0) + 320
    00035588 main (4, ffbef1dc, ffbef1f0, 55c00, 0, 0) + 1a8
    00018460 _start   (0, 0, 0, 0, 0, 0) + 108
    ----------------- lwp# 2 / thread# 2 --------------------
    ff11e958 _signotifywait (ff1de000, 59, 0, 0, 0, 0) + 8
    ff1c2030 thr_yield (0, 0, 0, 0, 0, 0) + 8c
    ----------------- lwp# 3 --------------------------------
    ff1c9774 private___lwp_cond_wait (ff075d70, ff1ded9c, ff1de000, 0, 0, 4) + 8
    ff11c554 doorreturn (ff075cb0, ff1ba740, 0, 0, 0, 0) + 68
    ----------------- lwp# 4 / thread# 4 --------------------
    ff11efbc ___lwp_cond_wait (60048, 60030, fe901ad0, 0, 0, fe901ac8) + 8
    ff116610 lwpcond_timedwait (1cb8c88, 3dd1157a, fe901ba4, 60030, 60048, 1) + 98
    fecfc7d8 ???????? (0, 1, 0, 581b8, feffa26c, 0)
    fecfcfd4 ???????? (ff00a15c, feffa4b8, feffa4b4, 0, 0, 0)
    fecfccc0 ???????? (d3980, 0, 0, 0, 0, 0)
    fecfcbd0 ???????? (d3980, ff1df688, 1, 1, ff1de000, 0)
    ff1cb728 threadstart (d3980, 0, 0, 0, 0, 0) + 40
    ----------------- lwp# 5 --------------------------------
    ff11c4fc doorreturn (4, ff1df688, ff1df6a0, 3, ff1de000, 1) + 10
    ff1ba740 lwpstart (fea95d70, 0, 6000, ff075b74, 0, 0) + 18
    ff1c2030 thr_yield (0, 0, 0, 0, 0, 0) + 8c
    ----------------- lwp# 6 / thread# 5 --------------------
    ff11efbc ___lwp_cond_wait (d5720, d5708, 0, fed10a40, 0, 0) + 8
    fed110d4 ???????? (d56c8, 0, 5000, 5210, d4d38, 4d24)
    fed10824 ???????? (fdf8172c, 0, 0, d4d38, d4d38, 30dec8)
    fed103b0 ???????? (d4dcc, fdf81824, 0, 0, 0, 0)
    fa40cc94 ???????? (f2000380, b6, fdf818a4, ffffffff, 0, fdf817c0)
    fa405da0 ???????? (f2000380, b6, fdf818a8, fa415444, 0, fdf81840)
    fa405da0 ???????? (fdf81938, 0, 0, fa4157a4, 2f4210, fdf818d8)
    fa400438 ???????? (fdf819c0, fdf81c08, a, f6050b68, fa40bc8c, fdf81b50)
    fecfe2f8 ???????? (fdf81c00, fdf81a88, fdf81b48, d4d38, d4d38, fdf81a9c)
    fed0ff90 ???????? (fefe4000, d5298, fdf81b3c, fdf81b38, fdf81b48, d4d38)
    fed0fdf0 ???????? (fdf81c00, fdf81bfc, fdf81bf0, fdf81be8, fdf81be0, d4d38)
    fed0fd78 ???????? (d4d38, d4d38, ac9a0, d5298, 2d4488, fed0fa60)
    fed0fa88 ???????? (d4d38, 0, 0, 0, 0, 0)
    fecfcbd0 ???????? (d4d38, ff1df688, 1, 1, ff1de000, 0)
    ff1cb728 threadstart (d4d38, 0, 0, 0, 0, 0) + 40
    ----------------- lwp# 7 / thread# 6 --------------------
    ff11efbc ___lwp_cond_wait (d7040, d7028, 0, 1, 0, 0) + 8
    fed110d4 ???????? (d6fe8, 0, 5000, 5210, d6658, 4d24)
    fed10824 ???????? (fa38169c, 0, 0, d6658, d6658, 30dec8)
    fed103b0 ???????? (d66ec, fa38179c, 0, 0, 0, 0)
    fa40cc94 ???????? (f2000490, b6, fa3817a0, fa414050, 0, fa381730)
    fa405da0 ???????? (f2000478, b6, fa3818b4, fa415444, 0, fa3817d8)
    fa405c4c ???????? (f2000478, b6, fa381934, fa415444, d6658, fa381858)
    fa405c4c ???????? (fa381938, 0, 0, fa38197c, 2f4210, fa3818d8)
    fa400438 ???????? (fa3819c0, fa381c08, a, f60520b8, fa40bc8c, fa381b50)
    fecfe2f8 ???????? (fa381c00, fa381a88, fa381b48, d6658, d6658, fa381a9c)
    fed0ff90 ???????? (fefe4000, d6bb8, fa381b3c, fa381b38, fa381b48, d6658)
    fed0fdf0 ???????? (fa381c00, fa381bfc, fa381bf0, fa381be8, fa381be0, d6658)
    fed0fd78 ???????? (d6658, d6658, ac9e0, d6bb8, 2d4488, fed0fa60)
    fed0fa88 ???????? (d6658, 0, 0, 0, 0, 0)
    fecfcbd0 ???????? (d6658, ff1df688, 1, 1, ff1de000, 0)
    ff1cb728 threadstart (d6658, 0, 0, 0, 0, 0) + 40
    ----------------- lwp# 8 / thread# 7 --------------------
    ff11d194 _poll    (0, 0, 0, fa281a28, ff13f1b4, fa281a28) + 8
    ff1cb134 select (0, a, 0, ff1de000, fa281e14, 0) + 34
    fed32afc ???????? (d8040, 0, a, 0, 0, 0)
    fed328b4 ???????? (d8040, 0, 0, 0, 0, 0)
    fecfcbd0 ???????? (d8040, ff1df688, 1, 1, ff1de000, 0)
    ff1cb728 threadstart (d8040, 0, 0, 0, 0, 0) + 40
    ----------------- lwp# 9 / thread# 8 --------------------
    ff11efbc ___lwp_cond_wait (5f998, 5f980, 2e7aa0, ff1de000, fa181e14, 0) + 8
    fecfc634 ???????? (5f950, 0, 0, 0, feffa26c, 0)
    fed3371c ???????? (3c00, 3f44, 0, 0, 0, 0)
    fecfcbd0 ???????? (d81a8, ff1df688, 1, 1, ff1de000, 0)
    ff1cb728 threadstart (d81a8, 0, 0, 0, 0, 0) + 40
    ----------------- lwp# 10 / thread# 9 --------------------
    ff11f008 lwpsema_wait (f1f81e30, ff1de000, 0, f1f81d70, ff3e2628, 0) + c
    ff1b94c0 _swtch   (f1f81d70, ffffffff, ff1de000, 5, 1000, 0) + 158
    ff1bcc64 sema_wait (ff020fe0, ff1e98e4, 5000, 10000, 534d, 1) + bc
    fed345c8 ???????? (0, 6, b, a, 1, 0)
    fed34254 ???????? (ff002ae4, ff00a5a0, ff00a5d4, dab90, 2d4488, fed0fa60)
    fed0fa88 ???????? (da630, 0, 0, 0, 0, 0)
    fecfcbd0 ???????? (da630, ff1df688, 1, 1, ff1de000, 0)
    ff1cb728 threadstart (da630, 0, 0, 0, 0, 0) + 40
    ----------------- lwp# 11 / thread# 10 --------------------
    ff11efbc ___lwp_cond_wait (604e8, 604d0, 2e7aa0, feffa26c, 106c40, 0) + 8
    fecfc88c ???????? (604a0, 0, 0, dbbd0, feffa26c, 0)
    fed349ac ???????? (db670, db670, dbfd0, dbbd0, 2d4488, fed0fa60)
    fed0fa88 ???????? (db670, 0, 0, 0, 0, 0)
    fecfcbd0 ???????? (db670, ff1df688, 1, 1, ff1de000, 0)
    ff1cb728 threadstart (db670, 0, 0, 0, 0, 0) + 40
    -------------------------- thread# 3 --------------------
    ff1bddbc reapwait (ff1e29e0, 20520, 0, ff1de000, 0, 0) + 38
    ff1bdb14 _reaper  (ff1dee30, ff1e4740, ff1e29e0, ff1dee08, 1, fe400000) + 38
    ff1cb728 threadstart (0, 0, 0, 0, 0, 0) + 40

    This is an update to the original message -
    I have tried both HotSpot & Server JVMs but still see the
    same behavior. I'm using 1.4 .
    I'd like to provide more information to those who can help
    me. I have a feeling there might be something wrong in my
    CC options. Thus you will find below what my CC statement
    looks like for one of the files in my project & for the
    linking of the final shared library. I also have
    provided the output of ldd on my shared library libaicd.so
    & for comparison the output of ldd on libjvm.so as that
    might provide some usefull information just incase
    something looks suspecious & might ring a bell.
    /opt/SUNWspro.cc6/bin/CC -c -KPIC -g -DDEBUG=DEBUG -
    D_DEBUG -mt -DSOLARIS -DSTD_STREAM -
    I/vob1/qwsrc/fw/include -I.-I/vob4/source/idl -
    I/vob4/source/mttoolkit -I/vob4/source/mttoolkit/tools -
    I/vob4/source/integrations/siebel/aicd -
    I/vob4/source/include -I/vob1/qwsrc/fw/include -
    I/vob4/source/source -I/vob4/source/mttoolkit -
    I/vob1/external/platform_neutral/siebel/scapi/include -
    I/external/sparc/Sun/jdk/1.3.1/include -
    I/external/sparc/Sun/jdk/1.3.1/include/solaris -
    I/vob4/source/idl -I/vob4/source/mttoolkit -
    I/vob4/source/mttoolkit/tools -
    I/vob4/source/mttoolkit/vnet -
    I/vob4/source/mttoolkit/bool -DUNIX -
    D_USE_MTTServerToolkit -D_JAVA_ WIAcceptTimeOut.cpp -
    o /space/users/janak/buildoutput/sparc/debug/obj/integratio s/siebel/aicd/WIAcceptTimeOut.o
    /opt/SUNWspro.cc6/bin/CC -G -
    o /space/users/janak/buildoutput/sparc/debug/lib/fw/libaicd.so
    /space/us
    ers/janak/buildoutput/sparc/debug/obj/integrations/siebel/ai
    cd/AgentService.o /space/users/janak/buildoutput/sparc/debug
    /obj/integrations/siebel/aicd/AgentServiceCmds.o /space/user
    s/janak/buildoutput/sparc/debug/obj/integrations/siebel/aicd
    /AgentServiceEvents.o /space/users/janak/buildoutput/sparc/d
    ebug/obj/integrations/siebel/aicd/AgentServiceICAReq.o /spac
    e/users/janak/buildoutput/sparc/debug/obj/integrations/siebe
    l/aicd/AgentServiceICEvents.o /space/users/janak/buildoutput
    /sparc/debug/obj/integrations/siebel/aicd/AgentServiceUtilit
    ies.o /space/users/janak/buildoutput/sparc/debug/obj/integra
    tions/siebel/aicd/AvMc.o /space/users/janak/buildoutput/spar
    c/debug/obj/integrations/siebel/aicd/InternationalStrings.o
    /space/users/janak/buildoutput/sparc/debug/obj/integrations/
    siebel/aicd/JEvent.o /space/users/janak/buildoutput/sparc/de
    bug/obj/integrations/siebel/aicd/JMultipleEvents.o /space/us
    ers/janak/buildoutput/sparc/debug/obj/integrations/siebel/ai
    cd/JNIObject.o /space/users/janak/buildoutput/sparc/debug/ob
    j/integrations/siebel/aicd/JObject.o /space/users/janak/buil
    doutput/sparc/debug/obj/integrations/siebel/aicd/JSemaphore.
    o /space/users/janak/buildoutput/sparc/debug/obj/integration
    s/siebel/aicd/JWorkerThread.o /space/users/janak/buildoutput
    /sparc/debug/obj/integrations/siebel/aicd/MultipleEvents.o /
    space/users/janak/buildoutput/sparc/debug/obj/integrations/s
    iebel/aicd/Param.o /space/users/janak/buildoutput/sparc/debu
    g/obj/integrations/siebel/aicd/ParamQueue.o /space/users/jan
    ak/buildoutput/sparc/debug/obj/integrations/siebel/aicd/RefC
    ount.o /space/users/janak/buildoutput/sparc/debug/obj/integr
    ations/siebel/aicd/SiebelDriver.o /space/users/janak/buildou
    tput/sparc/debug/obj/integrations/siebel/aicd/SiebelEvent.o
    /space/users/janak/buildoutput/sparc/debug/obj/integrations/
    siebel/aicd/SiebelWorkItem.o /space/users/janak/buildoutput/
    sparc/debug/obj/integrations/siebel/aicd/SingleEvent.o /spac
    e/users/janak/buildoutput/sparc/debug/obj/integrations/siebe
    l/aicd/SmartPtr.o /space/users/janak/buildoutput/sparc/debug
    /obj/integrations/siebel/aicd/StdAfx.o /space/users/janak/bu
    ildoutput/sparc/debug/obj/integrations/siebel/aicd/ThreadPoo
    l.o /space/users/janak/buildoutput/sparc/debug/obj/integrati
    ons/siebel/aicd/Utilities.o /space/users/janak/buildoutput/s
    parc/debug/obj/integrations/siebel/aicd/WIAcceptTimeOut.o -
    lnsl -lc -lCstd -
    L/space/users/janak/buildoutput/sparc/debug/lib/cti -
    lmttoolkit -
    L/space/users/janak/buildoutput/sparc/debug/lib/fw -
    lmttlogger -
    L/space/users/janak/buildoutput/sparc/debug/lib/fw -
    lqwlicmtt -
    L/external/sparc/Sun/jdk/1.3.1/jre/lib/sparc/server -
    Bdynamic -ljvm -mt -lpthread -lposix4
    $ ldd /usr/j2se/jre/lib/sparc/libjvm.so
    libCrun.so.1 => /usr/lib/libCrun.so.1
    libdl.so.1 => /usr/lib/libdl.so.1
    libthread.so.1 => /usr/lib/libthread.so.1
    libsocket.so.1 => /usr/lib/libsocket.so.1
    libnsl.so.1 => /usr/lib/libnsl.so.1
    libm.so.1 => /usr/lib/libm.so.1
    libw.so.1 => /usr/lib/libw.so.1
    libc.so.1 => /usr/lib/libc.so.1
    libmp.so.2 => /usr/lib/libmp.so.2
    /usr/platform/SUNW,Sun-Blade-1000/lib/libc_psr.so.1
    $ ldd libaicd.so
    libnsl.so.1 => /usr/lib/libnsl.so.1
    libc.so.1 => /usr/lib/libc.so.1
    libmttoolkit.so => ./libmttoolkit.so
    libmttlogger.so => ./libmttlogger.so
    libjvm.so => /usr/java/jre/lib/sparc/libjvm.so
    libpthread.so.1 => /usr/lib/libpthread.so.1
    librt.so.1 => /usr/lib/librt.so.1
    libdl.so.1 => /usr/lib/libdl.so.1
    libmp.so.2 => /usr/lib/libmp.so.2
    libCrun.so.1 => /usr/lib/libCrun.so.1
    libthread.so.1 => /usr/lib/libthread.so.1
    libsocket.so.1 => /usr/lib/libsocket.so.1
    libm.so.1 => /usr/lib/libm.so.1
    libaio.so.1 => /usr/lib/libaio.so.1
    libw.so.1 => /usr/lib/libw.so.1
    /usr/platform/SUNW,Sun-Blade-1000/lib/libc_psr.so.1

  • Problem with JNI and Tomcat (and threads???)

    Howdy,
    Here is the issue - I would like some help on HOW to debug and fix this problem:
    2 test use cases -
    1)
    a)User goes to Login.jsp, enters user and password
    b) User submits to LoginServlet
    c) login calls JNI code that connects to a powerbuilder(Yes I know this is ugly) PBNI code module (this is a .dll) that authenticates the user with the database
    d) the servlet then redirects to another .jsp page
    e) user then submits to LogoutServlet - also a JNI call to a powerbuilder PBNI code module
    f) REPEAT STEPS a-e over a few times (inconsistent) and then the call to the JNI code hangs
    2)
    a) users does NOT goto Login.jsp, but rather calls LoginServlet and passes the userid and password as GET parms
    b) user does NOT get redirected to a page (redirect code commented out)
    c) user calls LogoutServlet
    d) repeat steps a-c at will and no failure, no hanging
    The only difference is that in case 1 (with JSP), there is a redirect and it afffected the JNI call by haniging inside JNI code.
    In case 2 (without JSP) there is still a JNI call, but it does not hang. In addition, when it hangs and I stop Tomcat, the logs show cleanup entries that say:
    Oct 19, 2004 9:17:09 AM org.apache.catalina.core.StandardWrapper unload
    INFO: Waiting for 1 instance(s) to be deallocated
    Oct 19, 2004 9:17:10 AM org.apache.catalina.core.StandardWrapper unload
    INFO: Waiting for 1 instance(s) to be deallocated
    Oct 19, 2004 9:17:11 AM org.apache.catalina.core.StandardWrapper unload
    INFO: Waiting for 1 instance(s) to be deallocated
    Is this a threading issue in Tomcat???
    On would assume that the JNI code is not cleaning up after itself, but I don't believe this is the case,
    and even if it was, why would I get the tomcat log cleanup entries above???
    What do those cleanup entries imply about the state of Tomcat????

    hi ,
    I met the same problem this morning, and searched the www.google.com in order to solve it, as a result, your article was shown on my screen. :)
    Till now I have read some technical information and solved my problems. Maybe the solution be useful to you:
    ==============================
    error message : (Environment : Tomcat 5, Windows 2003, Mysql5)
    2006-3-29 11:53:48 org.apache.catalina.core.StandardWrapper unload
    message: Waiting for 2 instance(s) to be deallocated
    ==============================
    cause: the number of connection to database exceeded.another word,too many connections.
    ==============================
    solution: close the connection when it becomes useless for your program. :)
    ==============================
    ps. Sorry for my weak English . hehe ....

  • Problem with JNI on netBeans

    Hi !
    After a search on the forum, I request your help about a little JNI app developped to work with a 3D sensor. The research team in which I work use to working with Eclipse IDE, and this JNI appliation work on it. However, impossible to find a way on NetBeans... I get an exception :
    Exception in thread "main" java.lang.UnsatisfiedLinkError:
    materiel.videoproj.JNIsiapp.SiInitialize()I
    at materiel.videoproj.JNIsiapp.SiInitialize(Native Method)
    at materiel.videoproj.JNIsiapp.main(JNIsiapp.java:138)
    It seems the IDE get the DLL (if I change the name in the loadLibrary method, the exception change) but encounter an error with the native method.
    The application (source code + dll + java code) could be find on ftp :
    ftp://ftp-us.3dconnexion.com
    login: jni
    password: dev1221
    Please help me too find a way !
    FloDeTours

    Library loading seems to continue to be a problem. There are two things to consider. First if you wrote the C/C++ code (like in the tutorials) then you compile it into a dll. This is the only dll you have to worry about. It will get loaded by your Java code using loadLibrary.
    This method is going to look for the dll on the path java.library.path. If you don't set this, it is equal to the system path. I like to keep everything inside my project so I put alll dlls in a directory off my project root called "native". So I set java.library.path to "native". In any case it should point to the location of the dll if it is not on the system path.
    Second if you have a 3rd party dll then you also have a JNI dll. The JNI dll is the one that loadLibrary loads, so the above applies to it. The third party dll is loaded on the C/C++ side, which know nothing about java.library.path. I only knows system path. This means that the location of this dll must be in that path. You can add the location to the system path permanently or use the IDE project setting to add it only inside the project scope.
    When you deploy the app you will need to supply the various path settings in the launching code.
    Jim

  • Problem with Java in solaris 10 zone

    HI ,
    i get this error message in my solaris 10 zone :
    #./java version
    Exception java.lang.OutOfMemoryError: requested -4 bytes for size_t in /BUILD_AREA/jdk1.5.0_11/hotspot/src/os/solaris/vm/os_solaris.cpp. Out of swap space?
    in global zone , java works fine !
    uname -a
    SunOS Server 5.10 Generic_141414-07 sun4u sparc SUNW,SPARC-Enterprise
    best regards

    I see mention of a similar problem, but only with early development releases of solaris10 branded zones running on Solaris 11 development bits. It seems as though this is not what you are running.
    Since there are no swap caps nor brand emulation in place, the next thing I would suspect would be that you somehow have inconsistencies between key libraries (e.g. libc) and the kernel. This could happen if you have a full-root zone that has been force attached (zoneadm -z <zone> attach -F). In the past, I've seen products that do this under the covers (e.g. Veritas Cluster) so it may have happened without your knowledge. If it is a sparse root zone, you may want to run "zoneadm -z <zone> detach; zoneadm -z <zone> attach -u". Prior to doing so, take whatever precautions you would normally take when patching a system.
    If you open a support call about this I bet the first advice you are going to get is to patch, as you seem to be 2+ years behind. Also, newer releases of Java 5 are available at http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase5-419410.html.

  • Problem with JNI and Tomcat in windows

    Hello guys...
    I have the following problem.
    I used Tomcat 4 and I have following ApiEncriptacion class, in package com.servipag.sts;
    package com.servipag.sts;
    class ApiEncriptacion
         public native String encripta(String texto, String ubicacionLlavePublica, String semilla);
         static
              System.loadLibrary("apisdark");
         public native String desencripta(String texto, String ubicacionLlavePrivada);
         static
              System.loadLibrary("apisdark");
    the LD_LIBRARY_PATH is set in following dir c:\tomcat\bice
    the dll this in the following path = c:\tomcat\bice\apisdark.dll
    I run Tomcat at the following way..
    C:\jdk1.4\bin\java.exe -jar -Djava.library.path="c:\tomcat\bice" -Duser.dir="C:\Tomcat" "C:\Tomcat\bin\bootstrap.jar" start
    but, still appear the error:
    java.lang.UnsatisfiedLinkError: encripta
         at com.servipag.sts.ApiEncriptacion.encripta(Native Method)
         at com.servipag.sts.ServiciosServiPagImpl.rescatarFirma(ServiciosServiPagImpl.java:2143)
         at com.servipag.sts.ServiciosServiPagImpl.pagarCuenta(ServiciosServiPagImpl.java:310)
         at org.apache.jsp.SBCO_0005flogin_0005fbice_0005f4$jsp._jspService(SBCO_0005flogin_0005fbice_0005f4$jsp.java:265)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)
         at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)
         at java.lang.Thread.run(Thread.java:536)
    please help me
    Luis Navarro.
    Chile

    ApiEncripatcion.h
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class ApiEncriptacion */
    #ifndef IncludedApiEncriptacion
    #define IncludedApiEncriptacion
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class: ApiEncriptacion
    * Method: encripta
    * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    JNIEXPORT jstring JNICALL Java_ApiEncriptacion_encripta
    (JNIEnv *, jobject, jstring, jstring, jstring);
    * Class: ApiEncriptacion
    * Method: desencripta
    * Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    JNIEXPORT jstring JNICALL Java_ApiEncriptacion_desencripta
    (JNIEnv *, jobject, jstring, jstring);
    #ifdef __cplusplus
    #endif
    #endif
    ApiEncriptacion.c
    #include "jni.h"
    #include <stdio.h>
    #include "files.h"
    #include "hex.h"
    #include "rsa.h"
    #include "randpool.h"
    USING_NAMESPACE(CryptoPP)
    USING_NAMESPACE(std)
    void GenerateRSAKey(unsigned int keyLength, const char privFilename, const char pubFilename, const char *seed);
    char RSAEncryptString(const char pubFilename, const char seed, const char message);
    char RSADecryptString(const char privFilename, const char *ciphertext);
    JNIEXPORT jstring JNICALL
    Java_ApiEncriptacion_encripta(JNIEnv *env, jobject obj, jstring texto, jstring ubicacionLlavePublica, jstring semilla)
         try
              char *ciphertext = RSAEncryptString(ubicacionLlavePublica, semilla, texto);
              delete [] ciphertext;
              return(ciphertext);
         catch(CryptoPP::Exception &e)
              return ("");
         catch(std::exception &e)
              return ("");
         catch(...)
              return ("");
    JNIEXPORT jstring JNICALL
    Java_ApiEncriptacion_desencripta(JNIEnv *env, jobject obj, jstring texto, jstring ubicacionLlavePrivada)
         try
              char *decrypted = RSADecryptString(ubicacionLlavePrivada, texto);
              return(decrypted);
         catch(CryptoPP::Exception &e)
              return ("");
         catch(std::exception &e)
              return ("");
         catch(...)
              return ("");
    int main()
         return(0);     
    void GenerateRSAKey(unsigned int keyLength, const char privFilename, const char pubFilename, const char *seed)
         RandomPool randPool;
         randPool.Put((byte *)seed, strlen(seed));
         RSAES_OAEP_SHA_Decryptor priv(randPool, keyLength);
         HexEncoder privFile(new FileSink(privFilename));
         priv.DEREncode(privFile);
         privFile.MessageEnd();
         RSAES_OAEP_SHA_Encryptor pub(priv);
         HexEncoder pubFile(new FileSink(pubFilename));
         pub.DEREncode(pubFile);
         pubFile.MessageEnd();
    char RSAEncryptString(const char pubFilename, const char seed, const char message)
         FileSource pubFile(pubFilename, true, new HexDecoder);
         RSAES_OAEP_SHA_Encryptor pub(pubFile);
         if (strlen(message) > pub.MaxPlainTextLength())
              cerr << "message too long for this key\n";
              abort();
         RandomPool randPool;
         randPool.Put((byte *)seed, strlen(seed));
         char outstr = new char[2pub.CipherTextLength()+1];
         pub.Encrypt(randPool, (byte *)message, strlen(message), (byte *)outstr);
         HexEncoder hexEncoder;
         hexEncoder.Put((byte *)outstr, pub.CipherTextLength());
         hexEncoder.MessageEnd();
         hexEncoder.Get((byte *)outstr, 2*pub.CipherTextLength());
         outstr[2*pub.CipherTextLength()] = 0;
         return outstr;
    char RSADecryptString(const char privFilename, const char *ciphertext)
         FileSource privFile(privFilename, true, new HexDecoder);
         RSAES_OAEP_SHA_Decryptor priv(privFile);
         HexDecoder hexDecoder;
         hexDecoder.Put((byte *)ciphertext, strlen(ciphertext));
         hexDecoder.MessageEnd();
         SecByteBlock buf(priv.CipherTextLength());
         hexDecoder.Get(buf, priv.CipherTextLength());
         char *outstr = new char[priv.MaxPlainTextLength()+1];
         unsigned messageLength = priv.Decrypt(buf, (byte *)outstr);
         outstr[messageLength] = 0;
         return outstr;

Maybe you are looking for

  • ITunes movies not showing up on Apple TV

    I'm having some trouble with my movies not showing up on Apple TV. The movies I am missing are not purchased from iTunes but I have converted them using Handbrake. I've double checked the format and they seem to be what's required from what I've read

  • Adobe X Standard conflicts with multiple scanners?

    If I add a second scanner to my home network, will the Adobe X Standard software create a conflict when it sees the two devices?  I will be just scanning one document at a time.

  • Changing Pricing condition-JCV1

    Hi all i want to change the following conditon in PO ( relevant part) where in the > CVD is calculated wrong. ( 16% of Basic customs duty). ( CVD ought to be > 16% of material cost + basic customs duty). i have specified in IMG schema condition to ca

  • Nokia 8800 Internet purchase advice

    Hi guys, I have found this web-site that is selling a range of Nokia's 8800's at very good prices. Has anybody had any experience with this web-site (Link below)? I have also emailed the seller to ask him if the units are authentic and if he has any

  • OIM 11g can't get default reports working

    Hello, OIM 11g and BI publisher 11g here. They are installed on different machines, so they do not share anything at all. I want to make the standard OIM reports work into BI Publisher, so i installed BI publisher (alone), created user xelsysadm (giv