0

JBoss AS 7 で Richfaces 3.3.3 から 4.2.2 に、Seam 2.2.2 から Seam 2.3 にアップグレードしました。

しかし、タグ: a4j:push を使用する必要があり、これに seam コンポーネントをバインドする方法がわかりません。

私が持っているもの:

@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

これらは、最終的にプッシュ作業を開始した後、Richfaces フォーラムに書いたメモです。ざっと目を通して、これが役立つかどうかを確認してください。

  • サーブレット v3 コンテナー (web.xml: web-app version="3.0") を使用しているため、プッシュ サーブレットを web.xml で明示的に宣言する必要はありません。

  • 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 バージョンに問題があるようで、WebSocket の NoClassDefFound エラーが発生します (とにかくそのようなもの)。最新バージョン 0.8.2 は動作しません。

  • java ファイル内の topicContext に関連する行が必要です。これが原因で、「トピック 'トピック名' が構成されていません」というエラーが発生します。これらはショーケースの例にはありませんが、コンポーネント ガイドで参照されています。

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>

test.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 に答える