java.lang.UnsatisfiedLinkError

吃可爱长大的小学妹 提交于 2020-01-20 07:53:26

问题


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

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.


回答1:


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.




回答2:


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.path or installation issues.

I simply forgot to switch the MQConnectionFactory into the Client mode.

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:

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

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

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

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

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




回答3:


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

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

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

(Observed that it's OK to set MQEnvironment.port after MQQueueManager is initialized, but one would probably initialize everything related to MQEnvironment together)




回答4:


Here is an easy recipe: Tell the Java VM to Load the DLL. Is your code similiar, e.g. do you use System.loadLibrary to load 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.

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


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




回答5:


This can happen if you actually installed MQ Client instead of MQ Server.

IBM has even written a whole help page about it:

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.



来源:https://stackoverflow.com/questions/3289319/java-lang-unsatisfiedlinkerror

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!