2

I am trying to integrate comet chat into my struts2+hibernate application .First I have tested comet chat in separate web application. It works fine .Ihave download it from http://skillshared.blogspot.in/2012/10/facebook-similar-chat-for-your-java-web.html after then I try to implement in my application

My problem in web.xml here is my web.xml file

<context-param>
    <param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
    <param-value>/WEB-INF/tiles.xml</param-value>
</context-param>

<listener>
    <listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>
<display-name>Cometd Test WebApp</display-name>


 <filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>

 </filter>

<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>      
</filter-mapping>

<!-- Portability Filter, needed only to run on non Jetty 
     or non Servlet-3.0 containers like Tomcat-->

<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>

<!-- Cometd Servlet -->
<servlet>
    <servlet-name>cometd</servlet-name>
    <servlet-class>org.cometd.annotation.AnnotationCometdServlet</servlet-class>
    <init-param>
        <param-name>timeout</param-name>
        <param-value>20000</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>0</param-value>
    </init-param>
    <init-param>
        <param-name>transports</param-name>
        <param-value>org.cometd.websocket.server.WebSocketTransport</param-value>
    </init-param>
    <init-param>
        <param-name>services</param-name>
        <param-value>com.semika.cometd.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>
 <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

from above code application works fine but chat not working. I saw so posts regarding this problem , I have a solution

<URL-pattern>*.action</URL-pattern>

when I am trying to do this chat works fine but application doesn't work. When I have place application only working.

<url-pattern>/*</url-pattern> 

I have tried this one also in struts.xml but no use.

<constant name="struts.action.excludePattern" value="/cometd/*,/cometd/.*"/>

What can be the cause of the problem ?

Roman C
  • 49,761
  • 33
  • 66
  • 176

1 Answers1

1

The whole thing depends on your Struts version. If you have an old version, you should migrate to a new version for many reasons, especially security fixes.

However, considering that:

  • With Struts >= 2.1.3, the FilterDispatcher is deprecated, and the new StrutsPrepareAndExecuteFilter must be used. Read more

  • With Struts <= 2.1.6, the struts.action.excludePattern doesn't exist. Read more

your code can't possibly work ;)

Community
  • 1
  • 1
Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243