Comet-Jetty(3)Update the Sample
Comet-Jetty(3)UpdatetheSample
Trythesampleprojectcometd-demo
errormessagewhenimportthistoeclipse:
Pluginexecutionnotcoveredbylifecycleconfiguration:org.apache.felix:maven-buildle-plugin:2.3.5:manifest(execution:osgi,phase:process-classes)
Solution:
temporarilycommentsthefelixplugininparentpom.xml
Runthisprojectwithcommand
>mvnjetty:run
Importthisprojecttoeclipse
>mvneclipse:eclipse-Dwtpversion=1.5
Runthisprojectoneclipse
Firstofall,installhttp://download.eclipse.org/jetty/updates/jetty-wtppluginoneclipse:
Downloadthedistributedversionofjetty.
http://download.eclipse.org/jetty/
Findmysampleprojecteasycometd,startfromhere.
addthistomypom.xml
org.eclipse.jetty
jetty-server
7.6.4.v20120524
commentthewebsockettransport
errormessage:
java.lang.IllegalStateException:Notsupported.
atorg.apache.catalina.connector.Request.startAsync(Request.java:1664)
atorg.apache.catalina.connector.Request.startAsync(Request.java:1657)
solution:
<filter>
<filter-name>continuation</filter-name>
<filter-class>org.eclipse.jetty.continuation.ContinuationFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>continuation</filter-name>
<url-pattern>/cometd/*</url-pattern>
</filter-mapping>
errormessagewhenrunningmvntomcat:run
java.lang.ClassCastException:org.eclipse.jetty.continuation.ContinuationFiltercannotbecasttoja
vax.servlet.Filter
solution:
removethejarinpom.xml
org.eclipse.jetty
jetty-server
7.6.4.v20120524
Atthefinaltesting,itisworking.Mysamplepom.xmlwillbeasfollow:
<?xmlversion="1.0"encoding="UTF-8"?>
<projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sillycat</groupId>
<artifactId>easycometd</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<properties>
<spring.version>3.1.1.RELEASE</spring.version>
<cometd.version>2.5.0-SNAPSHOT</cometd.version>
</properties>
<build>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>7.6.4.v20120524</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webAppConfig>
<contextPath>/easycometd</contextPath>
</webAppConfig>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.cometd.java</groupId>
<artifactId>bayeux-api</artifactId>
<version>${cometd.version}</version>
</dependency>
<dependency>
<groupId>org.cometd.javascript</groupId>
<artifactId>cometd-javascript-jquery</artifactId>
<version>${cometd.version}</version>
<type>war</type>
</dependency>
<dependency>
<groupId>org.cometd.java</groupId>
<artifactId>cometd-java-server</artifactId>
<version>${cometd.version}</version>
</dependency>
<dependency>
<groupId>org.cometd.java</groupId>
<artifactId>cometd-websocket-jetty</artifactId>
<version>${cometd.version}</version>
<exclusions>
<exclusion>
<groupId>org.cometd.java</groupId>
<artifactId>cometd-java-client</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.cometd.java</groupId>
<artifactId>cometd-java-annotations</artifactId>
<version>${cometd.version}</version>
</dependency>
<dependency>
<groupId>org.cometd.java</groupId>
<artifactId>cometd-java-client</artifactId>
<version>${cometd.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlets</artifactId>
<version>7.6.4.v20120524</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-client</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.4</version>
</dependency>
</dependencies>
</project>
Andhereisthecometd-context.xml:
<?xmlversion="1.0"encoding="UTF-8"?>
<beansxmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:groovy="http://www.sillycat.com/schema/groovy"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/lang
http://www.springframework.org/schema/lang/spring-lang-3.0.xsd
http://www.sillycat.com/schema/groovy
http://www.sillycat.com/schema/groovy/groovy.xsd
">
<beanid="bayeux"class="org.cometd.server.BayeuxServerImpl"init-method="start"destroy-method="stop">
<propertyname="options">
<map>
<entrykey="logLevel"value="3"/>
<entrykey="timeout"value="15000"/>
</map>
</property>
<propertyname="transports">
<list>
<beanid="jsonTransport"class="org.cometd.server.transport.JSONTransport">
<constructor-argref="bayeux"/>
</bean>
<beanid="jsonpTransport"class="org.cometd.server.transport.JSONPTransport">
<constructor-argref="bayeux"/>
</bean>
</list>
</property>
</bean>
<beanclass="org.springframework.web.context.support.ServletContextAttributeExporter">
<propertyname="attributes">
<map>
<entrykey="org.cometd.bayeux">
<reflocal="bayeux"/>
</entry>
</map>
</property>
</bean>
</beans>
Andsomelittlechangesinweb.xmltousethespringlikemypreviousproject:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:main-context.xml</param-value>
</context-param>
<servlet>
<servlet-name>cometd</servlet-name>
<servlet-class>org.cometd.annotation.AnnotationCometdServlet</servlet-class>
<init-param>
<param-name>timeout</param-name>
<param-value>30000</param-value>
</init-param>
<init-param>
<param-name>interval</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>maxInterval</param-name>
<param-value>10000</param-value>
</init-param>
<init-param>
<param-name>maxLazyTimeout</param-name>
<param-value>5000</param-value>
</init-param>
<init-param>
<param-name>long-polling.multiSessionInterval</param-name>
<param-value>2000</param-value>
</init-param>
<init-param>
<param-name>logLevel</param-name>
<param-value>1</param-value>
</init-param>
<init-param>
<param-name>services</param-name>
<param-value>com.sillycat.easycometd.comed.chat.service.ChatService</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cometd</servlet-name>
<url-pattern>/cometd/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>continuation</filter-name>
<filter-class>org.eclipse.jetty.continuation.ContinuationFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>continuation</filter-name>
<url-pattern>/cometd/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>cross-origin</filter-name>
<filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>cross-origin</filter-name>
<url-pattern>/cometd/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
Itisworkingnow.AndIwilltrytorefactorthisproject.
references:
http://dev.eclipse.org/mhonarc/lists/m2e-users/msg01113.html
http://download.eclipse.org/jetty/
https://github.com/flowersinthesand/jquery-socket.git
http://code.google.com/p/jquery-stream/source/checkout
http://code.google.com/p/jquery-stream/wiki/ChatExample
http://cometd.org/documentation/2.x/howtos/servlet-containers
http://svn.cometd.com/trunk/