8 Replies Latest reply on Feb 22, 2018 4:54 PM by Richard Cannock

    Unsatisfied Link Error -Apache Wildfly 11 -  OpenCV Java 3.3.

    Richard Cannock Newbie

      HI,

       

      On windows (Server 2012 R2 64 bit), jdk1.8.0_151, running wildfly 11, and OpenCV 3.3.1.jar

       

      - I am attempting to run the simplest sample code provided by OpenCV 3.3.1 (https://opencv.org/releases.html ) for it's JNI Java binding:

                System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
               
      Mat mat = Mat.eye(3, 3, CvType.CV_8UC1);
               
      System.out.println("mat = " + mat.dump());

      within a message driven bean:

      @MessageDriven(name = "SimpleMessageDrivenBean", activationConfig = { @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "java:/jms/SimpleQueue"), @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")}) public class SimpleMessageDrivenBean implements MessageListener { @Override public void onMessage(Message message) { try { System.out.println(Core.NATIVE_LIBRARY_NAME); System.loadLibrary(Core.NATIVE_LIBRARY_NAME); Mat mat = Mat.eye(3, 3, CvType.CV_8UC1); System.out.println("mat = " + mat.dump());  System.out.println("Got message: " + ((TextMessage)message).getText() + " @" + System.currentTimeMillis()); } catch (JMSException e) { e.printStackTrace(); } catch(Exception ex) { ex.printStackTrace(); }  }

      This MDB is executed by a rest service that places a message on the queue.

       

      As expected, upon executing this code, I get a Caused by: java.lang.UnsatisfiedLinkError: no opencv_java331 in java.library.path

       

      Once I place the native library opencv_java331.dll in C:\Windows\ on the server in question, this error changes to:

       

      Caused by: java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_eye(III)J

       

      which suggests that although the native library has been loaded, it is now failing to load some dependency of the opencv_java331.dll (which is supposed to be standalone).

       

      Using the same dll and -Djava.library.path="C:\opencv\build\java\x64" to the same Dll within a J2SE project (under netbeans) works, so this suggests that there is some different behaviour under wildfly in terms of loading native libraries.

       

      In addition to placing opencv_java331.dll in C:\Windows\,  I have also attempted putting  opencv_java331.dll  in the lib folder and variants paths within the lib folder (win-x86_64) of the underlying ear archive but this causes the error to revert to to java.lang.UnsatisfiedLinkError: no opencv_java331 in java.library.path.

       

      Can anyone offer any assistance?

       

      Many thanks

       

      Richard

        • 1. Re: Unsatisfied Link Error -Apache Wildfly 11 -  OpenCV Java 3.3.
          Tomaz Cerar Master

          Probably best thing you should do is to package opencv to a module in wildfly installation and then add native libs (and all jars) to it.

           

          some docs on this topic JBoss Modules: version 1.x

          • 2. Re: Unsatisfied Link Error -Apache Wildfly 11 -  OpenCV Java 3.3.
            Richard Cannock Newbie

            Thank you Tomaz,

             

            My message driven bean and the rest webservice that puts a message on its queue are contained in an .ear archive (respectively inside a .ejb and .war archive) which is deployed to wildfly.

             

            Does the module need to contain all of these elements or just the opencv jar and it's native dll? if its is the last option, how does my .ear declare a dependency on the new opencv based module?

             

            found the module documentation a bit hard to follow, hence the questions!

             

            thanks

             

            richard

            • 3. Re: Unsatisfied Link Error -Apache Wildfly 11 -  OpenCV Java 3.3.
              Richard Cannock Newbie

              I have further tested this in wildfly 11 on WIndows 8.1 and get the same behaviour i.e unsatsified link error.

               

              I can confirm that the same code in Glassfish does work, and the dll is loaded successfully, so it appears that this is a issue with Wildly loading native libraries.

               

              Can anyone please advise how i raise a formal bug please?

              • 4. Re: Unsatisfied Link Error -Apache Wildfly 11 -  OpenCV Java 3.3.
                jaikiran pai Master

                Hi Richard,

                 

                Can you post the complete stacktrace when you configure a JBoss module? Also, please post the directory tree of this specific JBoss module and the contents of the module.xml.

                 

                Does the module need to contain all of these elements or just the opencv jar and it's native dll? if its is the last option, how does my .ear declare a dependency on the new opencv based module?

                You can create a JBoss module just for the opencv jar and it's native libraries. Then you can add an dependency to this newly created module, using the options noted here Class Loading in WildFly - Latest WildFly Documentation - Project Documentation Editor (you won't need the jboss-deployment-structure.xml for anything as simple as this, so you can use the MANIFEST.MF approach explained there).

                • 5. Re: Unsatisfied Link Error -Apache Wildfly 11 -  OpenCV Java 3.3.
                  David Lloyd Master

                  What it looks like to me is that opencv_java331.dll is referencing symbols in another DLL but for some reason they aren't linking together.  I don't know much about dynamic linking on Windows, being a Linux guy, but I can say that there's no reason I can see that this would work any differently between WF and GF.  Is it possible that GF had an additional configuration for specifying a dynamic library search path?

                  • 6. Re: Unsatisfied Link Error -Apache Wildfly 11 -  OpenCV Java 3.3.
                    David Lloyd Master

                    Maybe there is something extra in the GF "domains/xxx/bin" folder?

                    • 7. Re: Unsatisfied Link Error -Apache Wildfly 11 -  OpenCV Java 3.3.
                      Richard Cannock Newbie

                      Hi, I haven't deployed this as a module, only as a restful web service call inside a stateless session bean. I wasn't sure why a module would be needed.

                       

                      The full stacktrace (from the browser window) is below.

                       

                      21:04:28,895 ERROR [io.undertow.request] (default task-3) UT005023: Exception handling request to /TestJMSMessaging-war/rest/jms: org.jboss.resteasy.spi.UnhandledException: javax.ejb.EJBException: WFLYEJB0442: Unexpected Error

                      at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:78)

                      at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:222)

                      at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:179)

                      at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:422)

                      at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:213)

                      at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:228)

                      at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)

                      at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)

                      at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)

                      at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)

                      at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)

                      at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)

                      at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)

                      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

                      at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)

                      at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)

                      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

                      at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)

                      at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)

                      at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)

                      at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)

                      at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)

                      at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)

                      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

                      at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)

                      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

                      at org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68)

                      at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)

                      at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)

                      at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)

                      at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)

                      at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)

                      at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)

                      at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)

                      at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)

                      at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)

                      at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)

                      at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)

                      at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1508)

                      at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)

                      at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)

                      at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)

                      at io.undertow.server.Connectors.executeRootHandler(Connectors.java:326)

                      at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:812)

                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

                      at java.lang.Thread.run(Thread.java:745)

                      Caused by: javax.ejb.EJBException: WFLYEJB0442: Unexpected Error

                      at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:185)

                      at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:277)

                      at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:332)

                      at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:240)

                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                      at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:509)

                      at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:64)

                      at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:89)

                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                      at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)

                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                      at org.jboss.as.ejb3.component.invocationmetrics.WaitTimeInterceptor.processInvocation(WaitTimeInterceptor.java:47)

                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                      at org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:100)

                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                      at org.jboss.as.ejb3.deployment.processors.StartupAwaitInterceptor.processInvocation(StartupAwaitInterceptor.java:22)

                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                      at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64)

                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                      at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:67)

                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                      at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)

                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                      at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:54)

                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                      at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:60)

                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                      at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:438)

                      at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:609)

                      at org.jboss.invocation.AccessCheckingInterceptor.processInvocation(AccessCheckingInterceptor.java:57)

                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                      at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:53)

                      at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:198)

                      at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:185)

                      at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:81)

                      at test.SimpleJMSRestfulWebService$$$view2.putMessage(Unknown Source)

                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                      at java.lang.reflect.Method.invoke(Method.java:498)

                      at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:140)

                      at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295)

                      at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:249)

                      at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:236)

                      at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:406)

                      ... 43 more

                      Caused by: java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_eye(III)J

                      at org.opencv.core.Mat.n_eye(Native Method)

                      at org.opencv.core.Mat.eye(Mat.java:492)

                      at test.SimpleJMSRestfulWebService.putMessage(SimpleJMSRestfulWebService.java:57)

                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                      at java.lang.reflect.Method.invoke(Method.java:498)

                      at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)

                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                      at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:509)

                      at org.jboss.as.weld.interceptors.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:90)

                      at org.jboss.as.weld.interceptors.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:101)

                      at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)

                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                      at org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43)

                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                      at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)

                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                      at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45)

                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                      at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:40)

                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                      at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:53)

                      at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:52)

                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                      at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)

                      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)

                      at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:275)

                      ... 86 more

                      • 8. Re: Unsatisfied Link Error -Apache Wildfly 11 -  OpenCV Java 3.3.
                        Richard Cannock Newbie

                        Hi David,

                         

                        Using (GitHub - lucasg/Dependencies: A rewrite of the old legacy software "depends.exe" in C# for Windows devs to troubleshoot …)

                         

                        shows only the following dependencies which all seem to be present and correct in C:\Windows\System32

                         

                        MSVFW32.dll

                        AVIFIL32.dll

                        AVICAP32.dll

                        kernel32.dll

                        user32.dll

                        ole32.dll

                        oleaut32.dll

                         

                        and the GF "domains/domain1/bin" is empty, as i just checked.

                         

                        Cheers

                         

                        Richard