openwebbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aaron Anderson <aaronander...@acm.org>
Subject Re: Support of JAX-RS 2.1 SSE using CXF
Date Sun, 04 Feb 2018 18:56:38 GMT
Hi Romain,
If it is OK for me to add the CXF SSE transport and Tomcat WebSocket maven dependencies to
the meecrowave-core POM in the test scope I can write a unit test to boot up Meecrowave with
SSE enable and execute a couple of SSE and normal JAX-RS requests.
Regards,
Aaron
 

    On Saturday, February 3, 2018 3:48 PM, Romain Manni-Bucau <rmannibucau@gmail.com>
wrote:
 

 

Le 3 févr. 2018 21:42, "Aaron Anderson" <aaronanderson@acm.org> a écrit :

Thanks Romain. After further investigation I needed to specify servlet init parameter for
Atmosphere so that it would not attempt to auto-detect the servlet mapping:
cxf.servlet.params.org. atmosphere.container. JSR356AsyncSupport. mappingPath=/*

I also needed to apply a trivial fix to Meecrowave so that the destinations registered on
the alternative transport were registered with Meecrowave:
https://github.com/apache/ meecrowave/pull/5

Oh, this is a good one! Do you see how to add a test for it? If not i can help next week.



After applying all of these changes I got JAX-RS SSE working!!!
Thanks for your assistance!
Aaron


 

    On Saturday, February 3, 2018 12:05 PM, Romain Manni-Bucau <rmannibucau@gmail.com>
wrote:
 

 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 |  Blog | Old Blog | Github | LinkedIn | Book
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. atmospherecxf.servlet.params. transportId=http://cxf.apache.
org/transports/http/ssecxf.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  SseTransportCustomizationExten sion 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. SseTransportCustomizationExten sion;
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. DelegatingConstructorAccessorI
mpl.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. AtmosphereSseServletDestinatio n.onServletConfigAvailable( AtmosphereSseServletDestinatio
n.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 stagejava.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