Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-4842

A resource packaged in a RAR file fails to call a native library packaged in the same RAR.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 8.2.0.Final, 9.0.0.CR2
    • JCA
    • None
    • Windows 7, 64-bit

    • Hide

      Create a JCA resource adapter with a connection implementation, which contains a native method. Package the native library, which implements the method in the same RAR as the resource adapter, making sure that the native library matches your current platform.

      Upon deployment, the native library will be extracted and loaded into WildFly's process space. However, first call to the native method in the RA connection will throw UnsatisfiedLinkError, because the classloader, which is used to load RA classes is different from the classloader, which holds the reference to the loaded native library.

      The easiest way to test this is to build the native connector example from the IronJacamar project located here: http://www.ironjacamar.org/doc/userguide/1.1/en-US/html_single/index.html#sample_helloworld_native and attempt to invoke it from a Java EE application.

      Show
      Create a JCA resource adapter with a connection implementation, which contains a native method. Package the native library, which implements the method in the same RAR as the resource adapter, making sure that the native library matches your current platform. Upon deployment, the native library will be extracted and loaded into WildFly's process space. However, first call to the native method in the RA connection will throw UnsatisfiedLinkError, because the classloader, which is used to load RA classes is different from the classloader, which holds the reference to the loaded native library. The easiest way to test this is to build the native connector example from the IronJacamar project located here: http://www.ironjacamar.org/doc/userguide/1.1/en-US/html_single/index.html#sample_helloworld_native and attempt to invoke it from a Java EE application.
    • Workaround Exists
    • Hide

      If the native library is placed in one of the directories listed in java.library.path, it will be loaded by the RA classloader and calls to native methods succeed.

      Show
      If the native library is placed in one of the directories listed in java.library.path, it will be loaded by the RA classloader and calls to native methods succeed.

      JSR322, section 20.2.0.2, specifies that native libraries, packaged at an arbitrary location in a resource adapter's RAR file, will be made available to resource adapter's managed code. In fact, section 20.2.0.1 requires that the platform-specific libraries be packaged with the resource adapter module instead of being placed on java.library.path. However, attempting to access a native library included in a RAR from resource adapter code on WildFly results in an UnsatisfiedLinkError.

              jpederse@redhat.com Jesper Pedersen
              alashchuk Alex Lashchuk (Inactive)
              Votes:
              3 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated: