`
sillycat
  • 浏览: 2537793 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Comet-Jetty(3)Update the Sample

 
阅读更多
Comet-Jetty(3)Update the Sample

Try the sample project cometd-demo

error message when import this to eclipse:
Plugin execution not covered by lifecycle configuration:org.apache.felix:maven-buildle-plugin:2.3.5:manifest(execution:osgi,phase:process-classes)

Solution:
temporarily comments the felix plugin in parent pom.xml

Run this project with command
>mvn jetty:run

Import this project to eclipse
>mvn eclipse:eclipse -Dwtpversion=1.5

Run this project on eclipse
First of all, install http://download.eclipse.org/jetty/updates/jetty-wtp plugin on eclipse:

Download the distributed version of jetty.
http://download.eclipse.org/jetty/

Find my sample project easycometd, start from here.

add this to my pom.xml
org.eclipse.jetty
jetty-server
7.6.4.v20120524

comment the websocket transport

error message:
java.lang.IllegalStateException: Not supported.
at org.apache.catalina.connector.Request.startAsync(Request.java:1664)
at org.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>

error message when running mvn tomcat:run
java.lang.ClassCastException: org.eclipse.jetty.continuation.ContinuationFilter cannot be cast to ja
vax.servlet.Filter

solution:
remove the jar in pom.xml
org.eclipse.jetty
jetty-server
7.6.4.v20120524

At the final testing, it is working. My sample pom.xml will be as follow:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="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.0 http://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>

And here is the cometd-context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="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
">
     <bean id="bayeux" class="org.cometd.server.BayeuxServerImpl" init-method="start" destroy-method="stop">
        <property name="options">
            <map>
                <entry key="logLevel" value="3" />
                <entry key="timeout" value="15000" />
            </map>
        </property>
        <property name="transports">
            <list>
                <bean id="jsonTransport" class="org.cometd.server.transport.JSONTransport">
                    <constructor-arg ref="bayeux" />
                </bean>
                <bean id="jsonpTransport" class="org.cometd.server.transport.JSONPTransport">
                    <constructor-arg ref="bayeux" />
                </bean>
            </list>
        </property>
    </bean>
   
    <bean class="org.springframework.web.context.support.ServletContextAttributeExporter">
        <property name="attributes">
            <map>
                <entry key="org.cometd.bayeux">
                    <ref local="bayeux" />
                </entry>
            </map>
        </property>
    </bean>
</beans>

And some little changes in web.xml to use the spring like my previous project:
<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>

It is working now. And I will try to refactor this project.

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/

分享到:
评论

相关推荐

    comet-iframe.rar

    在"comet-iframe.rar"这个压缩包中,可能包含了关于如何将PHPComet集成到IFrame中的示例代码、配置文件或者教程文档。这些资源可以帮助开发者理解如何创建一个可以实时更新的IFrame,以及如何配置PHPComet服务器来...

    comet-ajax

    comet-ajax聊天comet-ajax聊天comet-ajax聊天comet-ajax聊天comet-ajax聊天comet-ajax聊天comet-ajax聊天comet-ajax聊天comet-ajax聊天

    comet-atomic-2020

    (Comet-)ATOMIC 2020:关于符号和神经常识知识图 纸 耶拿·黄(Jena D. Hwang),钱德拉(Chandra Bhagavatula),罗南·勒布拉斯(Ronan Le Bras),杰夫·达(Jeff Da),坂口圭介(Keisuke Sakaguchi),安托万...

    gwt-comet-jar包+实例+source.jar包,

    里面东西很多,都是关于GWT-COMET的内容,实现gwt的服务器推技术,包括gwt-comet-examples-1.2.3:google官网上的Test实例;gwt-comet-1.2.3.jar:jar包,gwt-example:聊天实例源代码(.java的),gwt-event-source...

    Python库 | unbabel-comet-0.0.1.tar.gz

    3. 进入解压后的目录`cd unbabel-comet-0.0.1`。 4. 运行`python setup.py install`来安装库。如果遇到权限问题,可以尝试使用`sudo`。 一旦安装成功,开发者就可以在他们的Python项目中导入并使用"unbabel_comet...

    atmosphere-flick-comet-0.2-m1-sources.jar

    atmosphere-flick-comet-0.2-m1-sources.jar

    atmosphere-flick-comet-0.3.1-sources.jar

    atmosphere-flick-comet-0.3.1-sources.jar

    atmosphere-flick-comet-0.5.1-sources.jar

    atmosphere-flick-comet-0.5.1-sources.jar

    atmosphere-flick-comet-0.4-sources.jar

    atmosphere-flick-comet-0.4-sources.jar

    atmosphere-flick-comet-0.3-sources.jar

    atmosphere-flick-comet-0.3-sources.jar

    atmosphere-flick-comet-0.2-sources.jar

    atmosphere-flick-comet-0.2-sources.jar

    atmosphere-flick-comet-0.1-sources.jar

    atmosphere-flick-comet-0.1-sources.jar

    科密点钞机升级操作指引教程

    科密点钞机升级操作指引教程,升级识别2015版人民币 WJD-Comet-A30 WJD-Comet-B329 WJD-Comet-C518 WJD-Comet-D629 WJD-Comet-KM2800 WJD-Comet-KM6800

    comet-for-mlflow:Comet-For-MLFlow扩展

    Comet-For-MLFlow扩展 Comet-For-MLFlow扩展是一个CLI,可将MLFlow实验运行映射到Comet实验。 此扩展程序使您可以在Comet.ml UI中查看现有实验,该UI提供了对实验结果的经过身份验证的访问权限,大大提高了大批量...

    comet-jquery

    【comet-jquery】是一种基于jQuery的实时通信技术,它利用了Comet技术来实现服务器向客户端推送数据的功能。在Web开发中,传统的HTTP协议是请求-响应模式,即客户端发起请求,服务器返回数据,而Comet技术打破了这种...

    科密票据打印机官方驱动程序 COMET-CM-30 官方版(32位/64位)

    科密票据打印机官方驱动程序 COMET-CM-30是CM-30票据打印机的官方驱动,使用这款驱动能完美驱程COMET-CM-30的票据打印机,有需要的用户可以下载驱动程序安装。小编已经把win32位和win64位的驱动都打包在压缩包里,请...

    科密票据打印机官方驱动程序 COMET-CK-300K 官方版(32位/64位)

    科密票据打印机官方驱动程序 COMET-CK-300K是CK-300K打印机的专用驱动程序,能完美驱程COMET-CK-300K的票据打印机,有需要的用户可以下载驱动程序安装。小编提供了32位和64位的驱动,请用户根据自身系统选择对应的...

    Python库 | comet_ml-2.0.12.tar.gz

    在实际使用Comet_ml时,首先需要通过pip安装:`pip install comet-ml`。然后,在项目开始时,引入comet_ml库并初始化实验,例如:`from comet_ml import Experiment; experiment = Experiment(api_key="YOUR_API_KEY...

    comet-php with chatroom demo

    【标题】"comet-php with chatroom demo"指的是一个基于Comet技术的PHP聊天室示例项目。Comet是一种Web实时通信技术,它允许服务器向客户端推送数据,而不仅仅是响应客户端的请求,从而实现了双向通信。 【描述】...

    Jetty+Dojo+Tomcat的Comet配置

    jetty-6.1.9 jetty-util-6.1.9 servlet-api-2.5-6.1.9 全网搜索dojox.cometd实现WEBQQ,没有可以运行的源码包项目,搞了五天,分享给大家,真实可用,jar包就找了好久,花了5分,搞了5天5分。共10分。 付原作者地址...

Global site tag (gtag.js) - Google Analytics