0

我刚刚在我的 JBoss AS 7 上从 Richfaces 3.3.3 升级到 4.2.2,从 Seam 2.2.2 升级到 Seam 2.3。目前它运行良好。

但我必须使用标签:a4j:push,我不知道如何将接缝组件绑定到这个。

是)我有的:

@Name(TestBeanInterface.NAME)
@JndiName(value=TestBeanInterface.JNDI_NAME)
@Scope(ScopeType.SESSION)
public class TestBean implements Serializable {

private static final String CDI_PUSH_TOPIC = "pushCdi";

private String userIdentifier;

@Inject
@Push(topic = CDI_PUSH_TOPIC, subtopic = "#{testBean.userIdentifier}")
private javax.enterprise.event.Event<String> pushEvent;

@PostConstruct
public void init() {
    System.out.println("hey");

    if (userIdentifier == null) {
        userIdentifier = UUID.randomUUID().toString().replace("-", "");
    }

    TopicsContext topicsContext = TopicsContext.lookup();
    topicsContext.getOrCreateTopic(new TopicKey(CDI_PUSH_TOPIC, userIdentifier));
}

public void sendMessage() throws Exception {
    System.out.println("Send Message");
    pushEvent.fire("a test message");
}

public String getUserIdentifier() {
    return userIdentifier;
}

public void setUserIdentifier(String userIdentifier) {
    this.userIdentifier = userIdentifier;
}
}

我得到什么:

