java.lang.UnsatisfiedLinkError

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3289319/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 19:54:51  来源:igfitidea点击:

java.lang.UnsatisfiedLinkError

javajmsibm-mq

提问by hakish

i am trying to access MQ queues using JMS. i am getting the below

我正在尝试使用 JMS 访问 MQ 队列。我得到以下

java.lang.UnsatisfiedLinkError: no mqjbnd05 in java.library.path

i am passing

我路过

-Djava.library.path="C:\Program Files\IBM\WebSphere MQ\java\lib"

as the VM argument while running the program in eclipse. This issue is discussed quite a lot on the net but with out any conclusion. Has anyone resolved this? TIA.

在 eclipse 中运行程序时作为 VM 参数。这个问题在网上讨论了很多,但没有任何结论。有没有人解决这个问题?TIA。

采纳答案by Romain Hippeau

You probably have some older MQ jar files either in your CLASSPATH, in the lib or in the EAR.
Remove them and you should be fine.
You should not put MQ files in your EAR or in the WEB-INF/lib folders. They should be in the classpath of your appserver.

您可能在 CLASSPATH、lib 或 EAR 中有一些较旧的 MQ jar 文件。
删除它们,你应该没事。
您不应将 MQ 文件放在 EAR 或 WEB-INF/lib 文件夹中。它们应该在您的应用程序服务器的类路径中。

回答by Andreas Dolk

Here is an easy recipe: Tell the Java VM to Load the DLL. Is your code similiar, e.g. do you use System.loadLibraryto load mqjbnd05.dll?

这是一个简单的方法:告诉 Java VM 加载 DLL。您的代码是否相似,例如您是否用于System.loadLibrary加载mqjbnd05.dll

If yes - does it work outside eclipse, like starting the application from the command line? If this is the case, you could try starting the whole eclipse IDE with that library path.

如果是 - 它是否在 eclipse 之外工作,比如从命令行启动应用程序?如果是这种情况,您可以尝试使用该库路径启动整个 Eclipse IDE。

And sometimes we have trouble with pathnames that contain spaces. Copy the dll to C:\, put that on the lib path and try again.

有时我们会遇到包含空格的路径名的问题。将 dll 复制到C:\,将其放在 lib 路径上,然后重试。



Ah, that's the problem, the specified dll is missing. This blog has a solution. Good luck!

啊,就是这个问题,指定的dll丢失了。这个博客有一个解决方案。祝你好运!

回答by BalusC

This can happen if you actuallyinstalled MQ Clientinstead of MQ Server.

如果您实际安装的是 MQ Client而不是 MQ Server,就会发生这种情况。

IBM has even written a whole help pageabout it:

IBM 甚至为此编写了一个完整的帮助页面

WebSphere MQ Client installation missing mqjb*.dll files

Problem(Abstract)

You install the WebSphere MQ Client and notice three dll's are missing from the \Program Files\IBM\WebSphere MQ\Java\lib\directory.

Symptom

The following dlls appear in the directory on a server install, but are not part of the Java? client:

  • 03/17/2003 10:59a 19,456 mqjbdf02.dll
  • 03/17/2003 10:59a 57,856 mqjbnd05.dll
  • 03/17/2003 10:59a 36,864 MQXAi02.dll

The subdirectory \jdbc\ appears on the server, but not on the client machine.

  • 03/17/2003 10:59a 61,440 jdbcdb2.dll
  • 03/17/2003 10:59a 61,440 jdbcora.dll

Cause

The files are missing because they are not provided nor needed in a client install.

Resolving the problem

The files are only included in the WebSphere MQ Server product.

WebSphere MQ 客户端安装缺少 mqjb*.dll 文件

问题(摘要)

您安装了 WebSphere MQ 客户端并注意到\Program Files\IBM\WebSphere MQ\Java\lib\目录中缺少三个 dll 。

症状

以下 dll 出现在服务器安装的目录中,但不是 Java? 客户:

  • 03/17/2003 10:59a 19,456 mqjbdf02.dll
  • 03/17/2003 10:59a 57,856 mqjbnd05.dll
  • 03/17/2003 10:59a 36,​​864 MQXAi02.dll

