Search code examples
ibm-mobilefirstworklight-adapters

Worklight JMS Adapter Issue


I'm trying to use worklight jms adpater with Websphere MQ Provider. Steps Followed: In WMQ V7.0 Explorer, Right click on JMS Administered Objects -> Add Inital Context -> select File System -> Gave name in Bindings directory (C:/JNDI_Directory) -> Gave Context nickname(file:/C:/JNDI_Directory/) and click finish.

In connectionFactory, the context nickname will be set as file:/C:/JNDI_Directory/ -> then click on New -> Gave connection factory name (JMSConnectionFactory)
and select messaging provider as, Websphere MQ -> select the connection factory -> select transport as MQ Client -> 
Select base queue manager(JMS_QMGR) and connection list(localhost(2525)) in the connection tab.

In Destination -> new -> Destination -> enter the name of destination(JMSDestination) and type of queue -> select Queue Manager and queue in general tab

In Worklight creating worklight project name as TestJMSAdapter and created a jms adapter(JMSAdapter), configured the following in JMSAdapter.xml file.


<namingConnection url="file:/C:/JNDI_Directory/"  initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory"/>

<jmsConnection connectionFactory="JMSConnectionFactory" />

In JMSAdapter-impl.js, configure the destination as follows,
readMessage(){
           return WL.Server.readSingleJMSMessage({
                                        destination: "JMSDestination",
                                        timeout: 60
                                        });
                     }

and took all jars from /WebSphere MQ/java/lib, added the following jars in lib folder:

/TestJMSAdapter/server/lib/com.ibm.mq.commonservices.jar
/TestJMSAdapter/server/lib/com.ibm.mq.headers.jar
/TestJMSAdapter/server/lib/com.ibm.mq.jar
/TestJMSAdapter/server/lib/com.ibm.mq.jmqi.jar
/TestJMSAdapter/server/lib/com.ibm.mq.jms.Nojndi.jar
/TestJMSAdapter/server/lib/com.ibm.mqjms.jar
/TestJMSAdapter/server/lib/dhbcore.jar
/TestJMSAdapter/server/lib/fscontext.jar
/TestJMSAdapter/server/lib/jms.jar
/TestJMSAdapter/server/lib/jndi.jar
/TestJMSAdapter/server/lib/providerutil.jar

I'm using worklight v6 and deployed in (WebSphere Application Server V8.5 Liberty)Worklight Development Server.

while invoking the procedure it shows the following error:

Error in Worklight Development Server console is,

[ERROR ] FWLSE0005W: JMS connection exception received: com.ibm.mq.jms.MQConnectionFactory cannot be cast to javax.jms.ConnectionFactory. Closing the connection. [project TestJMSAdapter]

Please help me out.


Solution

  • The error you are seeing is usually caused by the incorrect jars being added to your project.

    You have two options:

    • Find out which jars need to be removed.

    I believe the jar that is causing your problem is the "jms.jar" file. Remove that file and try again.

    • Upgrade to the latest version of Worklight.

    All classloading issues have been fixed in the latest version of worklight, so regardless of the jars that are included it should still work.