activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hmikhail <hmikh...@ksu.edu>
Subject Re: ActiveMq within tomcat 6
Date Wed, 03 Mar 2010 02:19:48 GMT

I did make the same page work before, but my web-app was deployed in jetty.
Here is my page:
<html>
   <head>
	<script type="text/javascript" src="amq/amq.js"></script>
	<script type="text/javascript">amq.uri='amq';</script>
	<script type="text/javascript">

	var myHandler =
	{ rcvMessage: function(message){
                    changeText(message.nodeValue);
                      alert(message.nodeValue);}
	};


       function changeText(val){
         var txtArea = document.getElementById('imgdesc');
         txtArea.value = val;
         }

	function show_prompt() {

        changeText("");
	var number = prompt("Please enter a number between 1 and 1000",null);
	if (number < 2 || number > 999 || isNaN(number) || number == null)
  	{
  	alert("Invalid input...try again");
  	}
	else{ 		
	    }
}

</script>

	<title> Client </title>
	</head>
	<body>
           <script type="text/javascript">
             alert('Listener added');
             amq.sendMessage("channel://TEST.FOO",'8');
             amq.addListener('1', "channel://RESP.FOO",
myHandler.rcvMessage);
             alert('Listener added');
           </script>

		
	   <h1> Click the button below to enter the number of words</h1>
		<input id="but" type="button"  onclick="show_prompt()" value="Start!"  />
                <textarea id="imgdesc"  rows="20" cols="80" readonly="yes"
</textarea>
       </body>
</html>



 



Dejan Bosanac wrote:
> 
> Hi,
> 
> your server config looks ok, seems like the problem could be on your web
> page.
> 
> Do you have something like this configured in it
> 
> <script type="text/javascript" src="amq/amq.js"></script>
> <script type="text/javascript">amq.uri='amq';</script>
> 
> You can also take a look at webapps/demo/chat.html (and chat.js) for some
> examples on how to do it.
> 
> If it doesn't work, send your page that doesn't work.
> 
> Cheers
> --
> Dejan Bosanac - http://twitter.com/dejanb
> 
> Open Source Integration - http://fusesource.com/
> ActiveMQ in Action - http://www.manning.com/snyder/
> Blog - http://www.nighttale.net
> 
> 
> On Tue, Mar 2, 2010 at 5:06 AM, hmikhail <hmikhail@ksu.edu> wrote:
> 
>>
>> Hello All,
>> I am trying to use activemq within tomcat6 and interact from javascript
>> using ajax, I am having lots of problems.
>> When I deploy Tomcat I see in the log "Connector vm://localhost Started ,
>> so
>> I am guessing that the configuration is correct, but when I try to send
>> messages from my javascript I get an error message from the Error console
>> of
>> forefox saying "amq is not defined".
>> In CATALINA_HOME/CONF/context.xml I put
>>   <Resource name="jms/ConnectionFactory" auth="Container"
>> type="org.apache.activemq.ActiveMQConnectionFactory" description="JMS
>> Connection Factory"
>>   factory="org.apache.activemq.jndi.JNDIReferenceFactory"
>> brokerURL="vm://localhost" brokerName="LocalActiveMQBroker"/>
>>
>> I also added the following jar files to CATALINA_HOME/lib:
>> geronimo-j2ee-management_1.0_spec-1.0.jar
>> geronimo-jta_1.0.1B_spec-1.0.1.jar
>> geronimo-jms_1.1_spec-1.1.1.jar
>> activemq-web-5.3.0.jar
>> activemq-core-5.3.0.jar
>> activemq-all-5.3.0.jar
>>
>> In the web.xml file of my web-app I put:
>>    <context-param>
>>        <param-name>org.apache.activemq.brokerURL</param-name>
>>        <param-value>vm://localhost</param-value>
>>        <description>The URL of the Message Broker to connect
>> to</description>
>>    </context-param>
>>
>>    <context-param>
>>        <param-name>org.apache.activemq.embeddedBroker</param-name>
>>        <param-value>true</param-value>
>>        <description>Whether we should
>>  an embedded broker or not</description>
>>
>>  <servlet>
>>    <servlet-name>AjaxServlet</servlet-name>
>>    <servlet-class>org.apache.activemq.web.AjaxServlet</servlet-class>
>>    <load-on-startup>1</load-on-startup>
>>  </servlet>
>>
>>  <servlet-mapping>
>>    <servlet-name>AjaxServlet</servlet-name>
>>    <url-pattern>/amq/*</url-pattern>
>>  </servlet-mapping>
>>
>> I really don't know how to make this work...would appreciate your help.
>>
>> Thanks,
>> Henry
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/ActiveMq-within-tomcat-6-tp27752022p27752022.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -----
> Dejan Bosanac
> 
> Open Source Integration - http://fusesource.com/
> ActiveMQ in Action - http://www.manning.com/snyder/
> Blog - http://www.nighttale.net
> 

-- 
View this message in context: http://old.nabble.com/ActiveMq-within-tomcat-6-tp27752022p27763712.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message