Topic
  • 17 replies
  • Latest Post - ‏2013-01-29T05:42:05Z by SystemAdmin
SystemAdmin
SystemAdmin
2327 Posts

Pinned topic Errors in the JMS Adapter

‏2013-01-22T16:37:30Z |
I want to develop a JMS Adapter via Worklight Studio in my PC.

I installed a MQ Server in the same PC. Then I created a local queue and related JMS Object. The following is the code in adapter xml:

<connectivity>
<connectionPolicy xsi:type="jms:JMSConnectionPolicyType">
<!-- uncomment this if you want to use an external JNDI repository -->
<namingConnection url="file:/D:/MQ_JNDI/"
initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory"/>
<jmsConnection
connectionFactory="java:comp/env/jms/MyJMSConnectFactory"
/>
</connectionPolicy>
<loadConstraints maxConcurrentConnectionsPerNode="10"/>
</connectivity>

When I tested the JMS Adapter, I got the following error msg:

JMS connection exception received: Cannot instantiate class: com.sun.jndi.fscontext.RefFSContextFactory. Closing the connection.

I added the fscontext.jar into the server/lib folder and rebuild the project. The above error was gone. But I got a new error.

com.worklight.integration.services.impl.DataAccessServiceImpl invokeProcedureInternal
Invocation of procedure 'writeMessage' caused java.lang.NoClassDefFoundError: com/sun/jndi/toolkit/chars/CharacterDecoder

Do I miss anything or set up the JNDI wrongly?