子目录\jdbc\ 出现在服务器上,但不在客户端计算机上。

  • 03/17/2003 10:59a 61,440 jdbcdb2.dll
  • 03/17/2003 10:59a 61,440 jdbcora.dll

原因

这些文件丢失是因为在客户端安装中没有提供也不需要它们。

解决问题

这些文件仅包含在 WebSphere MQ Server 产品中。

回答by Daniel Rothmaler

As I had to deal with this error myself; and it took me a lot of time to find the right answer, I'd like to share it with the next one, who comes along this thread...

因为我必须自己处理这个错误;我花了很多时间才找到正确的答案,我想与下一个分享这个话题的人......

Actually the solution to the problem was very simple (at least in my case). It was not related to any CLASSPATH, java.library.pathor installation issues.

实际上,问题的解决方案非常简单(至少在我的情况下)。它与任何CLASSPATH,java.library.path或安装问题无关。

I simply forgot to switch the MQConnectionFactoryinto the Client mode.

我只是忘了切换MQConnectionFactory到客户端模式。

This has to be done, by simply calling

这必须完成,只需调用

cf.setTransportType(WMQConstants.WMQ_CM_CLIENT);

or

或者

cf.setTransportType(WMQConstants.WMQ_CM_BINDINGS_THEN_CLIENT);

or any other connection type, that fits your needs.
By default, the ConnectionFactory is in "Binding" mode (WMQ_CM_BINDINGS), which is intended for local server installations, as it is is stated in the IBM Documentation:

或任何其他符合您需求的连接类型。
默认情况下,ConnectionFactory 处于“绑定”模式 ( WMQ_CM_BINDINGS),它用于本地服务器安装,正如 IBM 文档中所述:

To connect to a queue manager in bindings mode, a WebSphere MQ classes for JMS application must run on the same systemon which the queue manager is running.

要以绑定方式连接到队列管理器,JMS 应用程序的 WebSphere MQ 类必须在运行队列管理器的同一系统上运行。

This transport type is the same as the XMSC_WMQ_CONNECTION_MODE(WMQConstants.WMQ_CONNECTION_MODE) property, when using JNDI or the JmsFactoryFactory.

这种传输类型是一样的XMSC_WMQ_CONNECTION_MODEWMQConstants.WMQ_CONNECTION_MODE)属性,使用JNDI或时JmsFactoryFactory

The same should apply to the other ConnectionFactory types: MQQueueConnectionFactory, MQTopicConnectionFactory, MQXAConnectionFactory, MQXAQueueConnectionFactoryand MQXATopicConnectionFactory

这同样适用于其他类型的ConnectionFactory: ,MQQueueConnectionFactory,,和MQTopicConnectionFactoryMQXAConnectionFactoryMQXAQueueConnectionFactoryMQXATopicConnectionFactory

Check the IMB Knowledge Center for more information about the different connection/binding options:

查看 IMB 知识中心,了解有关不同连接/绑定选项的更多信息:

https://www.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.dev.doc/q031720_.htmhttps://www.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.dev.doc/q030560_.htm

https://www.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.dev.doc/q031720_.htm https://www.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com .ibm.mq.dev.doc/q030560_.htm

回答by ObviousChild

I came across this while connecting using IBM MQ api. I didn't find this issue to be related to classpath either.

我在使用 IBM MQ api 连接时遇到了这个问题。我也没有发现这个问题与类路径有关。

This happened to me when I instantiated MQQueueManagerbefore setting MQEnvironment's hostnameand channel. Just ensure that your code does not do that and that it instantiates the manager after the environment is set. Something like..

这发生在我身上时,我实例化MQQueueManager设置前MQEnvironmenthostnamechannel。只需确保您的代码不这样做,并在设置环境后实例化管理器。就像是..

MQEnvironment.hostname = "mq hostname";
MQEnvironment.channel = "mq channel";
..more code..
this._queueManager = new MQQueueManager(qManager);

(Observed that it's OK to set MQEnvironment.portafter MQQueueManageris initialized, but one would probably initialize everything related to MQEnvironmenttogether)

(观察到初始化MQEnvironment.port后设置MQQueueManager是可以的,但是可能会把所有相关的都MQEnvironment一起初始化)