openwebbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Romain Manni-Bucau <rmannibu...@gmail.com>
Subject Re: Support of JAX-RS 2.1 SSE using CXF
Date Sat, 03 Feb 2018 18:04:53 GMT
Hi

did you add tomcat-websocket too?

the reason behind it is to let /index.html works even if you didn't set any
application for your jaxrs endpoint and therefore we bound /* by default.

normally you don't need atmosphere setup if you have websocket and the
filter is before ours so it should work.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>

2018-02-03 19:01 GMT+01:00 Aaron Anderson <aaronanderson@acm.org>:

> Hi All,
>
> I made some progress on getting JAX-RS 2.1 SSE working on Meecrowave but I
> encountered an issue I can't get past. To get CXF SSE working on Meecrowave
> I had to do the following:
>
> 1) Add in the CXF SSE maven dependency to my runner:
>          <dependency>
>             <groupId>org.apache.cxf</groupId>
>             <artifactId>cxf-rt-rs-sse</artifactId>
>             <version>3.2.1</version>
>         </dependency>
>
> 2) Update my runner meecrowave.properties to exclude atomosphere (many
> unresolved classes and an ambiguous CDI dependency) and also set the CXF
> transport to the SSE extension transport.
>
> scanning-package-exclude=org.atmosphere
> cxf.servlet.params.transportId=http://cxf.apache.org/transports/http/sse
> cxf.servlet.params.jaxrs.scope=singleton
>
> 3) In addition to setting the transport on the front for CXF request
> handling the transport also needs to be set on the backend CXF
> JAXRSCdiResourceExtension that discovers resources by annotation. The SSE
> extension's SseTransportCustomizationExtension class performs this
> operation but currently it is not annotated with any CDI annotations so
> OpenWebBeans classpath scanning is ignoring it. I plan to open a CXF issue
> on this but for now I added a CDI extension to my runner to make
> OpenWebBeans aware of the class:
>
>
> import org.apache.cxf.jaxrs.sse.cdi.SseTransportCustomizationExtension;
>
> public class SSECDIExtension implements Extension {
>
> void addBeansFromJava(@Observes final BeforeBeanDiscovery bbd, final
> BeanManager bm) {
> bbd.addAnnotatedType(bm.createAnnotatedType(SseTransportCustomizationExten
> sion.class));
> }
> }
>
> After these changes the CXF SSE atmosphere runtime starts up but the
> following exception is generated:
>
> [11:18:49.098][ERROR][           main][   org.atmosphere.util.IOUtils]
> java.lang.IllegalStateException: Unable to configure jsr356 at that
> stage. No Servlet associated with cxf-cdi
>         at org.atmosphere.util.IOUtils.guestRawServletPath(IOUtils.java:275)
> [intworkspace-runner-2018.2.0-SNAPSHOT.jar:?]
>         at org.atmosphere.util.IOUtils.guestServletPath(IOUtils.java:248)
> [intworkspace-runner-2018.2.0-SNAPSHOT.jar:?]
>         at org.atmosphere.container.JSR356AsyncSupport.<init>(JSR356AsyncSupport.java:63)
> [intworkspace-runner-2018.2.0-SNAPSHOT.jar:?]
>         at org.atmosphere.container.JSR356AsyncSupport.<init>(JSR356AsyncSupport.java:40)
> [intworkspace-runner-2018.2.0-SNAPSHOT.jar:?]
>         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method) [?:1.8.0_92]
>         at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown
> Source) [?:1.8.0_92]
>         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
> Source) [?:1.8.0_92]
>         at java.lang.reflect.Constructor.newInstance(Unknown Source)
> [?:1.8.0_92]
>         at org.atmosphere.cpr.DefaultAsyncSupportResolver.newCometSupport(
> DefaultAsyncSupportResolver.java:237) [intworkspace-runner-2018.2.0-
> SNAPSHOT.jar:?]
>         at org.atmosphere.cpr.DefaultAsyncSupportResolver.
> resolveWebSocket(DefaultAsyncSupportResolver.java:308)
> [intworkspace-runner-2018.2.0-SNAPSHOT.jar:?]
>         at org.atmosphere.cpr.DefaultAsyncSupportResolver.resolve(
> DefaultAsyncSupportResolver.java:294) [intworkspace-runner-2018.2.0-
> SNAPSHOT.jar:?]
>         at org.atmosphere.cpr.AtmosphereFramework.autoDetectContainer(AtmosphereFramework.java:2083)
> [intworkspace-runner-2018.2.0-SNAPSHOT.jar:?]
>         at org.atmosphere.cpr.AtmosphereFramework.init(AtmosphereFramework.java:914)
> [intworkspace-runner-2018.2.0-SNAPSHOT.jar:?]
>         at org.atmosphere.cpr.AtmosphereFramework.init(AtmosphereFramework.java:838)
> [intworkspace-runner-2018.2.0-SNAPSHOT.jar:?]
>         at org.apache.cxf.transport.sse.atmosphere.
> AtmosphereSseServletDestination.onServletConfigAvailable(
> AtmosphereSseServletDestination.java:107) [intworkspace-runner-2018.2.0-
> SNAPSHOT.jar:?]
>         at org.apache.cxf.transport.http.DestinationRegistryImpl.
> onServletConfigAvailable(DestinationRegistryImpl.java:182)
> [intworkspace-runner-2018.2.0-SNAPSHOT.jar:?]
>         at org.apache.cxf.transport.servlet.CXFNonSpringServlet.
> finalizeServletInit(CXFNonSpringServlet.java:99)
> [intworkspace-runner-2018.2.0-SNAPSHOT.jar:?]
>         at org.apache.cxf.transport.servlet.CXFNonSpringServlet.
> init(CXFNonSpringServlet.java:91) [intworkspace-runner-2018.2.0-
> SNAPSHOT.jar:?]
>         at org.apache.meecrowave.cxf.CxfCdiAutoSetup$
> MeecrowaveCXFCdiServlet.init(CxfCdiAutoSetup.java:317)
> [intworkspace-runner-2018.2.0-SNAPSHOT.jar:?]
>         at org.apache.meecrowave.cxf.CxfCdiAutoSetup$1.init(CxfCdiAutoSetup.java:88)
> [intworkspace-runner-2018.2.0-SNAPSHOT.jar:?]
>         at org.apache.catalina.core.ApplicationFilterConfig.initFilter(
> ApplicationFilterConfig.java:277) [intworkspace-runner-2018.2.0-
> SNAPSHOT.jar:?]
>         at org.apache.catalina.core.ApplicationFilterConfig.<init>
> (ApplicationFilterConfig.java:108) [intworkspace-runner-2018.2.0-
> SNAPSHOT.jar:?]
>         at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4491)
> [intworkspace-runner-2018.2.0-SNAPSHOT.jar:?]
>         at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5131)
> [intworkspace-runner-2018.2.0-SNAPSHOT.jar:?]
>         at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
> [intworkspace-runner-2018.2.0-SNAPSHOT.jar:?]
>         at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:740)
> [intworkspace-runner-2018.2.0-SNAPSHOT.jar:?]
>         at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:716)
> [intworkspace-runner-2018.2.0-SNAPSHOT.jar:?]
>         at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:703)
> [intworkspace-runner-2018.2.0-SNAPSHOT.jar:?]
>         at org.apache.meecrowave.Meecrowave.deployWebapp(Meecrowave.java:350)
> [intworkspace-runner-2018.2.0-SNAPSHOT.jar:?]
>         at org.apache.meecrowave.Meecrowave.deployWebapp(Meecrowave.java:203)
> [intworkspace-runner-2018.2.0-SNAPSHOT.jar:?]
>         at myapp.CliExt.run(CliExt.java:237) [myapp-runner-2018.2.0-
> SNAPSHOT.jar:?]
>         at myapp.CliExt.main(CliExt.java:101) [myapp-runner-2018.2.0-
> SNAPSHOT.jar:?]
> [11:18:49.098][WARN ][           main][pr.DefaultAsyncSupportResolver]
> Failed to create AsyncSupport class: class org.atmosphere.container.JSR356AsyncSupport,
> error: java.lang.reflect.InvocationTargetException
> [11:18:49.098][ERROR][           main][pr.DefaultAsyncSupportResolver]
> Real error: Unable to configure jsr356 at that stage
> java.lang.IllegalStateException: Unable to configure jsr356 at that stage
>
> This error is due to CxfCdiAutoSetup  registering a ServletFilter that
> delegates to an instance of MeecrowaveCXFCdiServlet instead of actually
> registering the MeecrowaveCXFCdiServlet servlet with Tomcat.
>
> I haven't looked into it in much detail but is there a reason why the
> overrides provided my the filter could not be moved to
> the MeecrowaveCXFCdiServlet and have it directly registered with Tomcat
> where Atomosphere can access it?
>
> Thanks!
>
> Aaron
>
>
> On Friday, February 2, 2018 2:22 AM, Mark Struberg <struberg@yahoo.de>
> wrote:
>
>
> Hi folks!
>
> Just one minor point:
> if you add anything from cxf then you might likely add it to the
> Meecrowave libs directly.
> The reason is that CXF does not use the ThreadContextClassLoader when
> looking for it's own SPI implementations.
> So if you have cxf-core in meecrowave-lib and the cxf jax-ws jar just in
> your WAR, then CXF will not be able to find it.
>
> That's in most cases not a blocker.
> Btw, I also started with WAR packaging but nowadays almost always do
> web-jars.
>
> That means I package my UI module as jar and if I need anything then I use
> the Servlet-3.0 webresources feature.
> E.g. instead of
> src/main/webapp/WEB-INF/web.xml
> I now have
> src/main/resources/META-INF/resources/WEB-INF/web.xml
>
> Because since servlet-3.0 any content under META-INF/resources will be
> treated by the servlet container the same as if it's available under / in
> the WAR.
>
> LieGrue,
> strub
>
>
> > Am 01.02.2018 um 07:03 schrieb Romain Manni-Bucau <rmannibucau@gmail.com
> >:
> >
> > Hello Aaron,
> >
> > AFAIK it works yes and since we are tomcat it is just a matter of adding
> the right jars and dependencies - same than websockets setup which requires
> tomcat-websocket.
> >
> > Atmosphere has a tomcat integration too - another jar to add.
> >
> >
> > Le 1 févr. 2018 06:33, "Aaron Anderson" <nickmalthus@yahoo.com> a écrit
> :
> > Hi All,
> >
> > I was wondering if Meecrowave supports JAX-RS 2.1 SSE? After adding
> cxf-rt-rs-sse to my Maven runner POM I am able to add all the annotation to
> my endpoint and invoke it via a JavaScript EventSource but the injected
> SseEventSink and Sse values are null.
> >
> > The CXF example manually registers a CXF servlet so I wonder if that is
> the issue. Also the CXF project depends on Atmosphere (which I had to add
> to the scanning-package-exclude list) which I think only works with Jetty
> and not Tomcat.
> >
> > Any insight is appreciated. I do have Tomcat Web Sockets working but it
> would be nice to have SSE working in JAX-RS so I can easily have a
> reference in the endpoint to send interactive updates.
> >
> > Thanks,
> >
> > Aaron
> >
>
>
>

Mime
View raw message