PAX WEB: Websocket annotations working?

27 views
Skip to first unread message

Stephan Siano

unread,
Jun 25, 2019, 9:25:24 AM6/25/19
to OPS4J
Hi,

I have a question concerning web sockets in Pax-Web:

A colleague of mine is trying to deploy a war on a Pax-Web container that contains some annotated websocket server endpoints. This works with other web containers but not on Pax web (he is getting a 404 response when he is trying to upgrade the connection).

I looked into the Pax-Web integration tests and it turned out that there is an integration test for a very similar scenario WebSocketIntegrationTest,testWebSocket() which uses the websocket-jsr356 sample bundle.

However, this test was disabled. Even worse, it did not work anymore after the test client was moved from the jetty http client to the apache http client (because it currently uses a jetty websocket client which relies on the jetty http client).

I changed the test infrastructure to use a jsr356 client (with the container specific implementation) and with some hassle around the class loading because of the pax-exam infrastructure I could likely get this running (at least with tomcat and undertow). However on both containers I get a 404 response code when upgrading the connection (as my colleague got with his websocket endpoint.

Did this ever work in Pax-Web? I couldn't find any coding that is parsing for the ServerEndpoint annotation (only Servlet and other stuff). Or is this still unimplemented?

Best regards
Stephan

Grzegorz Grzybek

unread,
Jun 25, 2019, 9:27:37 AM6/25/19
to op...@googlegroups.com
Hello

I saw this @Ignored test, but I never worked with these annotation. I don't think it ever worked...
And I'm pretty sure I didn't break it ;)

regards
Grzegorz Grzybek

--
--
------------------
OPS4J - http://www.ops4j.org - op...@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ops4j/1baaf72c-d85f-423f-a9f3-91974ca72ba4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jean-Baptiste Onofré

unread,
Jun 25, 2019, 9:40:22 AM6/25/19
to op...@googlegroups.com

Hi,

AFAIR, it's not yet fully supported.

But easy to add/fix, I will tackle that.

Regards
JB

Stephan Siano

unread,
Jun 25, 2019, 10:22:35 AM6/25/19
to OPS4J
Hi,

I'm not so sure whether this is easy. I couldn't find anything about the web socket annotations in the War extender (plus the annotation scanner in the War extender creates some kind of dummy web.xml structure from the scanned annotations, but there are no web.xml entries for websockets). 

Nevertheless, are you interested in my changes to the tests? I think with these changes the tests start again (at least on Tomcat and Undertow), but the tests fail. I also tried to register the Websocket programatically with a ContextListener but there I couldn't get the ServerContainer from the ServletContext (AFAIK this should work via servletContext.getAttribute("javax.websocket.server.ServerContainer");). There is probably all the websocket infrastructure missing in the Pax-Web classes.

Best regards
Stephan


On Tuesday, June 25, 2019 at 3:40:22 PM UTC+2, Jean-Baptiste Onofré wrote:

Hi,

AFAIR, it's not yet fully supported.

But easy to add/fix, I will tackle that.

Regards
JB

On 25/06/2019 15:25, Stephan Siano wrote:
Hi,

I have a question concerning web sockets in Pax-Web:

A colleague of mine is trying to deploy a war on a Pax-Web container that contains some annotated websocket server endpoints. This works with other web containers but not on Pax web (he is getting a 404 response when he is trying to upgrade the connection).

I looked into the Pax-Web integration tests and it turned out that there is an integration test for a very similar scenario WebSocketIntegrationTest,testWebSocket() which uses the websocket-jsr356 sample bundle.

However, this test was disabled. Even worse, it did not work anymore after the test client was moved from the jetty http client to the apache http client (because it currently uses a jetty websocket client which relies on the jetty http client).