Thanks!
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: Errors in the JMS Adapter

    ‏2013-01-22T19:01:33Z  
    Can you post a list of the jars you have included in your server/lib folder? Sometimes there are conflicts that cause errors if the wrong jars are added.
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: Errors in the JMS Adapter

    ‏2013-01-23T01:04:19Z  
    Can you post a list of the jars you have included in your server/lib folder? Sometimes there are conflicts that cause errors if the wrong jars are added.
    Only the fscontext.jar was added into the server/lib folder.

    BTW, can we set up the JNDI in the Worklight Studio Server?
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: Errors in the JMS Adapter

    ‏2013-01-23T15:45:07Z  
    Only the fscontext.jar was added into the server/lib folder.

    BTW, can we set up the JNDI in the Worklight Studio Server?
    At the very minimum you'll also need the providerutil.jar file. I've included an image of all of the jars included in my Worklight server/lib folder (though some may be unnecessary for your particular setup). You should be able to get all of the necessary jars from your MQ environment.

    You can define the jndi names in your server/conf/worklight.properties file and then access them in your adapter file. The worklight.properties file will live on the server. Does that answer your second question?
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: Errors in the JMS Adapter

    ‏2013-01-24T16:03:30Z  
    At the very minimum you'll also need the providerutil.jar file. I've included an image of all of the jars included in my Worklight server/lib folder (though some may be unnecessary for your particular setup). You should be able to get all of the necessary jars from your MQ environment.

    You can define the jndi names in your server/conf/worklight.properties file and then access them in your adapter file. The worklight.properties file will live on the server. Does that answer your second question?
    Jeremy, thanks for your reply.

    The above error was solved by adding the jars into the server/lib folder. But it was still failed to connect to MQ server.

    I got the following error:

    "errors": [
    "Runtime: Failed to create connection from factory: java:\/comp\/env\/MyJMSConnectFactory"
    ],
    "info": [
    ],
    "isSuccessful": false,
    "warnings": [
    ]
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: Errors in the JMS Adapter

    ‏2013-01-24T16:30:50Z  
    Jeremy, thanks for your reply.

    The above error was solved by adding the jars into the server/lib folder. But it was still failed to connect to MQ server.

    I got the following error:

    "errors": [
    "Runtime: Failed to create connection from factory: java:\/comp\/env\/MyJMSConnectFactory"
    ],
    "info": [
    ],
    "isSuccessful": false,
    "warnings": [
    ]
    The following my current MQ conf and JNDI setting

    1. The MQ server was installed in the same PC with Worklight Studio
    2. Create a JMS initial context using the file system: D:\JMS_JNDI
    3. Create a JMS Connect Factory MyJMSConnectFactory
    3. Create a JMS Destination MyLocalQueue
    4. Create a queue manager MyQueueManager
    5. Create a local queue MyLocalQueue mapped to JMS

    Attach is the binding file under D:\JMS_JNDI

    Attachments

  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: Errors in the JMS Adapter

    ‏2013-01-24T16:36:22Z  
    The following my current MQ conf and JNDI setting

    1. The MQ server was installed in the same PC with Worklight Studio
    2. Create a JMS initial context using the file system: D:\JMS_JNDI
    3. Create a JMS Connect Factory MyJMSConnectFactory
    3. Create a JMS Destination MyLocalQueue
    4. Create a queue manager MyQueueManager
    5. Create a local queue MyLocalQueue mapped to JMS

    Attach is the binding file under D:\JMS_JNDI
    My setting in Adapter XML file:

    <connectivity>
    <connectionPolicy xsi:type="jms:JMSConnectionPolicyType">
    <!-- uncomment this if you want to use an external JNDI repository -->
    <namingConnection url="file:/D:/JMS_JNDI/"
    initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory"/>
    <jmsConnection
    connectionFactory="java:comp/env/jms/MyJMSConnectFactory"
    />
    </connectionPolicy>
    <loadConstraints maxConcurrentConnectionsPerNode="10"/>
    </connectivity>

    For connectionFactory, I tried the following values:

    1) java:comp/env/jms/MyJMSConnectFactory
    2) jms/MyJMSConnectFactory
    3) MyJMSConnectFactory

    neither of them can work.
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: Errors in the JMS Adapter

    ‏2013-01-24T16:37:17Z  
    My setting in Adapter XML file:

    <connectivity>
    <connectionPolicy xsi:type="jms:JMSConnectionPolicyType">
    <!-- uncomment this if you want to use an external JNDI repository -->
    <namingConnection url="file:/D:/JMS_JNDI/"
    initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory"/>
    <jmsConnection
    connectionFactory="java:comp/env/jms/MyJMSConnectFactory"
    />
    </connectionPolicy>
    <loadConstraints maxConcurrentConnectionsPerNode="10"/>
    </connectivity>

    For connectionFactory, I tried the following values:

    1) java:comp/env/jms/MyJMSConnectFactory
    2) jms/MyJMSConnectFactory
    3) MyJMSConnectFactory

    neither of them can work.
    Jeremy,

    Do you think what's wrong for my above setting?

    Thanks!
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: Errors in the JMS Adapter

    ‏2013-01-24T16:43:11Z  
    The following my current MQ conf and JNDI setting

    1. The MQ server was installed in the same PC with Worklight Studio
    2. Create a JMS initial context using the file system: D:\JMS_JNDI
    3. Create a JMS Connect Factory MyJMSConnectFactory
    3. Create a JMS Destination MyLocalQueue
    4. Create a queue manager MyQueueManager
    5. Create a local queue MyLocalQueue mapped to JMS

    Attach is the binding file under D:\JMS_JNDI
    Instead of

    
    connectionFactory=
    "java:comp/env/jms/MyJMSConnectFactory"
    


    can you try just using

    
    connectionFactory=
    "MyJMSConnectFactory"
    
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: Errors in the JMS Adapter

    ‏2013-01-24T16:44:53Z  
    Jeremy,

    Do you think what's wrong for my above setting?

    Thanks!
    Your settings all look correct, I've compared them to mine and the only difference I see is the way you are naming your connection factory. I was able to reproduce your error when I named my connection factory similar to the way you did. Hopefully your error is simply the naming issue.
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: Errors in the JMS Adapter

    ‏2013-01-24T16:46:03Z  
    Instead of

    <pre class="jive-pre"> connectionFactory= "java:comp/env/jms/MyJMSConnectFactory" </pre>

    can you try just using

    <pre class="jive-pre"> connectionFactory= "MyJMSConnectFactory" </pre>
    Nevermind, I just saw your post about already trying with different names. Going to take a look at the rest of your configuration to see what else could be wrong.
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: Errors in the JMS Adapter

    ‏2013-01-24T16:58:12Z  
    Nevermind, I just saw your post about already trying with different names. Going to take a look at the rest of your configuration to see what else could be wrong.
    This is what my configuration looks like (very similar to yours):

    
    <displayName>JMS_Adapter</displayName> <description>JMS_Adapter</description> <connectivity> <connectionPolicy xsi:type=
    "jms:JMSConnectionPolicyType"> <!-- uncomment 
    
    this 
    
    if you want to use an external JNDI  repository --> <namingConnection initialContextFactory=
    "com.sun.jndi.fscontext.RefFSContextFactory" url=
    "file:/C:/JNDI-Directory"/> <jmsConnection connectionFactory=
    "MQCONN" password=
    "xxxxx" user=
    "xxxxx"/> </connectionPolicy> <loadConstraints maxConcurrentConnectionsPerNode=
    "10"/> </connectivity>
    


    1. Can you attach an image of the jars that you have added to your project similar to the way I did before?
    2. Do you think that there might be any security settings that would be causing any of this?
    3. Can you check the log file (WORKSPACE_HOME/WORKLIGHT_PROJECT/WorklightServerHome/APPLICATION_NAME/logs/server.log) for any other exceptions that may be happening and post them here?
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: Errors in the JMS Adapter

    ‏2013-01-25T06:57:50Z  
    This is what my configuration looks like (very similar to yours):

    <pre class="jive-pre"> <displayName>JMS_Adapter</displayName> <description>JMS_Adapter</description> <connectivity> <connectionPolicy xsi:type= "jms:JMSConnectionPolicyType"> <!-- uncomment this if you want to use an external JNDI repository --> <namingConnection initialContextFactory= "com.sun.jndi.fscontext.RefFSContextFactory" url= "file:/C:/JNDI-Directory"/> <jmsConnection connectionFactory= "MQCONN" password= "xxxxx" user= "xxxxx"/> </connectionPolicy> <loadConstraints maxConcurrentConnectionsPerNode= "10"/> </connectivity> </pre>

    1. Can you attach an image of the jars that you have added to your project similar to the way I did before?
    2. Do you think that there might be any security settings that would be causing any of this?
    3. Can you check the log file (WORKSPACE_HOME/WORKLIGHT_PROJECT/WorklightServerHome/APPLICATION_NAME/logs/server.log) for any other exceptions that may be happening and post them here?
    1. Please see the attached file for the lib.

    2. I used the bind mode to connect MQ. I created a Java stand alone application that can connect to MQ and put a message successfully.
    3.
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: Errors in the JMS Adapter

    ‏2013-01-25T06:59:14Z  
    1. Please see the attached file for the lib.

    2. I used the bind mode to connect MQ. I created a Java stand alone application that can connect to MQ and put a message successfully.
    3.
    3. Please see the server.log

    Attachments

  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: Errors in the JMS Adapter

    ‏2013-01-25T07:01:20Z  
    3. Please see the server.log
    Jeremy,

    Does Worklight support Bind Mode to connect MQ? Or only support the Client Mode?

    Thanks!
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: Errors in the JMS Adapter

    ‏2013-01-25T15:31:56Z  
    Jeremy,

    Does Worklight support Bind Mode to connect MQ? Or only support the Client Mode?

    Thanks!
    Either your log file was cleared or you may have gotten the wrong log file. Either way I was able to see your problem in your list of jars. You are including the "jms.jar" file in your list of jars. If we were to look at the correct log file, we would see an error saying something along the lines of "MQConnectionFactory cannot be cast to javax.jms.ConnectionFactory". Including the jms.jar file in your server/lib folder is causing a java class loading conflict. Your problem should go away once you remove this one jar (see my original jar image to compare).

    Does Worklight support Bind Mode to connect MQ? Or only support the Client Mode?
    I believe we support both but let me get back to you on this one.
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: Errors in the JMS Adapter

    ‏2013-01-28T15:50:21Z  
    Either your log file was cleared or you may have gotten the wrong log file. Either way I was able to see your problem in your list of jars. You are including the "jms.jar" file in your list of jars. If we were to look at the correct log file, we would see an error saying something along the lines of "MQConnectionFactory cannot be cast to javax.jms.ConnectionFactory". Including the jms.jar file in your server/lib folder is causing a java class loading conflict. Your problem should go away once you remove this one jar (see my original jar image to compare).

    Does Worklight support Bind Mode to connect MQ? Or only support the Client Mode?
    I believe we support both but let me get back to you on this one.
    To answer your last question, Worklight only supports client mode.
  • SystemAdmin
    SystemAdmin
    2327 Posts

    Re: Errors in the JMS Adapter

    ‏2013-01-29T05:42:05Z  
    To answer your last question, Worklight only supports client mode.
    Thanks, Jeremy! I will try to use Client Mode to connect to MQ.