Expand my Community achievements bar.

JMS with flex

Avatar

Level 1
I have a problem with connection to open jms. I get an error
: "cannot instantiate class :
org.exolab.jms.jndi.InitialContextFactory"

This is my flex code :



<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="createChat()">



<!-- UI Declarations -->



<mx:Panel title="Simple Flex Chat">

<mx:TextArea id="output" width="385" height="220" />

<mx:TextInput id="input" width="385"
enter="sendChatMessage()" />

<mx:ControlBar horizontalAlign="center" width="385">

<mx:Button id="clearBtn" label="Clear" click="output.text
=''" />

</mx:ControlBar>

</mx:Panel>



<mx:Script>

<![CDATA[



import mx.messaging.Consumer;

import mx.messaging.Producer;

import mx.messaging.events.MessageAckEvent;

import mx.messaging.events.MessageFaultEvent;

import mx.messaging.events.MessageEvent;

import mx.messaging.messages.AcknowledgeMessage;

import mx.messaging.messages.AsyncMessage;

import mx.utils.ObjectUtil;



private var chatPublisher:Producer;

private var chatSubscriber:Consumer;



private function createChat():void

{

chatPublisher = new Producer();

chatPublisher.addEventListener(MessageFaultEvent.FAULT,
onProducerFault);

chatPublisher.destination = "topic1";



chatSubscriber = new Consumer();

chatSubscriber.addEventListener(MessageAckEvent.ACKNOWLEDGE,
onConsumerAck);

chatSubscriber.addEventListener(MessageEvent.MESSAGE,
receiveChatMessage);

chatSubscriber.destination = "topic1";

chatSubscriber.subscribe();

}



private function
onProducerFault(faultEvent:MessageFaultEvent):void

{

output.text += "[Error: " + faultEvent.message.toString() +
"]\n";

}



private function
onConsumerAck(ackEvent:MessageAckEvent):void

{

output.text += "[Got ack for subscribe or unsubscribe
operation]\n";

}



// Note: these are the event-handling methods from above,
now moved into the separate source file:



private function sendChatMessage():void

{

var msg:AsyncMessage = new AsyncMessage();

msg.body = input.text;

chatPublisher.send(msg);

input.text = "";

}



private function
receiveChatMessage(msgEvent:MessageEvent):void

{

var msg:AsyncMessage = AsyncMessage(msgEvent.message);

output.text += msg.body + "\n";

}



]]>



</mx:Script>

</mx:Application>





and then the configuration in the blazeds :



<adapters>

<adapter-definition id="actionscript"
class="flex.messaging.services.messaging.adapters.ActionScriptAdapter"
default="true" />

<adapter-definition id="jms"
class="flex.messaging.services.messaging.adapters.JMSAdapter"/>

</adapters>



<default-channels>

<channel ref="my-polling-amf"/>

</default-channels>



<!--configurazione JMS Queue-->

<destination id="topic1">

<properties>



<jms>

<destination-type>Topic</destination-type>


<message-type>javax.jms.ObjectMessage</message-type>

<!--connection-factory>jms/flex/TopicConnectionFactory

</connection-factory-->

<connection-factory>JmsTopicConnectionFactory

</connection-factory>

<destination-jndi-name>topic1

</destination-jndi-name>

<destination-name>topic1

</destination-name>

<delivery-mode>NON_PERSISTENT</delivery-mode>


<message-priority>DEFAULT_PRIORITY</message-priority>


<acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>

<transacted-sessions>false</transacted-sessions>

<!-- (Optional) JNDI environment. Use when using JMS on a
remote JNDI server. Used to specify the JNDI environment to access
an external JMS provider. -->

<initial-context-environment>

<property>

<name>Context.SECURITY_PRINCIPAL</name>

<value>anonymous</value>

</property>

<property>

<name>Context.SECURITY_CREDENTIALS</name>

<value>anonymous</value>

</property>

<property>

<name>Context.PROVIDER_URL</name>

<value>rmi://localhost:1099/</value>

</property>

<property>

<name>Context.INITIAL_CONTEXT_FACTORY</name>

<value>org.exolab.jms.jndi.InitialContextFactory

</value>

</property>

</initial-context-environment>



</jms>

</properties>



<adapter ref="jms"/>

</destination>



Please help me to fix this problem



Thanx
2 Replies

Avatar

Level 1
I found the
http://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/lcds/wwhelp/wwhimpl/common/html/wwhelp.htm...
useful. If you look in the small print on the bottom of the page
then you might find useful infos.

Avatar

Level 2
You might want to change the URL



from

rmi://localhost:1099/



to

jnp://localhost:1099/



Flex Messaging was not working for us until we changed the
protocol to jnp://