JNI UnsatisfiedLinkError in Weblogic 5.1.0 SP 8

I am running Weblogic 5.1.0 with service pack 8 on solaris. We are using a web application called ecare. Servlets are under:myserver/ecare/web-inf/classes/servletsThe JavaBean that uses JNI to connect to the C code is under:myserver/ecare/web-inf/classes/JNIThe C library is under:myserver/ecare/web-inf/libThis path is added on LD_LIBRARY_PATHThe JavaBeans although it manages to load the library successfully it fails on the first native function call with the error java.lang.UnsatisfiedLinkError: functionnameI've tested that code before adding it to our weblogic implementation, by using a test java program that made the native calls to the library and that worked fine.The JavaBean that calls the c library is in package JNI. I've tried using javah from the classes directory (parent of JNI, and in classpath) which produced a header file with the function names that included the package name JNI, but that did not help.Browsing through the emails on this newsgroup I've noticed that there were a few people with the same problem as me, but I did not manage to find any solution to the problem.Any help would be greatly appreciated. I am looking forward to hearing from any of you.Kind Regards,Mike

For me it seems that you have not created the native method header file correctly.
To create the header file correctly you have to call the javah compiler in the following
way:
javah -jni fullpackagename.NativeClassName
then you get the right package name in your header file.
This has solved the UnsatisfiedLinkError at the first call of my nativ method call.
I hava not tested this within a EJB. It's still a "normal" programm.
Greetings
Johannes