I changed the test infrastructure to use a jsr356 client (with the container specific implementation) and with some hassle around the class loading because of the pax-exam infrastructure I could likely get this running (at least with tomcat and undertow). However on both containers I get a 404 response code when upgrading the connection (as my colleague got with his websocket endpoint.

Did this ever work in Pax-Web? I couldn't find any coding that is parsing for the ServerEndpoint annotation (only Servlet and other stuff). Or is this still unimplemented?

Best regards
Stephan
--
--
------------------
OPS4J - http://www.ops4j.org - op...@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to op...@googlegroups.com.

Jean-Baptiste Onofré

unread,
Jun 25, 2019, 10:49:40 AM6/25/19
to op...@googlegroups.com

I mean that it's a similar pattern we use for other "connector".

By the way, did you take a look on the websocket example in Karaf ?

Regards
JB

To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ops4j/919b3351-ea5e-46e7-8e3c-310970cb71b1%40googlegroups.com.

Achim Nierbeck

unread,
Jun 25, 2019, 11:45:03 AM6/25/19
to op...@googlegroups.com
Hi,

when I first started to look into websockets, there needed to be extra Bundles installed for Jetty.
That's about 4 to 5 years ago :)
But I haven't looked into the annotations, as far as I can remember.

Regards, Achim



For more options, visit https://groups.google.com/d/optout.


--

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master 

Stephan Siano

unread,
Jun 26, 2019, 5:33:09 AM6/26/19
to OPS4J
Hi,

I did some further work on the topic. Here are my results:

1. I have some changes that are required to get the tests working at all. There is some heavy use of service loaders in the websocket API, which doesn't play too well with OSGi, so some tricks with ThreadContext class loaders are needed.
2. With these changes the tests works with the jetty container (I don't know who parses these Annotations, but obviously something in Jetty does).
3. I did some change to the sample bundle to have it register itself programatically (as an option). With this change, the test will work on Tomcat, so the runtime does work in tomcat but the automatic registration doesn't. In order to make that working, I needed to register an additional ServletContainerInitializer in pax-web-tomcat.
4. I could not get it working with the Undertow container (the registration, the test does work but returns a 404 when trying to upgrade the websocket), which means that the endpoint is not registered.

I think I should contribute what I have now because it will bring us a working test for websockets on Jetty and at least partially working websocket support on Tomcat. Do I create a new JIRA item for that or do I re-use PAXWEB-1027, which is still open?

Does anybody know how the websocket endpoint annotation parsing works in pax-web-jetty (and maybe how we can get the same functionality with Tomcat and Undertow)?

Best regards
Stephan

--
--
------------------
OPS4J - http://www.ops4j.org - op...@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to op...@googlegroups.com.

Jean-Baptiste Onofré

unread,
Jun 26, 2019, 7:25:01 AM6/26/19
to op...@googlegroups.com

+1 to reuse PAXWEB-1027, and happy to work with you on this one ;)

Regards
JB

To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ops4j/dccc6d6f-202c-431c-8780-96b9b9b3c29d%40googlegroups.com.

Achim Nierbeck

unread,
Jun 26, 2019, 7:32:46 AM6/26/19
to op...@googlegroups.com
I'll need to dig down to it again,
Afaik I added the parser for the websocket stuff ... :D

regards, Achim



For more options, visit https://groups.google.com/d/optout.

Stephan Siano

unread,
Jun 26, 2019, 8:32:43 AM6/26/19
to OPS4J
OK, I created a first pull request that only contains the test changes. It's for the pax-web-7.2.x branch right now, but it should also work in master and pax-web-7.3.x branches (I can create pull requests also for these branches, but I would prefer to complete the review first). I have set you as a reviewer for it. I have not included the Tomcat patch because I would prefer to have different commits for the test extensions and the coding changes and because while the change makes the websocket test run on tomcat it has side effects on other tests (without websockets).

Grzegorz Grzybek

unread,
Jun 26, 2019, 8:35:46 AM6/26/19
to op...@googlegroups.com
Hello

Don't bother much with pax-web-7.3.x branch. As I wrote here[1], 7.3.0 is kind of "tech preview" with Tomcat 9 and Undertow 2. As it's missing Jetty 10, don't treat 7.3.x as the "main" 7.x line.

regards
Grzegorz Grzybek
===

To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ops4j/d681b088-e7b7-42e6-99e1-cf3d66458dff%40googlegroups.com.

Stephan Siano

unread,
Jun 27, 2019, 10:24:32 AM6/27/19
to OPS4J
Hi.

I found Achim's commit where he added websocket support in Jetty. That actually did the trick, after I added a similar approach in Tomcat and now also the annotations work. I prepare another commit later today (or tomorrow).

Both Jetty and Tomcat have a ServletContainerInitializer that does the websocket initialization and Achim's coding is scanning for the required annotations.

So in the end the websocket integration test will work with Jetty and Tomcat (but not with Undertow).

Best regards
Stephan

--
--
------------------
OPS4J - http://www.ops4j.org - op...@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to op...@googlegroups.com.

Achim Nierbeck

unread,
Jun 30, 2019, 1:22:52 PM6/30/19
to op...@googlegroups.com
Glad you found it.
Was just about to look for it.
Thanks, Achim

To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ops4j/d54c9c31-1f35-49e8-bff4-07675ba29af5%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Jean-Baptiste Onofré

unread,
Jul 1, 2019, 2:33:58 PM7/1/19
to OPS4J
Thanks Stephan

I will take a look.

Regards
JB

To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ops4j/d681b088-e7b7-42e6-99e1-cf3d66458dff%40googlegroups.com.

Stephan Siano

unread,
Jul 2, 2019, 7:51:18 AM7/2/19
to OPS4J
Hi,

OK, I have merged my two changes (the general enablement of the websocket integration test and the fix to provide websocket support for tomcat) into the pax-web-7.2.x, pax-web-7.3.x, and the master branch.

The whiteboard support for websockets still does not work for all containers (that's what is PAXWEB-1027 is mainly about) and the websocket support via WAB with the undertow container also doesn't work (the test for that is ignored for undertow).

Shall I create a JITA task for the undertow container (though I will not be able to actually fix the issue there)?

Best regards
Stephan
JB

Jean-Baptiste Onofré

unread,
Jul 2, 2019, 8:49:14 AM7/2/19
to op...@googlegroups.com

+1 to create a Jira related to undertow.

Regards
JB

To unsubscribe from this group and stop receiving emails from it, send an email to ops4j+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ops4j/b15582a6-815c-4338-ac68-6d3a00647db8%40googlegroups.com.

Achim Nierbeck

unread,
Jul 2, 2019, 12:15:30 PM7/2/19
to op...@googlegroups.com
Hi,

yes please. Create a Jira issue.
Creating an issue, doesn't mean you have to fix it ;)

Thanks, Achim



For more options, visit https://groups.google.com/d/optout.

Stephan Siano

unread,
Jul 2, 2019, 12:40:05 PM7/2/19
to OPS4J
Hi,


Best regards
Stephan

--
--
------------------
OPS4J - http://www.ops4j.org - op...@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to op...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages