Hi Sergey, Aki,

My application seems to work under Tomcat 8 with the following modifications:

1) Add @ServerEndpoint(value = "/services") on my service class (named 
UserService.java)
2) Add a method into this class with the annotation @OnMessage like:
        @OnMessage
        public String hello(String message) {
                return "Hello!";
        }
3) Add the following dependency in my pom.xml
        <dependency>
                <groupId>javax.websocket</groupId>
                <artifactId>javax.websocket-api</artifactId>
                <version>1.0</version>
                <scope>provided</scope>
        </dependency>

With these changes, the sample almost works in both Tomcat version (7 and 8), 
except that all websocket requests are routed to the method having @OnMessage 
annotation :)

It seems it needs some configurations again :)

Hope this will help.

Best regards,
Anthony

-----Original Message-----
From: MULLER, Anthony [mailto:anthony.mul...@sap.com] 
Sent: jeudi 29 septembre 2016 15:18
To: users@cxf.apache.org
Subject: RE: CXF 3.1 + Tomcat 8 + JAR-RS + Atmosphere + WebSocket

Hi Sergey,

Thanks very much, I deployed on Tomcat 7 and it works fine.

I will investigate deeper to try to understand what's going on with Tomcat 8...

Regards,
Anthony

-----Original Message-----
From: Sergey Beryozkin [mailto:sberyoz...@gmail.com] 
Sent: jeudi 29 septembre 2016 12:17
To: users@cxf.apache.org
Subject: Re: CXF 3.1 + Tomcat 8 + JAR-RS + Atmosphere + WebSocket

Hi Anthony

Sorry it is my fault, I looked at the master source, not realizing 3.1.7 
uses a different Atmosphere version (2.3.7).

I've run a websocket_web demo with a Tomcat 7 plugin and it works fine 
for me. Can you confirm please this demo also works for you ?

Thanks, Sergey
On 29/09/16 08:47, MULLER, Anthony wrote:
> Hi Sergey,
>
> I made the recommended changes (upgrade Atmosphere and disable the async 
> feature of CXFServlet), I got this error when trying to connect.
>
> Seems there is a mismatch between the used CXF version (3.1.7) and Atmosphere 
> (2.4.3).
>
> Best regards,
> Anthony
>
>
> SEVERE: Servlet.service() for servlet [CXF Bootstrap] in context with path 
> [/cxf31_websocket] threw exception [Servlet execution threw an exception] 
> with root cause
> java.lang.NoSuchMethodError: 
> org.atmosphere.cpr.AtmosphereRequest.wrap(Ljavax/servlet/http/HttpServletRequest;)Lorg/atmosphere/cpr/AtmosphereRequest;
>       at 
> org.apache.cxf.transport.websocket.atmosphere.AtmosphereWebSocketServletDestination.invoke(AtmosphereWebSocketServletDestination.java:73)
>       at 
> org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234)
>       at 
> org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208)
>       at 
> org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160)
>       at 
> org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:180)
>       at 
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:299)
>       at 
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:223)
>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
>       at 
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:274)
>       at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
>       at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
>       at 
> org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
>       at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
>       at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
>       at 
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
>       at 
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
>       at 
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
>       at 
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
>       at 
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
>       at 
> org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
>       at 
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
>       at 
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
>       at 
> org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
>       at 
> org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:670)
>       at 
> org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
>       at 
> org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
>       at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
>       at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>       at 
> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
>       at java.lang.Thread.run(Thread.java:745)
>
> -----Original Message-----
> From: Sergey Beryozkin [mailto:sberyoz...@gmail.com]
> Sent: mercredi 28 septembre 2016 17:54
> To: users@cxf.apache.org
> Subject: Re: CXF 3.1 + Tomcat 8 + JAR-RS + Atmosphere + WebSocket
>
> Hi Anthony
>
> It all looks OK, except that you select the older Atmosphere version, it
> has to be 2.4.3 - so start from removing that pom section where you get
> an older version from the non-Central maven location.
>
> The other thing - enabling async (suspended) continuations is not needed
> for WebSocket (AFAIK), I'm not sure if it interferes, try disabling this
> CXFServlet setting if using the latest Atmosphere does not help (it
> would an issue of its own - but for now lets try to isolate where the
> problem is)
>
> Sergey
> On 28/09/16 16:26, MULLER, Anthony wrote:
>> Hello CXF Experts, Sergey, Aki,
>>
>> I have some issues to implement a simple test using WebSocket with CXF 
>> 3.1.7, in a Tomcat 8 Servlet container.
>>
>> To make troubleshooting easier, I shared my demo project (based on the 
>> official CXF samples written by Aki):
>> https://github.com/AnthonyMullerPlayground/cxf31_websocket
>>
>> The webapp context is "cxf31_websocket" and it contains a simple RESTful 
>> service running under "/services/users" path.
>>
>> The project also contains a basic index.html webpage to test the websocket.
>>
>> CXF is bootstrapped using: org.apache.cxf.transport.servlet.CXFServlet
>>
>> Spring is used to and configured this way with a "beans.xml" file:
>>
>>  <jaxrs:server id="websocketService" address="/" 
>> transportId="http://cxf.apache.org/transports/websocket"; />
>> <context:component-scan base-package="com.sap.businessobjects.amuller"/>
>>
>> When I check the websocket using Chrome, the following error is displayed in 
>> the Network panel of the developer tools:
>>
>> Request headers:
>> GET ws://localhost:8080/cxf31_websocket/services HTTP/1.1
>> Host: localhost:8080
>> Connection: Upgrade
>> Pragma: no-cache
>> Cache-Control: no-cache
>> Upgrade: websocket
>> Origin: http://localhost:8080
>> Sec-WebSocket-Version: 13
>> User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 
>> (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36
>> Accept-Encoding: gzip, deflate, sdch
>> Accept-Language: en-US,en;q=0.8,fr;q=0.6
>> Sec-WebSocket-Key: Uc/E4OEE/BnKx/EvHUgLtQ==
>> Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
>>
>> Response headers:
>> HTTP/1.1 501 Not Implemented
>> Server: Apache-Coyote/1.1
>> X-Atmosphere-first-request: true
>> X-Atmosphere-tracking-id: aeeb9f45-62e8-45b4-9d37-4657988e20ec
>> X-Atmosphere-error: Websocket protocol not supported
>> Transfer-Encoding: chunked
>> Date: Wed, 28 Sep 2016 15:21:58 GMT
>> Connection: close
>>
>> No error is displayed in the Eclipse console... I'm stuck because I didn't 
>> really get the magic behind the scene. It seems that the transportId 
>> attribute is enabling the full WebSocket logic? 
>> (transportId="http://cxf.apache.org/transports/websocket";)
>>
>> Thanks for your help and explanations.
>>
>> Best regards,
>> Anthony MÜLLER
>>
>>
>>
>>
>

Reply via email to