22:23:28,191 INFO  [org.atmosphere.cpr.AtmosphereFramework] (MSC service thread 1-2) Atmosphere is using async support: org.atmosphere.container.BlockingIOCometSupport running under container: JBoss Web/7.0.13.Final
22:23:28,193 INFO  [org.atmosphere.cpr.AtmosphereFramework] (MSC service thread 1-2) Installed WebSocketProtocol org.atmosphere.websocket.protocol.SimpleHttpProtocol 
22:23:28,201 INFO  [org.atmosphere.cpr.AtmosphereFramework] (MSC service thread 1-2) Installed Default AtmosphereInterceptor [Android Interceptor Support, SSE Interceptor Support, JSONP Interceptor Support]. Set org.atmosphere.cpr.AtmosphereInterceptor.disableDefaults in your xml to disable them.
22:23:28,203 WARN  [org.atmosphere.cpr.AtmosphereFramework] (MSC service thread 1-2) No BroadcasterCache configured. Broadcasted message between client reconnection will be LOST. It is recommended to configure the HeaderBroadcasterCache.
22:23:28,204 INFO  [org.atmosphere.cpr.AtmosphereFramework] (MSC service thread 1-2) HttpSession supported: false
22:23:28,205 INFO  [org.atmosphere.cpr.AtmosphereFramework] (MSC service thread 1-2) Using BroadcasterFactory: org.atmosphere.cpr.DefaultBroadcasterFactory
22:23:28,205 INFO  [org.atmosphere.cpr.AtmosphereFramework] (MSC service thread 1-2) Using WebSocketProcessor: org.atmosphere.websocket.DefaultWebSocketProcessor
22:23:28,206 INFO  [org.atmosphere.cpr.AtmosphereFramework] (MSC service thread 1-2) Using Broadcaster: org.atmosphere.cpr.DefaultBroadcaster
22:23:28,208 INFO  [org.atmosphere.cpr.AtmosphereFramework] (MSC service thread 1-2) Atmosphere Framework 1.0.0.beta5 started.
22:23:28,212 INFO  [org.atmosphere.cpr.MeteorServlet] (MSC service thread 1-2) Installed Filter/Meteor org.richfaces.webapp.PushHandlerFilter mapped to /*
22:23:28,234 INFO  [org.atmosphere.cpr.AtmosphereFramework] (MSC service thread 1-2) Installed AtmosphereHandler org.atmosphere.handler.ReflectorServletProcessor mapped to context-path: /*
22:23:28,236 INFO  [org.atmosphere.handler.ReflectorServletProcessor] (MSC service thread 1-2) Installing Servlet null
22:23:28,238 INFO  [org.atmosphere.handler.ReflectorServletProcessor] (MSC service thread 1-2) Installing Filter PushHandlerFilter
.....
22:23:38,101 INFO  [stdout] (http-localhost-127.0.0.1-8080-1) hey
22:23:38,538 WARN  [org.jboss.seam.mock.MockViewHandler] (http-localhost-127.0.0.1-8080-1) You should catch the exception before Seam: java.lang.IllegalArgumentException: no file extension in servlet path: /__richfaces_push
    at org.jboss.seam.mock.MockViewHandler.getActionURL(MockViewHandler.java:49) [jboss-seam.jar:2.3.0.Beta2]
    at org.jboss.seam.jsf.SeamViewHandler.getActionURL(SeamViewHandler.java:75) [jboss-seam.jar:2.3.0.Beta2]
    at org.jboss.seam.faces.FacesManager.redirect(FacesManager.java:168) [jboss-seam.jar:2.3.0.Beta2]
    at org.jboss.seam.faces.Redirect.execute(Redirect.java:154) [jboss-seam.jar:2.3.0.Beta2]
    at org.jboss.seam.exception.DebugPageHandler.handle(DebugPageHandler.java:32) [jboss-seam.jar:2.3.0.Beta2]
    at org.jboss.seam.exception.Exceptions.handle(Exceptions.java:76) [jboss-seam.jar:2.3.0.Beta2]
    at org.jboss.seam.web.ExceptionFilter.endWebRequestAfterException(ExceptionFilter.java:114) [jboss-seam.jar:2.3.0.Beta2]
    at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:70) [jboss-seam.jar:2.3.0.Beta2]
    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [jboss-seam.jar:2.3.0.Beta2]
    at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45) [jboss-seam.jar:2.3.0.Beta2]
    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [jboss-seam.jar:2.3.0.Beta2]
    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73) [jboss-seam.jar:2.3.0.Beta2]
    at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158) [jboss-seam.jar:2.3.0.Beta2]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:397) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
    at java.lang.Thread.run(Thread.java:679) [rt.jar:1.6.0_24]
4

1 回答 1

2

这些是我最终在 Push 工作后在 Richfaces 论坛上写的笔记。请浏览一下,看看这是否有帮助。

  • 我正在使用 servlet v3 容器 (web.xml: web-app version="3.0"),因此不需要在 web.xml 中显式声明推送 servlet。

  • 我在 web.xml 中看到了 PushFilter 的一些示例,这肯定给我带来了问题,我只是在删除它之后才让它工作。

  • 我已经看到它建议在 web.xml 中使用它,但我不需要:

    <context-param>
       <param-name>org.richfaces.push.handlerMapping</param-name>
       <param-value>/__richfaces_push</param-value>
    </context-param>
    
  • 晚于(不包括)0.8.0-RC1 的 Atmosphere 版本似乎存在问题,导致 WebSockets 出现 NoClassDefFound 错误(无论如何都是这样)。最新版本 0.8.2 不起作用。

  • 需要在 java 文件中与 topicContext 相关的行 - 这就是导致“主题 'topic-name' 未配置错误”的原因。展示示例中缺少这些,但在组件指南中引用。

pom.xml

<dependency>
            <groupId>org.atmosphere</groupId>
            <artifactId>atmosphere-runtime</artifactId>
            <version>0.8.0-RC1</version>
            <type>jar</type>
</dependency>

域.xml

<jvm-options>-Dcom.sun.grizzly.http.asyncwrite.enabled=true</jvm-options>
<jvm-options>-Dcom.sun.grizzly.http.asyncwrite.maxBufferPoolSize=10000</jvm-options>

web.xml

<context-param>
        <param-name>org.richfaces.push.jms.disable</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>org.atmosphere.useBlocking</param-name>
        <param-value>true</param-value>
</context-param>
<servlet>
        <description>AtmosphereServlet</description>
        <servlet-name>AtmosphereServlet</servlet-name>
        <servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
        <async-supported>true</async-supported>
</servlet>

测试.xhtml

<h:outputText id="uid" value="uid: #{testBean.userIdentifier}"/>
<a4j:push address="#{testBean.userIdentifier}@pushCdi"
               onerror="alert('error: ' + event.rf.data)"
               ondataavailable="alert('data: ' + event.rf.data)">
    <a4j:ajax event="dataavailable"/>
</a4j:push>

TestBean.java

@ViewScoped
public class TestBean implements Serializable {

    private static final String CDI_PUSH_TOPIC = "pushCdi";
    private String userIdentifier;
    @Inject
    @Push(topic = CDI_PUSH_TOPIC, subtopic = "#{testBean.userIdentifier}")
    private javax.enterprise.event.Event<String> pushEvent;

    @PostConstruct
    public void init() {

        if (userIdentifier == null) {
            userIdentifier = UUID.randomUUID().toString().replace("-", "");
        }

        TopicsContext topicsContext = TopicsContext.lookup();
        topicsContext.getOrCreateTopic(new TopicKey(CDI_PUSH_TOPIC, userIdentifier));
    }

    public void sendMessage() throws Exception {
        Log.log("sendMessage");
        pushEvent.fire("a test message");
    }

    // add getters & setters
于 2012-08-20T12:59:20.090 回答