0
votes

When I run unit test with maven in Intellij IDEA (Ultimate) 11.1. I got following exception.

-------------------------------------------------------------------------------
Test set: myapp.messaging.MQServiceTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.026 sec <<< FAILURE!
testEnqueueAndDequeue(myapp.messaging.MQServiceTest)  Time elapsed: 0.024 sec  <<< ERROR!
java.lang.UnsatisfiedLinkError: no jzmq in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1856)
    at java.lang.Runtime.loadLibrary0(Runtime.java:845)
    at java.lang.System.loadLibrary(System.java:1084)
    at org.zeromq.ZMQ.<clinit>(ZMQ.java:34)
    at myapp.messaging.MQClient.<init>(MQClient.java:34)
    at myapp.messaging.MQServiceTest.testEnqueueAndDequeue(MQServiceTest.java:34)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
    at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
    at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)

After search from internet, it seems zmq missing java.library.path - usr/local/lib. So I tried add "-Djava.library.path=/usr/local/lib" to vm option of maven, but still no good.

Note:

  1. I can pass the test with "mvn test" in bash. (I added "export LD_LIBRARY_PATH=/usr/local/lib" into ~/.profile)

  2. I configured this in pom instead of jzmq, as I need to use storm in my project and storm referenced jzmq.

<dependency>
    <groupId>storm</groupId>
    <artifactId>storm</artifactId>
    <version>0.7.4</version>
</dependency>
1
Try to echo the environment from the Maven test to compare it with your terminal environment.CrazyCoder
Thanks CrazyCoder for reply. Following are the maven test environment.Terry Yip
/usr/lib/jvm/java-7-openjdk-i386/bin/java -Djava.library.path=/usr/local/lib -Dclassworlds.conf=/home/terrill/apache-maven-3.0.4/bin/m2.conf -Dmaven.home=/home/terrill/apache-maven-3.0.4 -Didea.launcher.port=7532 -Didea.launcher.bin.path=/home/terrill/idea-IU-117.798/bin -Dfile.encoding=UTF-8 -classpath /home/terrill/apache-maven-3.0.4/boot/plexus-classworlds-2.4.jar:/home/terrill/idea-IU-117.798/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain org.codehaus.classworlds.Launcher --no-plugin-registry --fail-fast --strict-checksums --update-snapshots -fTerry Yip
/home/terrill/workspace/etown-community-framework/messaging/pom.xml test But how can I echo all the terminal environment?Terry Yip

1 Answers

0
votes

I try starting Intellij from terminal, it just works fine. When I start it from launch panel of Ubuntu, it isn’t starting with any of my login environment variables. After checked http://blog.bluecalyx.org/2009/07/02/missing-environment-variables-in-intellij/ , I updated exec in the Intellij desktop file with bash --login IDEAPATH/bin/idea.sh, then the world become peaceful.

One thing I'm still confused on is, before even if I added -Djava.library.path=/usr/local/lib in Intellij maven runner setting, it doesn't work.

Last, just a reminder, before start using ZMQ and jzmq, it is necessary to install it. Refer to www.zeromq.org/intro:get-the-software and www.zeromq.org/bindings:java