Similar Messages

  • JNI  UnsatisfiedLinkError

    Hi everybody.
    i've got a problem running a simple example of JNI.
    I'm trying to call the method MessageBox of user32.dll, that is placed on system32 of course.
    This is the code:
    import java.io.*;
    public class NativeMFCMsg{
    static {
    try {
    //System.loadLibrary("user32");
    System.load("c:\\winnt\\system32\\user32.dll");
    System.out.println("Library user32 Loaded");
    }catch(Exception e){
    e.printStackTrace();
    public native int MessageBox( int hWnd,String lpText,String lpCaption,int uType );
    public static void main(String[] args){
    try {
    new NativeMFCMsg().MessageBox(0,"Hello","Caption",0);
    }catch(UnsatisfiedLinkError ex){
    ex.printStackTrace();
    System.out.println("Error " + "\n" + ex.toString());
    System.exit(1);
    the load or the loadLibrary methods works fine ... the problem is when i call the MessageBox ... don't know why ? i've read the JNI tutorial from sun and i think that there is everything correct but ... it's obvious that i'm wrong ...
    please help.
    Regards, Roberto.

    First, you could use the -verbose option of the jvm to try to get some more info. Is there is some other dll that it can't find ?
    Then, you could check your method signature. Make sure you use the prototypes from the JNI-created header file exactly.
    In particular, did you supply the fully qualified name (including the package name) of your class to javah (e.g. yourPackage.yourClass).
    The mangled name (in yourPackage_yourClass.h) should look like this:
    Ljava_yourPackage_yourClass_yourMethod

  • JNI UnsatisfiedLinkError - one more

    Hi there,
    As i saw a lot of problem concerning use of JNI and shared library i've got same problems. All i could see about how to do the right way is not enough ...
    My java class, .c, .h are in the right writes. All is well compiled, with package name. Libraries path are well set, even LD_LIBRARY PATH and SHLIB_PATH as i'm working on hp-ux. The library exists, has the right name
    and when executing i've got the :
    Exception occurred during event dispatching :
    java.lang.UnsatisfiedLinkError: no ArtStart in java.library.path
    at java.lang.ClassLoader.loadLibrary(...)
    at java.lang.Runtime.loadLibrary0(...)
    at java.lang.System.loadLibrary(...)
    etc ...
    So is there any way to make it working ???
    Chris

    I was only able to load libraries using System.load("<full path to lib>"); . This was on Win 2000 though.
    If you are using packages, please read this from a previous post:
    When you package your class there are 2 things to look out for. First in order to generate a proper package-named header you must use "javah -jni mypackage.myclass" at the head of the appropriate classpath. This will create the mypackage_myclass.h header file. Second, you have to change the names appropriately in your calls. Non-packaged methods have the form JAVAMYCLASS_MYMETHOD. Packaged methods have the form JAVAMYPACKAGE_MYCLASS_MYMETHOD.
    If you use dumpbin/EXPORTS on DOS or an equivalent on UNIX on your dll, you can see what the export method name really is. Also be sure to get rid of any old dll.
    Good luck.
    Frank L. Hood
    Polexis
    ---------------------------------------------

  • Help: I'm sure it is a Bug in JNI calling WebLogic EJB

    Help me! I'm using jni to call weblogic EJB from a Com+ component,here is the code:
    // This is the main project file for VC++ application project
    // generated using an Application Wizard.
    #include "stdafx.h"
    #pragma unmanaged
    #include <windows.h>
    #include <jni.h>
    #include <process.h>
    #include <stdio.h>
    #define USER_CLASSPATH "C:\\myClasses;C:\\j2sdk1.4.0\\lib\\tools.jar;Z:\\wlserver6.1\\lib\\weblogic.jar;"
    /* where Prog.class is */
    JavaVM *jvm;
    * Function GetJNIEnv(void) returns the java environment pointer
    * in case we are executing on a thread other than the one the
    * jvm was created on.
    JNIEnv* GetJNIEnv(void){
         JNIEnv *env = NULL;
         jint nRet = jvm->GetEnv((void **)&env, JNI_VERSION_1_2);
         if(nRet == JNI_EDETACHED){
              jvm->AttachCurrentThread((void **)&env, NULL);
         return env;
    * Function DoJNDI(void *arg) uses the Java Invocation API to
    * execute the following Java code:
    * Hashtable prop = new Hashtable();
    * prop.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"
    * prop.put( Context.PROVIDER_URL, "t3://192.168.40.137:7001" );
    * ctxInitial = new InitialDirContext( prop );
    void DoJNDI(void *arg){
         jclass clsHash, clsInitDirCx;
         jmethodID mHashInit, mHashPut, mInitDirCxInit;
         jobject objHash, objInitDirCx;
         JNIEnv *env = GetJNIEnv(); // Get the environment if on a different thread
         clsHash = env->FindClass("java/util/Hashtable");
         mHashInit = env->GetMethodID(clsHash, "<init>", "()V");
         objHash = env->NewObject(clsHash, mHashInit);
         mHashPut = env->GetMethodID(clsHash, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
         jstring jstrICxFactoryPut = env->NewStringUTF("java.naming.factory.initial");
         jstring jstrICxFactoryVal = env->NewStringUTF("weblogic.jndi.WLInitialContextFactory");
         env->CallObjectMethod(objHash, mHashPut, jstrICxFactoryPut,jstrICxFactoryVal);
         jstring jstrProviderUrlPut = env->NewStringUTF("java.naming.provider.url");
         jstring jstrProviderUrlVal = env->NewStringUTF("t3://192.168.40.137:7001");
         env->CallObjectMethod(objHash, mHashPut, jstrProviderUrlPut,jstrProviderUrlVal);
         clsInitDirCx = env->FindClass("javax/naming/InitialContext");
         mInitDirCxInit = env->GetMethodID(clsInitDirCx, "<init>", "(Ljava/util/Hashtable;)V");
         objInitDirCx = env->NewObject(clsInitDirCx, mInitDirCxInit, objHash);
         if(objInitDirCx == NULL){
              printf("%s test FAILED:\n\n", (char*)arg);
         else{
              printf("%s test PASSED\n\n", (char*)arg);
         jvm->DetachCurrentThread();
    * Function main(void) creates a JVM, and calls DoJNDI twice:
    * Once as a regular function call, and once as a spun off thread.
    void main() {
    JavaVMInitArgs vm_args;
    JavaVMOption options[5];
         options[0].optionString = "-client";
    options[1].optionString =
    "-cp " USER_CLASSPATH;
    options[2].optionString =
    "-Djava.class.path=" USER_CLASSPATH;
         //options[3].optionString =
         //     "-Xbootclasspath:c:\\j2sdk1.4.0\\lib\\tools.jar;z:\\wlserver6.1\\lib\\weblogic_sp.jar;z:\\wlserver6.1\\lib\\weblogic.jar;";
         options[3].optionString =
              "-Xbootclasspath/a:c:\\j2sdk1.4.0\\lib\\tools.jar;z:\\wlserver6.1\\lib\\weblogic_sp.jar;";
         options[4].optionString =
              "-Xbootclasspath/p:c:\\j2sdk1.4.0\\lib\\tools.jar;z:\\wlserver6.1\\lib\\weblogic_sp.jar;";
    vm_args.version = 0x00010002;
    vm_args.options = options;
    vm_args.nOptions = 5;
    vm_args.ignoreUnrecognized = JNI_TRUE;
         JNIEnv *env;
         jint res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
         // *** Make the magic calls! (Both lines should do the same thing) ***
         DoJNDI((void*)"Function call");
         _beginthread(DoJNDI,0,(void *)"Thread call");
         /* wait for thread(s) to finish */
         Sleep(5000);
         jvm->DestroyJavaVM();
    But it always send me a Exception like below:
    javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory.
    Root exception is java.lang.ClassNotFoundException: weblogic/jndi/WLInitialContextFactory
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:207)
    at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:649)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
    at javax.naming.InitialContext.init(InitialContext.java:219)
    at javax.naming.InitialContext.<init>(InitialContext.java:195)
    when I search this problem in java.sun.com,an article announce that it is a bug that
    JNDI not support multi-threads call,and it is fixed is JDK1.4 beta. The link is:
    http://developer.java.sun.com/developer/bugParade/bugs/4307751.html
    It seems that weblogic's JNDI is not support multi-thread call. what can i do?

    Try adding the following code before instantiating your initial context:
    Thread.currentThread().setContextClassLoader( ClassLoader.getSystemClassLoader()
    This fixed the problem for me.
    -Brian
    "Edward Lu" <[email protected]> wrote:
    >
    Help me! I'm using jni to call weblogic EJB from a Com+ component,here is
    the code:
    // This is the main project file for VC++ application project
    // generated using an Application Wizard.
    #include "stdafx.h"
    #pragma unmanaged
    #include <windows.h>
    #include <jni.h>
    #include <process.h>
    #include <stdio.h>
    #define USER_CLASSPATH "C:\\myClasses;C:\\j2sdk1.4.0\\lib\\tools.jar;Z:\\wlserver6.1\\lib\\weblogic.jar;"
    /* where Prog.class is */
    JavaVM *jvm;
    * Function GetJNIEnv(void) returns the java environment pointer
    * in case we are executing on a thread other than the one the
    * jvm was created on.
    JNIEnv* GetJNIEnv(void){
         JNIEnv *env = NULL;
         jint nRet = jvm->GetEnv((void **)&env, JNI_VERSION_1_2);
         if(nRet == JNI_EDETACHED){
              jvm->AttachCurrentThread((void **)&env, NULL);
         return env;
    * Function DoJNDI(void *arg) uses the Java Invocation API to
    * execute the following Java code:
    * Hashtable prop = new Hashtable();
    * prop.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"
    * prop.put( Context.PROVIDER_URL, "t3://192.168.40.137:7001" );
    * ctxInitial = new InitialDirContext( prop );
    void DoJNDI(void *arg){
         jclass clsHash, clsInitDirCx;
         jmethodID mHashInit, mHashPut, mInitDirCxInit;
         jobject objHash, objInitDirCx;
         JNIEnv *env = GetJNIEnv(); // Get the environment if on a different thread
         clsHash = env->FindClass("java/util/Hashtable");
         mHashInit = env->GetMethodID(clsHash, "<init>", "()V");
         objHash = env->NewObject(clsHash, mHashInit);
         mHashPut = env->GetMethodID(clsHash, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
         jstring jstrICxFactoryPut = env->NewStringUTF("java.naming.factory.initial");
         jstring jstrICxFactoryVal = env->NewStringUTF("weblogic.jndi.WLInitialContextFactory");
         env->CallObjectMethod(objHash, mHashPut, jstrICxFactoryPut,jstrICxFactoryVal);
         jstring jstrProviderUrlPut = env->NewStringUTF("java.naming.provider.url");
         jstring jstrProviderUrlVal = env->NewStringUTF("t3://192.168.40.137:7001");
         env->CallObjectMethod(objHash, mHashPut, jstrProviderUrlPut,jstrProviderUrlVal);
         clsInitDirCx = env->FindClass("javax/naming/InitialContext");
         mInitDirCxInit = env->GetMethodID(clsInitDirCx, "<init>", "(Ljava/util/Hashtable;)V");
         objInitDirCx = env->NewObject(clsInitDirCx, mInitDirCxInit, objHash);
         if(objInitDirCx == NULL){
              printf("%s test FAILED:\n\n", (char*)arg);
         else{
              printf("%s test PASSED\n\n", (char*)arg);
         jvm->DetachCurrentThread();
    * Function main(void) creates a JVM, and calls DoJNDI twice:
    * Once as a regular function call, and once as a spun off thread.
    void main() {
    JavaVMInitArgs vm_args;
    JavaVMOption options[5];
         options[0].optionString = "-client";
    options[1].optionString =
    "-cp " USER_CLASSPATH;
    options[2].optionString =
    "-Djava.class.path=" USER_CLASSPATH;
         //options[3].optionString =
         //     "-Xbootclasspath:c:\\j2sdk1.4.0\\lib\\tools.jar;z:\\wlserver6.1\\lib\\weblogic_sp.jar;z:\\wlserver6.1\\lib\\weblogic.jar;";
         options[3].optionString =
              "-Xbootclasspath/a:c:\\j2sdk1.4.0\\lib\\tools.jar;z:\\wlserver6.1\\lib\\weblogic_sp.jar;";
         options[4].optionString =
              "-Xbootclasspath/p:c:\\j2sdk1.4.0\\lib\\tools.jar;z:\\wlserver6.1\\lib\\weblogic_sp.jar;";
    vm_args.version = 0x00010002;
    vm_args.options = options;
    vm_args.nOptions = 5;
    vm_args.ignoreUnrecognized = JNI_TRUE;
         JNIEnv *env;
         jint res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
         // *** Make the magic calls! (Both lines should do the same thing) ***
         DoJNDI((void*)"Function call");
         _beginthread(DoJNDI,0,(void *)"Thread call");
         /* wait for thread(s) to finish */
         Sleep(5000);
         jvm->DestroyJavaVM();
    But it always send me a Exception like below:
    javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory.
    Root exception is java.lang.ClassNotFoundException: weblogic/jndi/WLInitialContextFactory
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:207)
    at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:649)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
    at javax.naming.InitialContext.init(InitialContext.java:219)
    at javax.naming.InitialContext.<init>(InitialContext.java:195)
    when I search this problem in java.sun.com,an article announce that it is
    a bug that
    JNDI not support multi-threads call,and it is fixed is JDK1.4 beta. The
    link is:
    http://developer.java.sun.com/developer/bugParade/bugs/4307751.html
    It seems that weblogic's JNDI is not support multi-thread call. what can
    i do?

  • Java.lang.UnsatisfiedLinkError - Unknown file type.

    Hi
    I am trying load a library file A.so using System.load function and I get the below error
    java.lang.UnsatisfiedLinkError: /u1/weblogic/weblogic92/weblogic92/server/native
    /solaris/sparc/A.so: ld.so.1: java: fatal: /u1/weblogic/weblogic92/weblogic92/server/native
    /solaris/sparc/A.so: unknown file type (Possible cause: endianness mismatch)
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1647)
    at java.lang.Runtime.load0(Runtime.java:769)
    at java.lang.System.load(System.java:968)
    Can some one please help.
    Also when I am using the libraries of next version,I get the below error
    java.lang.UnsatisfiedLinkError: /u1/weblogic/weblogic92/weblogic92/server/native
    /solaris/sparc/A.so: ld.so.1: java: fatal: /u1/weblogic/weblogic92/weblogic92/server/native
    /solaris/sparc/A.so: wrong ELFCLASS:ELFCLASS32(Possible cause: architecture word width mismatch)
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1647)
    at java.lang.Runtime.load0(Runtime.java:769)
    at java.lang.System.load(System.java:968)
    Thanks
    Phani

    phani_sridhar wrote:
    Hi
    I am trying load a library file A.so using System.load function and I get the below error
    java.lang.UnsatisfiedLinkError: /u1/weblogic/weblogic92/weblogic92/server/native
    /solaris/sparc/A.so: ld.so.1: java: fatal: /u1/weblogic/weblogic92/weblogic92/server/native
    /solaris/sparc/A.so: unknown file type (Possible cause: endianness mismatch)
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1647)
    at java.lang.Runtime.load0(Runtime.java:769)
    at java.lang.System.load(System.java:968)
    Can some one please help.
    Also when I am using the libraries of next version,I get the below error
    java.lang.UnsatisfiedLinkError: /u1/weblogic/weblogic92/weblogic92/server/native
    /solaris/sparc/A.so: ld.so.1: java: fatal: /u1/weblogic/weblogic92/weblogic92/server/native
    /solaris/sparc/A.so: wrong ELFCLASS:ELFCLASS32(Possible cause: architecture word width mismatch)
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1647)
    at java.lang.Runtime.load0(Runtime.java:769)
    at java.lang.System.load(System.java:968)
    I see several possibilities.
    1. What you are trying to load is not a shared library.
    2. The shared library is compiled incorrectly to match the process space of the VM. There can be any number of causes for this.
    Note that the word width mismatch strongly suggests the second.
    You should start by forgetting weblogic entirely. Write a simple java app and using an explicit path in the load() method, not loadLibrary(), get it to load. Until it works there it you have no chance in weblogic.

  • Ifs Connection problem from local machine to Ifs server using API

    I am trying to make an API call to connect to Ifs database server running on different machine(UNIX) from local machine. I copied all jar files and /Lib/Ifs/Settings directory to my local machine. All these files are in the classpath of weblogic 6.0 environment. A jsp on weblogic server call a bean which has a responsibibility of connecting to Ifs server to get LibrarySession.
    From Visual Cafe 4.5 everything works fine but when i start weblogic 6.0 outside the visual cafe environment i get the error
    below. I included all the jar files and /Lib/Ifs/Settings in start up script of weblogic server
    Do you know if i missing some thing????
    java.lang.UnsatisfiedLinkError: do_open
    at oracle.jdbc.oci8.OCIDBAccess.do_open(Native Method)
    at oracle.jdbc.oci8.OCIDBAccess.logon(OCIDBAccess.java:309)
    at oracle.jdbc.driver.OracleConnection.(OracleConnection.java:198)
    at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
    va:251)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:224)
    at java.sql.DriverManager.getConnection(DriverManager.java:517)
    at java.sql.DriverManager.getConnection(DriverManager.java:177)
    at oracle.ifs.server.LibraryConnection.(LibraryConnection.java:235
    at oracle.ifs.server.ConnectionPool.createLibraryConnection(ConnectionPo
    ol.java:576)
    at oracle.ifs.server.ConnectionPool.(ConnectionPool.java:321)
    at oracle.ifs.server.S_LibraryService.(S_LibraryService.java:912)
    at oracle.ifs.server.S_LibraryService.startService(S_LibraryService.java
    :1129)
    at oracle.ifs.beans.LibraryService.connectLocal(LibraryService.java:408)
    at oracle.ifs.beans.LibraryService.connect(LibraryService.java:280)

    Have you installed the Oracle client software on the machine where you are running WebLogic and your custom iFS application (your bean)?
    It looks like the native JDBC libraries are not available to the JVM where WebLogic is executing your code. iFS uses JDBC to access the Oracle database, and it requires "thick" (OCI8) JDBC to do so. This means that you need Oracle client software to be installed (in an ORACLE_HOME directory) on a computer where you want to use the iFS API.
    If you do have the Oracle client software installed already, then perhaps the WebLogic environment isn't configured to have access to the native JDBC libraries. Normally, as long as $ORACLE_HOME/lib is in the LD_LIBRARY_PATH (on unix) or $ORACLE_HOME/bin is in the PATH (on windows), stuff should just work.
    See if you can find any information about including native libraries (for instance, to use JNI) in the WebLogic documentation. We don't certify with WebLogic, which is why I don't know the answer offhand.

  • WLS 5.1 and prevent caching on cache server

    Hi,
    Is there any method to prevent caching for *.jar files or any other
    static resources on client side cache server ?
    It seems to be possible by making filter programs that insert
    statement <meta http-equiv="Pragma" content="no-cache">
    into http response header if using WLS 7.1
    but we are using WLS5.1 SP13.

    I'm running native io. How would I use green threads with jdk1.3?
    I didn't think I could.
    thanks,
    lisa
    Chris Shipman <[email protected]> wrote:
    are you runing native io, or running green threads? try
    green threads.
    Lisa Klag wrote:
    I'm having problems getting WLS to run under JDK 1.3.I keep getting
    the following exception:
    Tue Feb 27 15:55:00 GMT+00:00 2001:<A> <SSLListenThread>ListenThread.run()
    failed:
    java.lang.UnsatisfiedLinkError: /opt/weblogic/5.10/lib/linux/libweblogicunix1.so:
    /opt/weblogic/5.10/lib/linux/libweblogicunix1.so: undefinedsymbol:
    makeCString
    at java.lang.ClassLoader$NativeLibrary.load(NativeMethod)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1382)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1306)
    at java.lang.Runtime.loadLibrary0(Runtime.java:749)
    at java.lang.System.loadLibrary(System.java:820)
    at weblogic.platform.Unix.<init>(Unix.java:14)
    at java.lang.Class.newInstance0(Native Method)
    at java.lang.Class.newInstance(Class.java:237)
    at weblogic.platform.OperatingSystem.getOS(OperatingSystem.java:77)
    at weblogic.t3.srvr.T3Srvr$1.run(T3Srvr.java:1160)
    at weblogic.t3.srvr.Callback.done(Callback.java:37)
    at weblogic.t3.srvr.SSLListenThread.newServerSocket(SSLListenThread.java:474)
    at weblogic.t3.srvr.ListenThread.run(ListenThread.java:245)

  • Weblogic server 8.1 JNI module deployment java.lang.UnsatisfiedLinkError

    This is on the weblogic 8.1 Solaris platform.
    We have a module in our application which uses the native shared library and makes JNI called from the J2EE application. We have added the .so files to the LD_LIBRARY_PATH environment variable in our managed server startup scripts. When we start our servers the module works fine. But when we redeploy the J2EE application, the java code is changed but we start getting java.lang.UnsatisfiedLinkError exception when the module is invoked. We are using the staged mode for deployment. We have to shut down the managed servers and restart them every time for this module to start working after the redeployment of the J2EE application.
    Is this a known problem with the JNI based application. Is there any setting that we are missing? Has this problem been fixed in any of the service packs?

    Have you checked to see if your file descriptor setting is set high enough? Disabling native IO is not a very good solution as it will drastically reduce performance.
    --Raheem                                                                                                                                                                                                                                                                                                                                                                   

  • Using JNI with weblogic JSP & Servlets

    I want to use native libraries from JSP and Servlets.
              Everything works fine befire redeploying.
              After redeploying there is an error:
              Servlet failed with Exception
              java.lang.UnsatisfiedLinkError: Native Library D:\WINNT\system32\XXXX.dll
              already loaded in another classloader
              at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1346)
              at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1306)
              at java.lang.Runtime.loadLibrary0(Runtime.java:749)
              at java.lang.System.loadLibrary(System.java:820)
              at HelloWorld.<clinit>(HelloWorld.java:9)
              at NativeTestServlet.doGet(NativeTestServlet.java:31)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
              at
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
              :208)
              at
              weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
              ntext.java:1127)
              at
              weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
              :1529)
              at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              >
              Can anybody solve it?
              Best wishes, Oleg.
              

    Java will not allow us to reload any class that is dependent on a native
              library. I suggest that any classes that depend on native code should be
              put in the system classpath. If you change these classes or the native
              library you will need to restart your server.
              Sam
              "Jennifer Yin" <[email protected]> wrote in message
              news:[email protected]...
              > Oleg-
              >
              > I'm having the exact same problem and was wondering how you fixed it. I
              ran
              > javah -jni <classname> to verify the correct method call and have also
              verified
              > that the library file is included in the system path.
              >
              > Any other suggestions?
              >
              > Jennifer
              >
              > Oleg wrote:
              >
              > > I want to use native libraries from JSP and Servlets.
              > > Everything works fine befire redeploying.
              > > After redeploying there is an error:
              > >
              > > Servlet failed with Exception
              > > java.lang.UnsatisfiedLinkError: Native Library
              D:\WINNT\system32\XXXX.dll
              > > already loaded in another classloader
              > > at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1346)
              > > at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1306)
              > > at java.lang.Runtime.loadLibrary0(Runtime.java:749)
              > > at java.lang.System.loadLibrary(System.java:820)
              > > at HelloWorld.<clinit>(HelloWorld.java:9)
              > > at NativeTestServlet.doGet(NativeTestServlet.java:31)
              > > at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
              > > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
              > > at
              > >
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
              > > :208)
              > > at
              > >
              weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
              > > ntext.java:1127)
              > > at
              > >
              weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
              > > :1529)
              > > at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
              > > at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              > > >
              > >
              > > Can anybody solve it?
              > >
              > > Best wishes, Oleg.
              >
              

  • Problems using JNI and JSP in WebLogic 6.0

    Hello everybody. My problem is that I've got a Java class that is called from a JSP. That class connects to a C function and it returns a String. A want this string to be shown by the JSP. The code is:
    JSP
    <html>
    <head>
    <title>prueba JNI</title>
    </head>
    <body>
    <%@ page import="ejemplosJNI.*, conversiones.*;"%>
    <%
    Texto texto = new Texto();
    out.println(texto.realizado());
    %>
    </body>
    </html>
    Java class
    package ejemplosJNI;
    public class Texto
    private native String getLine(String prompt);
    String input = null;
    public static void main(String args[])
    Texto t = new Texto();
    static
    System.loadLibrary("MyImpOfPrompt");
    public String realizado()
    input = this.getLine("Mando una l�nea desde Java");
    return input;
    C function
    #include <stdio.h>
    #include <jni.h>
    #include "Texto.h"
    JNIEXPORT jstring JNICALL
    Java_Texto_getLine(JNIEnv *env, jobject obj, jstring prompt)
    char buf[128];
    const char str = (env)->GetStringUTFChars(env, prompt, 0);
    (*env)->ReleaseStringUTFChars(env, prompt, str);
    return (*env)->NewStringUTF(env, str);
    I compile de C function and put the .dll library in the 'bin' folder in webLogic.
    When I call the JSP, I get the next exception:
    Servlet failed with Exception
    java.lang.UnsatisfiedLinkError: getLine
    at ejemplosJNI.Texto.getLine(Native Method)
    at ejemplosJNI.Texto.realizado(Texto.java:19)
    at jsp_servlet._jsp._pruebasjni._prueba1._jspService(_prueba1.java:93)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
    pl.java:213)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
    pl.java:246)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
    rvletContext.java:1265)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
    pl.java:1622)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    Is there any place where I have to put the .dll?
    Is there any place where I have to put the generated .lib?
    Where do I have to put the Texto.h file generated with javah?
    Can anybody help me to solve this problem?
    Thanks in advance.

    Hi, jschell! Maybe you can see my problem if I give you the code. My Java class and the C funtions are:
    Java class
    package ejemplos.cadena;
    public class Texto
    private native String getLine(String prompt) throws Exception;
    String cadenaFinal = null;
    public static void main(String args[])
    Texto t = new Texto();
    static
    System.loadLibrary("LibreriaCadena");
    public String realizado(String cadena)
    try
    cadenaFinal = getLine(cadena);
    catch(Exception e)
    System.out.println(e.toString());
    return cadenaFinal;
    C code
    #include <stdio.h>
    #include <jni.h>
    #include "ejemplos_cadena_Texto.h"
    JNIEXPORT jstring JNICALL
    Java_ejemplos_cadena_Texto_getLine(JNIEnv *env, jobject obj, jstring prompt)
    int cero =0;
    int division = 10 / cero;
    const char str = (env)->GetStringUTFChars(env, prompt, 0);
    (*env)->ReleaseStringUTFChars(env, prompt, str);
    return (*env)->NewStringUTF(env, str);
    I have done something like "int division = 10 / cero;" in order to get an exception in my C code. When I run my Java class I get an error message and the application breaks. I would like to know how to catch the C exception in order to pass it to my Java class that can manage it into the try-catch clause. I have read I have to use something like "FindClass" or "ThrowNew", but my problem is that I have no idea about C programming.
    Can you help me?
    Thanks for your time.

  • UnsatisfiedLinkError with JNI

    I have what I think is a strange problem, because last year this program worked, and this year it doesn't. Obviously something has changed, but I can't figure out what.
    What I am doing here is using the JNI to call a Native Method to get some data from a A/D.
    However, now when I try to call that method, I get the following error:
    Caused by java.lang.UnsatisfiedLinkError; fileiotest.dllinterface.startget()UAlso, here is the code for the dllinterface file. It's simple and short, so I think I can paste the whole thing
    package fileiotest;
    * @author Owner
    public class dllinterface {
        public native void startget(int channels);
        public native float[] getpoint(int channels);
        public native float[] gettimepoint(int channels);
        public native void stopget();
        private static dllinterface DI;
        private float newtempfloat[] = new float[9];
        static {
         System.loadLibrary("daqdll");//This is firstJNI.DLL
         DI = new dllinterface();
         /*if generated by borland
         System.loadLibrary("firstjni");//This is firstjni.dll
        public void start_daq(int channels)
         DI.startget(channels);
        public void stop_daq()
           DI.stopget();
        public float[] get_data_point(int channels)
          newtempfloat = DI.getpoint(channels);
          return newtempfloat;
        public float[] get_data_time_point(int channels)
          newtempfloat = DI.gettimepoint(channels);
          //System.out.println(newtempfloat[channels]);
          return newtempfloat;
    }Edited by: Mike_Keller on Aug 2, 2010 8:02 AM

    You are loading the dll successfully.
    So that means the dll changed.

  • Canot call Weblogic Bean from Delphi via JNI

    I tried to call a bean within the weblogiv server 7 from Delphi.
    I use a JNI Wrapper which allows me easily to acces normal java objects.
    I can call the bean from a java application.
    When i try to call the bean via jni, the following error occurs:
    weblogic.utils.AssertionError: ***** ASSERTION FAILED *****
    [ Assertion violated] at weblogic.utils.Debug.assertion(Debug.java:74)
    at weblogic.j2ee.ApplicationManager.loadClass(ApplicationManager.java:258)
    at weblogic.j2ee.ApplicationManager.loadClass(ApplicationManager.java:233)
    at weblogic.rmi.internal.ClientRuntimeDescriptor.computeInterfaces(ClientRuntimeDescriptor.java:224)
    at weblogic.rmi.internal.ClientRuntimeDescriptor.intern(ClientRuntimeDescriptor.java:123)
    at weblogic.jndi.WLInitialContextFactoryDelegate.<clinit>(WLInitialContextFactoryDelegate.java:165)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:145)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:671)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:242)
    at javax.naming.InitialContext.init(InitialContext.java:218)
    at javax.naming.InitialContext.<init>(InitialContext.java:194)
    at ejbtest3.ejbtest3sbTestClient1.getInitialContext(ejbtest3sbTestClient1.java:104)
    at ejbtest3.ejbtest3sbTestClient1.init(ejbtest3sbTestClient1.java:32)
    at ejbtest3.ejbtest3sbTestClient1.testmain(ejbtest3sbTestClient1.java:277)
    It seems that i canno create a context object, but i do not know why ...
    So i would be glad if anyone could help me here ...
    Regards Robert

    I would try this with the newest service pack since it seems this assertion does
    not exist in later code lines. It appears to be related to a class loader
    issue. Do you know what version of the Java VM Delphi uses?
    Sam
    robert wrote:
    I tried to call a bean within the weblogiv server 7 from Delphi.
    I use a JNI Wrapper which allows me easily to acces normal java objects.
    I can call the bean from a java application.
    When i try to call the bean via jni, the following error occurs:
    weblogic.utils.AssertionError: ***** ASSERTION FAILED *****
    [ Assertion violated] at weblogic.utils.Debug.assertion(Debug.java:74)
    at weblogic.j2ee.ApplicationManager.loadClass(ApplicationManager.java:258)
    at weblogic.j2ee.ApplicationManager.loadClass(ApplicationManager.java:233)
    at weblogic.rmi.internal.ClientRuntimeDescriptor.computeInterfaces(ClientRuntimeDescriptor.java:224)
    at weblogic.rmi.internal.ClientRuntimeDescriptor.intern(ClientRuntimeDescriptor.java:123)
    at weblogic.jndi.WLInitialContextFactoryDelegate.<clinit>(WLInitialContextFactoryDelegate.java:165)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:145)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:671)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:242)
    at javax.naming.InitialContext.init(InitialContext.java:218)
    at javax.naming.InitialContext.<init>(InitialContext.java:194)
    at ejbtest3.ejbtest3sbTestClient1.getInitialContext(ejbtest3sbTestClient1.java:104)
    at ejbtest3.ejbtest3sbTestClient1.init(ejbtest3sbTestClient1.java:32)
    at ejbtest3.ejbtest3sbTestClient1.testmain(ejbtest3sbTestClient1.java:277)
    It seems that i canno create a context object, but i do not know why ...
    So i would be glad if anyone could help me here ...
    Regards Robert

  • JNI exception, java.lang.UnsatisfiedLinkError

    Hi,
    I�m trying to call a native method with JNI and the following exception occurs when I try to call the native method setFileName:
    Exception occurred during event dispatching:
    java.lang.UnsatisfiedLinkError: setFileName
    The dll where this method is defined is in the directory c:/winnt/system32, the Windows default path.
    Why this exception occurs?
    Thanks in advance
    carlos

    The basic reasons why this would occur are
    1. There is something wrong with the path to the dll.
    2. You didn't do a "loadLibrary()" on the dll before you called the native method.
    3. There is some disconnect between the expected signature of the native method, and the way it is defined in the dll.
    If this doesn't help, thenI suggest you post a bit of code (loadLibrary, native method signature, C function signature).

  • UnsatisfiedLinkError for JNI DLL compiled with vs2008 express

    I am trying to create a JNI DLL using Visual Studio 2008 Express.
    I have read several places where -MD causes JNI problems but from what I've read, I need this option to create the DLL properly.
    The DLL does get built cleanly and I have created a simple C application (obviously not calling the JNI functions themselves but the other functions that are in the DLL). This application runs with no problems.
    As soon as I try to use the DLL with JNI, I get an UnsatisfiedLinkError: Can't find dependent libraries.
    I have used Dependency Walker on the C application I created and it finds no errors; however, if I run it on the DLL itself, it does report an error trying to find msvcr90.dll which is in the winsxs directory under c:\windows so I assume this is the problem dependency.
    I am running this on the same computer that has Visual Studio 2008 Express SP1 installed. This is a Windows XP Service Pack 3 computer running JDK 1.6.0_14.
    Any help would be greatly appreciated.
    Thanks

    Right or wrong, I include some library files into my link statement (it's the only way I could find to clear up your question). I link in some standard window libraries as well as some of my own DLL whose functions are used by this DLL. I use a makefile to build my code.
    Here is a compile statement and the link statement for my DLL:
    cl.exe -I c:\progra~1\micros~1.0\vc\include -I c:\progra~1\mi2578~1\windows\v7.0\include -I c:/progra~1/java/jdk1.6.0_14/include -I c:/progra~1/java/jdk1.6.0_14/include/Win32 -I S:/wlw/Develop/Src/Include -I S:/wlw/Products/Src/Include -I S:/wlw/Products/Src/Include -I S:/wlw/Products/Src/LibSrc/RTA/Client/Include/Example -I S:/wlw/Products/Src/LibSrc/RTA/Client/Include/System -I S:/wlw/Products/Src/LibSrc/RTA/Client/Include/User -I S:/wlw/Products/Src/LibSrc/RTA/Server/Include/System -I S:/wlw/Products/Src/LibSrc/RTA/Server/Include/User -DRTA_DLL -D_BIND_TO_CURRENT_VCLIBS_VERSION -Zp4 -DWIN32 -D__WIN32__ -DWINVER=0x0400 -D_WIN32_WINNT=0x0400 -D_USE_32BIT_TIME_T -D_CRT_SECURE_NO_WARNINGS -nologo -W3 -Od -EHsc -MD -Z7 -c buildDate.c
    link.exe -incremental:no -nologo -debug kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib -dll -out:S:/wlw/Products/Obj/Win32/Lib/rta.dll -implib:S:/wlw/Products/Obj/Win32/Lib/rta.lib eipc_client.obj eipc_usersys.obj eips_pccc.obj eips_cnxn.obj eips_cpf.obj eips_encap.obj eips_iomsg.obj eips_rtasys.obj eips_timer.obj rta_utils.obj eips_userdf1.obj eips_userobj.obj eips_usersock.obj eips_usersys.obj jniRta.obj jniRtaPlc.obj jniRtaPlcAddress.obj qcRta.obj qcRtaPlcAddressLink.obj qcRtaPlcLink.obj qcRtaProcess.obj qcRtaRead.obj qcRtaSlcRead.obj qcRtaSlcWrite.obj qcRtaState.obj qcRtaTimer.obj qcRtaWrite.obj Q:/Develop/Obj/Win32/Lib/tcpipNet.lib Q:/Develop/Obj/Win32/Lib/linkList.lib Q:/Develop/Obj/Win32/Lib/stdUtils.lib buildDate.obj
    mt -manifest S:/wlw/Products/Obj/Win32/Lib/rta.dll.manifest -outputresource:S:/wlw/Products/Obj/Win32/Lib/rta.dll;2

  • "Exception in thread "main" java.lang.UnsatisfiedLinkError:"  JNI in Linux

    Hi,
    I am writing a simple program to understand how JNI works so that I can use this concept to develop a project. But after running the simple code,
    It gives the following error:
    Exception in thread "main" java.lang.UnsatisfiedLinkError: sum
    at TestJni.main(testJni.java:25)
    My Java code is:
    import java.io.*;
    import java.util.*;
    class TestJni
    // Try to load the native Code library for user Authentication.
    static
    try
    System.loadLibrary( "test" );
    catch( UnsatisfiedLinkError e )
    System.out.println("Could not load native code for user authentication." );
    System.exit(1);
    public static void main( String [] args )
    //TestJni obj = new TestJni();
    System.out.println(TestJni.sum(2, 3));
    public static native int sum( int x, int y );
    TestJni.h looks like:
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class TestJni */
    #ifndef IncludedTestJni
    #define IncludedTestJni
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class: TestJni
    * Method: sum
    * Signature: (II)I
    JNIEXPORT jint JNICALL Java_TestJni_sum
    (JNIEnv *, jclass, jint, jint);
    #ifdef __cplusplus
    #endif
    #endif
    and my C++ code is:
    #include <jni.h>
    #include "TestJni.h"
    #include <stdio.h>
    JNIEXPORT jint JNICALL Java_TestJni_sum(JNIEnv *env, jclass obj, jint x, jint y)
    printf("Inside the native function\n");
    return (x + y);
    Then I am generating my .so file as:
    g++ -o libtest.so sum.cpp -shared -fpic -lcrypt -I//usr/lib/j2se/1.4/include -I/usr/lib/j2se/1.4/include/linux
    and copying the libtest.so file into the folder where I have my TestJni.class file. Then running the java code by:
    java TestJni
    but it gives the "UnsatisfiedLinkError". What to do? :( I have spend 2 days now to solve this problem but I am not getting it.
    I am using ubuntu 7.10 as my OS.
    Please let me know if you can help.

    Thanks for your response. I found that, when I copied the shared library to /usr/lib and
    did: ldconfig -n /usr/lib it worked
    But the problem is, this is my computer, but the computers that I am going to run my actual
    JNI application, have restrictive permission. Could anyone please let me know how I can
    do the work without ldconfig. I mean is there anyway I can configure my .so file's path without
    copying it into the /usr/lib folder and without ldconfig?
    I will appreciate any reply. Thanks.

Maybe you are looking for