質問

We had an issue with our CometD/Gigaspaces application creating a duplicate instances of the Bayeux Server. See my previous question posted here. After investigating this issue with Gigaspaces, it turns out each bean defined in our Application Context File was getting created twice as GigaSpaces has special treatment for Application Context Files called PU.XML. We've resolved this issue by renaming the PU.XML File but the problem we have now is that we're not receiving any data on the client side and receive the following error "NetworkError: 400 Unknown Bayeux Transport - http://localhost:9292/cometd".

Previously, when the application created a duplicate instance of the Bayeux Server, we put a workaround in place to terminate the first instance of the thread that the Bayeux Server was running on and as a result we were able to publish data on our channels using Web Sockets which we configured in the Application Context File.

Could you have a look at our current configuration and let me know if there is a alternative solution to configure and export the Bayeux Server correctly using Spring? Is it possible the Bayeux bean is not getting exported correctly or if it is getting exported too late??

I've posted our updated Web.XML and Application Context configurations below. The CometD Version/Jars in our POM.XML are the same as my previous post. If you need further info. please let me know.

Current Web.XMl:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    id="WebApp_ID" version="2.5">
    <display-name>CometDApplication</display-name>          
    <servlet>
        <servlet-name>cometd</servlet-name>
        <servlet-class>org.cometd.server.CometdServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>cometd</servlet-name>
        <url-pattern>/cometd/*</url-pattern>
    </servlet-mapping>  
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>  
    <!-- <listener>
        <listener-class>org.openspaces.pu.container.jee.context.ProcessingUnitContextLoaderListener</listener-class>
    </listener>-->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext-gigaspaces.xml</param-value>
    </context-param>
</web-app>

Current applicationContext-gigaspaces.XML:

<bean id="Bayeux" class="org.cometd.server.BayeuxServerImpl"
        init-method="start" destroy-method="stop">
        <property name="options">
            <map>
                <entry key="logLevel" value="0" />
                <entry key="timeout" value="15000" />
            </map>
        </property>
        <property name="transports">
            <list>
                <!-- The order of the following transports dictates the type of transport 
                    used i.e. Web Sockets then JsonTransport (a.k.a long-polling) -->
                <bean id="websocketTransport" class="org.cometd.websocket.server.WebSocketTransport">
                    <constructor-arg ref="Bayeux" />
                </bean>
                <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>

    <!-- Export the Bayeux Server to the servlet context via springs ServletContextAttributeExporter -->
    <bean id="ContextExporter"
        class="org.springframework.web.context.support.ServletContextAttributeExporter">
        <property name="attributes">
            <map>
                <entry key="org.cometd.bayeux">
                    <ref local="Bayeux" />
                </entry>
            </map>
        </property>
    </bean>
役に立ちましたか?

解決

The code you posted is correct and virtually identical to the test present in CometD, see here and here.

You have something else going on, and debug logs on both client and server will help you understanding.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top