【问题标题】:Push messages to clients in tapestry在挂毯中向客户端推送消息
【发布时间】:2016-04-01 17:29:04
【问题描述】:

有没有办法在挂毯中向客户端推送消息?我尝试了彗星而不是大气(大约2周),它们都对我不起作用。我有一些 exanpe jquery 冲突。 我的挂毯版本是 5.3.6。

对于 CometD,这些是我正在使用的依赖项:

<dependency>
        <groupId>org.cometd.java</groupId>
        <artifactId>cometd-java-server</artifactId>
        <version>3.0.9</version>
</dependency>
<dependency>
            <groupId>org.lazan</groupId>
            <artifactId>tapestry-cometd</artifactId>
            <version>0.9.18</version> 
 </dependency>
<dependency>
            <groupId>org.cometd.java</groupId>
            <artifactId>cometd-websocket-jetty</artifactId>
            <version>2.4.3</version>
</dependency>
<dependency>
            <groupId>org.got5</groupId>
             <artifactId>tapestry5-jquery</artifactId>
            <version>3.4.2</version>
 </dependency>

这是我正在使用的存储库:

<repository>
        <id>tapestry-cometd</id>
        <url>https://raw.github.com/uklance/releases/master</url>
    </repository>

我的java页面:

Object onChat(String message) {
        this.message = message;
        return myZone.getBody();
    }

        Object onSuccess() {
            pushManager.broadcast("/chatTopic", message);
            return request.isXHR() ? formZone.getBody() : null;
        }

我的tml页面:

<t:zone t:id="formZone" id="formZone">
    <form t:id="ajaxForm" t:type="form" t:zone="formZone">
     Message: <input t:type="TextField" t:id="message" />  <input type="submit" value="Send"/>
    </form>
</t:zone>

<t:cometd.PushTarget topic="/chatTopic" event="chat" update="replace" />
<t:zone t:id="myZone" id="myZone" t:zone="myZone">
 <h2 t:zone="myZone"> ${message}</h2>
 </t:zone> 

这是我得到的错误:

2016-04-07 13:58:10.377:WARN::failed app: java.lang.RuntimeException: Service id 'AjaxUploadDecoder' 已经由 org.got5.tapestry5.jquery.services.AjaxUploadDecoderImpl(FileItemFactory) 定义(在 AjaxUploadDecoderImpl.java:23)通过 org.got5.tapestry5.jquery.services.JQueryModule.bind(ServiceBinder)(在 JQueryModule.java:175),并且可能不会被 org.cyberplix.internal.services.AjaxUploadDecoderImpl(FileItemFactory )(在 AjaxUploadDecoderImpl.java:25)通过 org.cyberplix.services.AppModule.bind(ServiceBinder)(在 AppModule.java:81)。您应该重命名服务构建器方法之一。 2016-04-07 13:58:10.377:WARN:: 上下文 org.mortbay.jetty.plugin.Jetty6PluginWebAppContext@3abbbb74{/homewarranty,C:\HomeOneSource40\homewarranty\src\main\webapp} 启动失败 java.lang.RuntimeException:服务 id 'AjaxUploadDecoder' 已经由 org.got5.tapestry5.jquery.services.AjaxUploadDecoderImpl(FileItemFactory) (在 AjaxUploadDecoderImpl.java:23)通过 org.got5.tapestry5.jquery.services.JQueryModule 定义.bind(ServiceBinder) (在 JQueryModule.java:175 处)并且可能不会通过 org.cyberplix.services.AppModule.bind( ServiceBinder)(在 AppModule.java:81)。您应该重命名服务构建器方法之一。 在 org.apache.tapestry5.ioc.internal.RegistryImpl.(RegistryImpl.java:183) 在 org.apache.tapestry5.ioc.RegistryBuilder.build(RegistryBuilder.java:177) 在 org.apache.tapestry5.internal.TapestryAppInitializer.createRegistry(TapestryAppInitializer.java:200) 在 org.apache.tapestry5.TapestryFilter.init(TapestryFilter.java:109) 在 org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97) 在 org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) 在 org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:713) 在 org.mortbay.jetty.servlet.Context.startContext(Context.java:140) 在 org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1282) 在 org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:518) 在 org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499) 在 org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart(Jetty6PluginWebAppContext.java:115) 在 org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) 在 org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152) 在 org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156) 在 org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) 在 org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152) 在 org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) 在 org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) 在 org.mortbay.jetty.Server.doStart(Server.java:224) 在 org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) 在 org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:132) 在 org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:454) 在 org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:396) 在 org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute(AbstractJettyRunMojo.java:210) 在 org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:184) 在 org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) 在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) 在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) 在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) 在 org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) 在 org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) 在 org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) 在 org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) 在 org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) 在 org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) 在 org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) 在 org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) 在 org.apache.maven.cli.MavenCli.main(MavenCli.java:141) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java:606) 在 org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) 在 org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) 在 org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) 在 org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) 2016-04-07 13:58:10.391:INFO::Started SelectChannelConnector@0.0.0.0:8081 [INFO] 启动 Jetty 服务器

【问题讨论】:

  • 你的问题很模糊。例如,您是否直接使用 cometd/atmosphere?或者您使用的是tapestry-atmospheretapestry-cometd。什么是扩展?你看到了什么错误等等?
  • 嗨兰斯,我已经更新了我的帖子!

标签: jquery tapestry atmosphere cometd


【解决方案1】:

此错误消息表明您的注册表中的两个服务正在尝试使用 AjaxUploadDecoder 的相同 serviceId

  • org.got5.tapestry5.jquery.services.AjaxUploadDecoderImpl
  • org.cyberplix.internal.services.AjaxUploadDecoderImpl

您需要为所有服务使用唯一名称

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-01-12
    • 2019-11-12
    • 2015-03-03
    • 2015-10-26
    • 1970-01-01
    • 2023-03-25
    • 1970-01-01
    • 2015-04-07
    相关资源
    最近更新 更多