7 Replies Latest reply on Jan 15, 2003 5:34 AM by Andy Godwin

    JNI calls in MBean

    Sokto Shaidorov Newbie

      Hi,

      Is there any way to use JNI calls in MBean?

      Jboss version is 3.0.4.

      I get UnsatisfiedLinkError exception

      Thanks

        • 1. Re: JNI calls in MBean
          Greg Turner Apprentice

          You ask Jndi for an RMIConnector to the MBeanServer. Then you invoke methods on MBeans by using the invoke method of the MBeanServer. Details are in the Admin Guide

          • 2. Re: JNI calls in MBean
            David Jencks Master

            As far as I know there is nothing preventing jni calls from an mbean. You can only deploy a native library once, which makes including it in a redeployable java package problematical.

            My experiments with hot deploying a half-java half-native (closed source) driver eventually failed due to the native library loading code in the java part ot the driver, but got far enough that I suspect that you have not successfully deployed the native library.

            • 3. Re: JNI calls in MBean
              Andy Godwin Newbie

              UnsatisfiedLinkError means the VM can't find your native
              library ... the library must be on the system path, not
              the classpath.

              Generally, using JNI in MBeans is fine, but, as David
              says, you can't redeploy a native library ... that's
              a VM issue, nothing to do with JBoss. If you do need
              to, you can always write a simple wrapper library that
              just loads and unloads your real library in response
              to the MBean start and stop service methods.

              • 4. Re: JNI calls in MBean
                Andy Godwin Newbie

                UnsatisfiedLinkError means the VM can't find your native
                library. A native library must be on the system path,
                not the classpath, in order to be found.

                Generally, JNI in MBeans works fine, but, as David said,
                you can't redeploy a native library ... that's a VM
                issue, nothing to do with JBoss. If you do need this,
                tho, you can always write a simple wrapper library that
                loads and unloads your real library in the MBean start
                and stop service methods.

                • 5. Re: JNI calls in MBean
                  Andrew Collins Newbie

                  > Generally, using JNI in MBeans is fine, but, as
                  > David says, you can't redeploy a native library
                  > ... that's a VM issue, nothing to do with JBoss.
                  > If you do need to, you can always write a simple
                  > wrapper library that just loads and unloads your
                  > real library in response to the MBean start and
                  > stop service methods.

                  How would you write such a load/unload wrapper?

                  • 6. Re: JNI calls in MBean
                    Adrian Brock Master

                    AFAIK the problem with hotdeploying JNI is that
                    you cannot reload the library until the referencing
                    class is garbage collected.
                    Something that is hard to control.

                    This should not stop one-time deployment.

                    Regards,
                    Adrian

                    • 7. Re: JNI calls in MBean
                      Andy Godwin Newbie

                      In Win32 land, LoadLibrary() and FreeLibrary() do the
                      job ... don't know about any other platforms.