Archive for February 2009


Getting started with Comet

February 23rd, 2009 — 4:58pm

Getting started trying to run a comet service

Download Maven from http://maven.apache.org/

Install Maven using http://maven.apache.org/download.html#Installation
I did the following commands
Extracted to /home/sdwyer/apache-maven-2.0.9

> sdwyer@pluto:~/apache-maven-2.0.9$ export M2_HOME=/home/sdwyer/apache-maven-2.0.9
> sdwyer@pluto:~/apache-maven-2.0.9$ export M2=$M2_HOME/bin
> sdwyer@pluto:~/apache-maven-2.0.9$ export PATH=$M2:$PATH.
> sdwyer@pluto:~/apache-maven-2.0.9$ mvn --version
-bash: /home/sdwyer/apache-maven-2.0.9/bin/mvn: Permission denied

> sdwyer@pluto:~/apache-maven-2.0.9$ cd bin
> sdwyer@pluto:~/apache-maven-2.0.9/bin$ ls
m2 m2.bat m2.conf mvn mvn.bat mvnDebug mvnDebug.bat

> sdwyer@pluto:~/apache-maven-2.0.9/bin$ chmod +x mvn

> sdwyer@pluto:~/apache-maven-2.0.9/bin$ mvn –version
Maven version: 2.0.9
Java version: 1.5.0_08
OS name: “linux” version: “2.6.18-4-686″ arch: “i386″ Family: “unix”
sdwyer@pluto:~/apache-maven-2.0.9/bin$

Download the jetty server from http://www.mortbay.org/jetty/
Extract to /home/sdwyer/jetty-6.1.3
> sdwyer@pluto:~$ cd jetty-6.1.3//examples/cometd-demo

> mvn jetty:run

A whole stack of downloads run

Once it’s completed open a browser and point it to:
http://[server]:8080 and test the demos

Take a look around the code of the demos, specifically look for
<script type="text/javascript">
cometd.init({}, new String(document.location).replace(/http:\/\/[^\/]*/,'').replace(/\/examples\/.*$/,'')+"/cometd");
</script>

The new String() variable ends up being /cometd in a location like – http://pluto:8080/examples/exploration/

Comment » | Web Development

Back to top