zmq 在使用 Maven 在 Intellij IDEA 中运行单元测试时失败



当我在Intellij IDEA(Ultimate)11.1中使用maven运行单元测试时。我得到了以下异常。

-------------------------------------------------------------------------------
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)

从互联网搜索后,似乎zmq缺少java.library.path - usr/local/lib。所以我尝试将"-Djava.library.path=/usr/local/lib"添加到 maven 的 vm 选项中,但仍然不好。

注意:

  1. 我可以通过 bash 中的"mvn 测试"进行测试。(我在~/.profile中添加了"export LD_LIBRARY_PATH=/usr/local/lib")

  2. 我在pom而不是jzmq中配置了它,因为我需要在项目中使用storm并且storm引用jzmq。

<dependency>
    <groupId>storm</groupId>
    <artifactId>storm</artifactId>
    <version>0.7.4</version>
</dependency>

我尝试从终端启动 Intellij,它工作正常。当我从 Ubuntu 的启动面板启动它时,它不是从我的任何登录环境变量开始的。检查 http://blog.bluecalyx.org/2009/07/02/missing-environment-variables-in-intellij/后,我用bash更新了Intellij桌面文件中的exec--login IDEAPATH/bin/idea.sh,然后世界变得和平。

我仍然感到困惑的一件事是,即使我在 Intellij maven runner 设置中添加了 -Djava.library.path=/usr/local/lib,它也无法正常工作。

最后,提醒一下,在开始使用ZMQ和jzmq之前,有必要安装它。请参阅 www.zeromq.org/intro:get-the-software 和 www.zeromq.org/bindings:java

相关内容

  • 没有找到相关文章

最新更新