Re: Reactive Services & CDI

2018-02-05 Thread Sergey Beryozkin

Hi John
On 04/02/18 19:19, John D. Ament wrote:

On Sun, Feb 4, 2018 at 2:01 PM Sergey Beryozkin 
wrote:


I thought I'd point to the utility of that module anyway (by the way, in
the updated code below the AsyncResponse is also not needed)



Yep, I know that.  Was seeing the issue either way, and as far as I know
the AsyncResponse approach is the more spec appropriate way.

It is only needed in this case to init a CXF-specific subscriber hence a 
portability issue while without it one would have a portable code 
consistent with the way CompletableFuture is supported in 2.1 - where 
you just return it...



In the servlet container you may need to enable the async (via the
standard servlet param).



haha, that was it.  Thanks!

Np, sometimes it is probably not needed, I thought I saw some examples 
before where it just works, may be some servlet containers are stricter...


Sergey




Cheers, Sergey

On 04/02/18 17:59, John D. Ament wrote:

Sergey,

I think you're mixing emails (the email on dev@ is unrelated).

On Sun, Feb 4, 2018 at 12:53 PM Sergey Beryozkin 
wrote:


That dependency you referred to should let you do:

@Path("/")
public class RestController {
 @GET
 @Produces(MediaType.APPLICATION_JSON)
 public Flux doGet(@Suspended AsyncResponse asyncResponse) {
 ClientBuilder.newClient()
 .register(MyAppFeature.class)
 .target("https://postman-echo.com/get;)
 .queryParam("arg1", "arg1")
 .queryParam("arg2", "arg2")
 .request(MediaType.APPLICATION_JSON_TYPE)
 .rx(ReactorInvoker.class)
 .get(JsonObject.class);
}

Not sure why Continuation is not init-ed though, something to do with
the servlet setup



Anything you can suggest to debug through?

I'm following the async example I wrote, but within a servlet container
(I'm assuming the systests are running a jetty instance).




Sergey



On 04/02/18 16:16, John D. Ament wrote:

BTW, sample project can be found @
https://github.com/johnament/cxf-demo-reactive-cdi


On Sun, Feb 4, 2018 at 11:13 AM John D. Ament 

wrote:



I built a simple webapp (WAR file, deploying to Tomcat) that depends

on

the CXF 3.2.2 libraries + Weld 3.0.2.  I don't believe CDI has

anything

to

do with my problem though.

I registered a feature/server customizer that can deal with the

invoker

logic required, and provided a rest controller that simply invokes the
postman echo service

Feature/Extension:

@ApplicationScoped
public class MyAppFeature implements Feature,
JAXRSServerFactoryCustomizationExtension {
   public boolean configure(FeatureContext featureContext) {
   featureContext.register(JsrProvider.class);
   featureContext.register(ReactorInvokerProvider.class);
   return true;
   }

   @Override
   public void customize(JAXRSServerFactoryBean

jaxrsServerFactoryBean) {

   ReactorInvoker invoker = new ReactorInvoker();
   invoker.setUseStreamingSubscriberIfPossible(false);
   jaxrsServerFactoryBean.setInvoker(invoker);
   StreamingResponseProvider streamProvider = new
StreamingResponseProvider<>();





streamProvider.setProduceMediaTypes(Collections.singletonList("application/json"));

   jaxrsServerFactoryBean.setProvider(streamProvider);
   jaxrsServerFactoryBean.getOutInterceptors().add(new
LoggingOutInterceptor());
   }
}

RestController:

@RequestScoped
@Path("/")
public class RestController {
   @GET
   @Produces(MediaType.APPLICATION_JSON)
   public void doGet(@Suspended AsyncResponse asyncResponse) {
   ClientBuilder.newClient()
   .register(MyAppFeature.class)
   .target("https://postman-echo.com/get;)
   .queryParam("arg1", "arg1")
   .queryParam("arg2", "arg2")
   .request(MediaType.APPLICATION_JSON_TYPE)
   .rx(ReactorInvoker.class)
   .get(JsonObject.class)
   .subscribe(new
JsonStreamingAsyncSubscriber<>(asyncResponse));
   }
}

When I attempt to invoke this endpoint, I see a NPE in the logs

04-Feb-2018 11:07:20.245 WARNING [http-nio-8080-exec-69]
org.apache.cxf.phase.PhaseInterceptorChain.doDefaultLogging

Interceptor

for

{http://rest.mycompany.com/}RestController has thrown exception,
unwinding now
java.lang.NullPointerException
at




org.apache.cxf.jaxrs.impl.AsyncResponseImpl.initContinuation(AsyncResponseImpl.java:306)

at




org.apache.cxf.jaxrs.impl.AsyncResponseImpl.(AsyncResponseImpl.java:68)

at




org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:826)

at




org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:795)

at





Re: Reactive Services & CDI

2018-02-04 Thread John D. Ament
On Sun, Feb 4, 2018 at 2:01 PM Sergey Beryozkin 
wrote:

> I thought I'd point to the utility of that module anyway (by the way, in
> the updated code below the AsyncResponse is also not needed)
>
>
Yep, I know that.  Was seeing the issue either way, and as far as I know
the AsyncResponse approach is the more spec appropriate way.


> In the servlet container you may need to enable the async (via the
> standard servlet param).
>

haha, that was it.  Thanks!


>
> Cheers, Sergey
>
> On 04/02/18 17:59, John D. Ament wrote:
> > Sergey,
> >
> > I think you're mixing emails (the email on dev@ is unrelated).
> >
> > On Sun, Feb 4, 2018 at 12:53 PM Sergey Beryozkin 
> > wrote:
> >
> >> That dependency you referred to should let you do:
> >>
> >>@Path("/")
> >>public class RestController {
> >> @GET
> >> @Produces(MediaType.APPLICATION_JSON)
> >> public Flux doGet(@Suspended AsyncResponse asyncResponse) {
> >> ClientBuilder.newClient()
> >> .register(MyAppFeature.class)
> >> .target("https://postman-echo.com/get;)
> >> .queryParam("arg1", "arg1")
> >> .queryParam("arg2", "arg2")
> >> .request(MediaType.APPLICATION_JSON_TYPE)
> >> .rx(ReactorInvoker.class)
> >> .get(JsonObject.class);
> >>}
> >>
> >> Not sure why Continuation is not init-ed though, something to do with
> >> the servlet setup
> >>
> >
> > Anything you can suggest to debug through?
> >
> > I'm following the async example I wrote, but within a servlet container
> > (I'm assuming the systests are running a jetty instance).
> >
> >
> >>
> >> Sergey
> >>
> >>
> >>
> >> On 04/02/18 16:16, John D. Ament wrote:
> >>> BTW, sample project can be found @
> >>> https://github.com/johnament/cxf-demo-reactive-cdi
> >>>
> >>>
> >>> On Sun, Feb 4, 2018 at 11:13 AM John D. Ament 
> >> wrote:
> >>>
>  I built a simple webapp (WAR file, deploying to Tomcat) that depends
> on
>  the CXF 3.2.2 libraries + Weld 3.0.2.  I don't believe CDI has
> anything
> >> to
>  do with my problem though.
> 
>  I registered a feature/server customizer that can deal with the
> invoker
>  logic required, and provided a rest controller that simply invokes the
>  postman echo service
> 
>  Feature/Extension:
> 
>  @ApplicationScoped
>  public class MyAppFeature implements Feature,
>  JAXRSServerFactoryCustomizationExtension {
>    public boolean configure(FeatureContext featureContext) {
>    featureContext.register(JsrProvider.class);
>    featureContext.register(ReactorInvokerProvider.class);
>    return true;
>    }
> 
>    @Override
>    public void customize(JAXRSServerFactoryBean
> >> jaxrsServerFactoryBean) {
>    ReactorInvoker invoker = new ReactorInvoker();
>    invoker.setUseStreamingSubscriberIfPossible(false);
>    jaxrsServerFactoryBean.setInvoker(invoker);
>    StreamingResponseProvider streamProvider = new
>  StreamingResponseProvider<>();
> 
> 
> >>
> streamProvider.setProduceMediaTypes(Collections.singletonList("application/json"));
>    jaxrsServerFactoryBean.setProvider(streamProvider);
>    jaxrsServerFactoryBean.getOutInterceptors().add(new
>  LoggingOutInterceptor());
>    }
>  }
> 
>  RestController:
> 
>  @RequestScoped
>  @Path("/")
>  public class RestController {
>    @GET
>    @Produces(MediaType.APPLICATION_JSON)
>    public void doGet(@Suspended AsyncResponse asyncResponse) {
>    ClientBuilder.newClient()
>    .register(MyAppFeature.class)
>    .target("https://postman-echo.com/get;)
>    .queryParam("arg1", "arg1")
>    .queryParam("arg2", "arg2")
>    .request(MediaType.APPLICATION_JSON_TYPE)
>    .rx(ReactorInvoker.class)
>    .get(JsonObject.class)
>    .subscribe(new
>  JsonStreamingAsyncSubscriber<>(asyncResponse));
>    }
>  }
> 
>  When I attempt to invoke this endpoint, I see a NPE in the logs
> 
>  04-Feb-2018 11:07:20.245 WARNING [http-nio-8080-exec-69]
>  org.apache.cxf.phase.PhaseInterceptorChain.doDefaultLogging
> Interceptor
> >> for
>  {http://rest.mycompany.com/}RestController has thrown exception,
>  unwinding now
> java.lang.NullPointerException
>  at
> 
> >>
> org.apache.cxf.jaxrs.impl.AsyncResponseImpl.initContinuation(AsyncResponseImpl.java:306)
>  at
> 
> >>
> org.apache.cxf.jaxrs.impl.AsyncResponseImpl.(AsyncResponseImpl.java:68)
>  at
> 
> >>
> 

Re: Reactive Services & CDI

2018-02-04 Thread Sergey Beryozkin
I thought I'd point to the utility of that module anyway (by the way, in 
the updated code below the AsyncResponse is also not needed)


In the servlet container you may need to enable the async (via the 
standard servlet param).


Cheers, Sergey

On 04/02/18 17:59, John D. Ament wrote:

Sergey,

I think you're mixing emails (the email on dev@ is unrelated).

On Sun, Feb 4, 2018 at 12:53 PM Sergey Beryozkin 
wrote:


That dependency you referred to should let you do:

   @Path("/")
   public class RestController {
@GET
@Produces(MediaType.APPLICATION_JSON)
public Flux doGet(@Suspended AsyncResponse asyncResponse) {
ClientBuilder.newClient()
.register(MyAppFeature.class)
.target("https://postman-echo.com/get;)
.queryParam("arg1", "arg1")
.queryParam("arg2", "arg2")
.request(MediaType.APPLICATION_JSON_TYPE)
.rx(ReactorInvoker.class)
.get(JsonObject.class);
   }

Not sure why Continuation is not init-ed though, something to do with
the servlet setup



Anything you can suggest to debug through?

I'm following the async example I wrote, but within a servlet container
(I'm assuming the systests are running a jetty instance).




Sergey



On 04/02/18 16:16, John D. Ament wrote:

BTW, sample project can be found @
https://github.com/johnament/cxf-demo-reactive-cdi


On Sun, Feb 4, 2018 at 11:13 AM John D. Ament 

wrote:



I built a simple webapp (WAR file, deploying to Tomcat) that depends on
the CXF 3.2.2 libraries + Weld 3.0.2.  I don't believe CDI has anything

to

do with my problem though.

I registered a feature/server customizer that can deal with the invoker
logic required, and provided a rest controller that simply invokes the
postman echo service

Feature/Extension:

@ApplicationScoped
public class MyAppFeature implements Feature,
JAXRSServerFactoryCustomizationExtension {
  public boolean configure(FeatureContext featureContext) {
  featureContext.register(JsrProvider.class);
  featureContext.register(ReactorInvokerProvider.class);
  return true;
  }

  @Override
  public void customize(JAXRSServerFactoryBean

jaxrsServerFactoryBean) {

  ReactorInvoker invoker = new ReactorInvoker();
  invoker.setUseStreamingSubscriberIfPossible(false);
  jaxrsServerFactoryBean.setInvoker(invoker);
  StreamingResponseProvider streamProvider = new
StreamingResponseProvider<>();



streamProvider.setProduceMediaTypes(Collections.singletonList("application/json"));

  jaxrsServerFactoryBean.setProvider(streamProvider);
  jaxrsServerFactoryBean.getOutInterceptors().add(new
LoggingOutInterceptor());
  }
}

RestController:

@RequestScoped
@Path("/")
public class RestController {
  @GET
  @Produces(MediaType.APPLICATION_JSON)
  public void doGet(@Suspended AsyncResponse asyncResponse) {
  ClientBuilder.newClient()
  .register(MyAppFeature.class)
  .target("https://postman-echo.com/get;)
  .queryParam("arg1", "arg1")
  .queryParam("arg2", "arg2")
  .request(MediaType.APPLICATION_JSON_TYPE)
  .rx(ReactorInvoker.class)
  .get(JsonObject.class)
  .subscribe(new
JsonStreamingAsyncSubscriber<>(asyncResponse));
  }
}

When I attempt to invoke this endpoint, I see a NPE in the logs

04-Feb-2018 11:07:20.245 WARNING [http-nio-8080-exec-69]
org.apache.cxf.phase.PhaseInterceptorChain.doDefaultLogging Interceptor

for

{http://rest.mycompany.com/}RestController has thrown exception,
unwinding now
   java.lang.NullPointerException
at


org.apache.cxf.jaxrs.impl.AsyncResponseImpl.initContinuation(AsyncResponseImpl.java:306)

at


org.apache.cxf.jaxrs.impl.AsyncResponseImpl.(AsyncResponseImpl.java:68)

at


org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:826)

at


org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:795)

at


org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:214)

at


org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:78)

at


org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)

at


org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)

at


org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267)

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



Re: Reactive Services & CDI

2018-02-04 Thread John D. Ament
Sergey,

I think you're mixing emails (the email on dev@ is unrelated).

On Sun, Feb 4, 2018 at 12:53 PM Sergey Beryozkin 
wrote:

> That dependency you referred to should let you do:
>
>   @Path("/")
>   public class RestController {
>@GET
>@Produces(MediaType.APPLICATION_JSON)
>public Flux doGet(@Suspended AsyncResponse asyncResponse) {
>ClientBuilder.newClient()
>.register(MyAppFeature.class)
>.target("https://postman-echo.com/get;)
>.queryParam("arg1", "arg1")
>.queryParam("arg2", "arg2")
>.request(MediaType.APPLICATION_JSON_TYPE)
>.rx(ReactorInvoker.class)
>.get(JsonObject.class);
>   }
>
> Not sure why Continuation is not init-ed though, something to do with
> the servlet setup
>

Anything you can suggest to debug through?

I'm following the async example I wrote, but within a servlet container
(I'm assuming the systests are running a jetty instance).


>
> Sergey
>
>
>
> On 04/02/18 16:16, John D. Ament wrote:
> > BTW, sample project can be found @
> > https://github.com/johnament/cxf-demo-reactive-cdi
> >
> >
> > On Sun, Feb 4, 2018 at 11:13 AM John D. Ament 
> wrote:
> >
> >> I built a simple webapp (WAR file, deploying to Tomcat) that depends on
> >> the CXF 3.2.2 libraries + Weld 3.0.2.  I don't believe CDI has anything
> to
> >> do with my problem though.
> >>
> >> I registered a feature/server customizer that can deal with the invoker
> >> logic required, and provided a rest controller that simply invokes the
> >> postman echo service
> >>
> >> Feature/Extension:
> >>
> >> @ApplicationScoped
> >> public class MyAppFeature implements Feature,
> >> JAXRSServerFactoryCustomizationExtension {
> >>  public boolean configure(FeatureContext featureContext) {
> >>  featureContext.register(JsrProvider.class);
> >>  featureContext.register(ReactorInvokerProvider.class);
> >>  return true;
> >>  }
> >>
> >>  @Override
> >>  public void customize(JAXRSServerFactoryBean
> jaxrsServerFactoryBean) {
> >>  ReactorInvoker invoker = new ReactorInvoker();
> >>  invoker.setUseStreamingSubscriberIfPossible(false);
> >>  jaxrsServerFactoryBean.setInvoker(invoker);
> >>  StreamingResponseProvider streamProvider = new
> >> StreamingResponseProvider<>();
> >>
> >>
> streamProvider.setProduceMediaTypes(Collections.singletonList("application/json"));
> >>  jaxrsServerFactoryBean.setProvider(streamProvider);
> >>  jaxrsServerFactoryBean.getOutInterceptors().add(new
> >> LoggingOutInterceptor());
> >>  }
> >> }
> >>
> >> RestController:
> >>
> >> @RequestScoped
> >> @Path("/")
> >> public class RestController {
> >>  @GET
> >>  @Produces(MediaType.APPLICATION_JSON)
> >>  public void doGet(@Suspended AsyncResponse asyncResponse) {
> >>  ClientBuilder.newClient()
> >>  .register(MyAppFeature.class)
> >>  .target("https://postman-echo.com/get;)
> >>  .queryParam("arg1", "arg1")
> >>  .queryParam("arg2", "arg2")
> >>  .request(MediaType.APPLICATION_JSON_TYPE)
> >>  .rx(ReactorInvoker.class)
> >>  .get(JsonObject.class)
> >>  .subscribe(new
> >> JsonStreamingAsyncSubscriber<>(asyncResponse));
> >>  }
> >> }
> >>
> >> When I attempt to invoke this endpoint, I see a NPE in the logs
> >>
> >> 04-Feb-2018 11:07:20.245 WARNING [http-nio-8080-exec-69]
> >> org.apache.cxf.phase.PhaseInterceptorChain.doDefaultLogging Interceptor
> for
> >> {http://rest.mycompany.com/}RestController has thrown exception,
> >> unwinding now
> >>   java.lang.NullPointerException
> >> at
> >>
> org.apache.cxf.jaxrs.impl.AsyncResponseImpl.initContinuation(AsyncResponseImpl.java:306)
> >> at
> >>
> org.apache.cxf.jaxrs.impl.AsyncResponseImpl.(AsyncResponseImpl.java:68)
> >> at
> >>
> org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:826)
> >> at
> >>
> org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:795)
> >> at
> >>
> org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:214)
> >> at
> >>
> org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:78)
> >> at
> >>
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
> >> at
> >>
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
> >> at
> >>
> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267)
> >> at
> >>
> org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234)
> >> at
> >>
> org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208)
> >> at
> >>

Re: Reactive Services & CDI

2018-02-04 Thread Sergey Beryozkin

That dependency you referred to should let you do:

 @Path("/")
 public class RestController {
  @GET
  @Produces(MediaType.APPLICATION_JSON)
  public Flux doGet(@Suspended AsyncResponse asyncResponse) {
  ClientBuilder.newClient()
  .register(MyAppFeature.class)
  .target("https://postman-echo.com/get;)
  .queryParam("arg1", "arg1")
  .queryParam("arg2", "arg2")
  .request(MediaType.APPLICATION_JSON_TYPE)
  .rx(ReactorInvoker.class)
  .get(JsonObject.class);
 }

Not sure why Continuation is not init-ed though, something to do with 
the servlet setup


Sergey



On 04/02/18 16:16, John D. Ament wrote:

BTW, sample project can be found @
https://github.com/johnament/cxf-demo-reactive-cdi


On Sun, Feb 4, 2018 at 11:13 AM John D. Ament  wrote:


I built a simple webapp (WAR file, deploying to Tomcat) that depends on
the CXF 3.2.2 libraries + Weld 3.0.2.  I don't believe CDI has anything to
do with my problem though.

I registered a feature/server customizer that can deal with the invoker
logic required, and provided a rest controller that simply invokes the
postman echo service

Feature/Extension:

@ApplicationScoped
public class MyAppFeature implements Feature,
JAXRSServerFactoryCustomizationExtension {
 public boolean configure(FeatureContext featureContext) {
 featureContext.register(JsrProvider.class);
 featureContext.register(ReactorInvokerProvider.class);
 return true;
 }

 @Override
 public void customize(JAXRSServerFactoryBean jaxrsServerFactoryBean) {
 ReactorInvoker invoker = new ReactorInvoker();
 invoker.setUseStreamingSubscriberIfPossible(false);
 jaxrsServerFactoryBean.setInvoker(invoker);
 StreamingResponseProvider streamProvider = new
StreamingResponseProvider<>();

streamProvider.setProduceMediaTypes(Collections.singletonList("application/json"));
 jaxrsServerFactoryBean.setProvider(streamProvider);
 jaxrsServerFactoryBean.getOutInterceptors().add(new
LoggingOutInterceptor());
 }
}

RestController:

@RequestScoped
@Path("/")
public class RestController {
 @GET
 @Produces(MediaType.APPLICATION_JSON)
 public void doGet(@Suspended AsyncResponse asyncResponse) {
 ClientBuilder.newClient()
 .register(MyAppFeature.class)
 .target("https://postman-echo.com/get;)
 .queryParam("arg1", "arg1")
 .queryParam("arg2", "arg2")
 .request(MediaType.APPLICATION_JSON_TYPE)
 .rx(ReactorInvoker.class)
 .get(JsonObject.class)
 .subscribe(new
JsonStreamingAsyncSubscriber<>(asyncResponse));
 }
}

When I attempt to invoke this endpoint, I see a NPE in the logs

04-Feb-2018 11:07:20.245 WARNING [http-nio-8080-exec-69]
org.apache.cxf.phase.PhaseInterceptorChain.doDefaultLogging Interceptor for
{http://rest.mycompany.com/}RestController has thrown exception,
unwinding now
  java.lang.NullPointerException
at
org.apache.cxf.jaxrs.impl.AsyncResponseImpl.initContinuation(AsyncResponseImpl.java:306)
at
org.apache.cxf.jaxrs.impl.AsyncResponseImpl.(AsyncResponseImpl.java:68)
at
org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:826)
at
org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:795)
at
org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:214)
at
org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:78)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at
org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267)
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:191)
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:301)
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:225)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:276)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at

Re: Reactive Services & CDI

2018-02-04 Thread Sergey Beryozkin

Why should be optional ?

Sergey
On 04/02/18 16:13, John D. Ament wrote:

I built a simple webapp (WAR file, deploying to Tomcat) that depends on the
CXF 3.2.2 libraries + Weld 3.0.2.  I don't believe CDI has anything to do
with my problem though.

I registered a feature/server customizer that can deal with the invoker
logic required, and provided a rest controller that simply invokes the
postman echo service

Feature/Extension:

@ApplicationScoped
public class MyAppFeature implements Feature,
JAXRSServerFactoryCustomizationExtension {
 public boolean configure(FeatureContext featureContext) {
 featureContext.register(JsrProvider.class);
 featureContext.register(ReactorInvokerProvider.class);
 return true;
 }

 @Override
 public void customize(JAXRSServerFactoryBean jaxrsServerFactoryBean) {
 ReactorInvoker invoker = new ReactorInvoker();
 invoker.setUseStreamingSubscriberIfPossible(false);
 jaxrsServerFactoryBean.setInvoker(invoker);
 StreamingResponseProvider streamProvider = new
StreamingResponseProvider<>();

streamProvider.setProduceMediaTypes(Collections.singletonList("application/json"));
 jaxrsServerFactoryBean.setProvider(streamProvider);
 jaxrsServerFactoryBean.getOutInterceptors().add(new
LoggingOutInterceptor());
 }
}

RestController:

@RequestScoped
@Path("/")
public class RestController {
 @GET
 @Produces(MediaType.APPLICATION_JSON)
 public void doGet(@Suspended AsyncResponse asyncResponse) {
 ClientBuilder.newClient()
 .register(MyAppFeature.class)
 .target("https://postman-echo.com/get;)
 .queryParam("arg1", "arg1")
 .queryParam("arg2", "arg2")
 .request(MediaType.APPLICATION_JSON_TYPE)
 .rx(ReactorInvoker.class)
 .get(JsonObject.class)
 .subscribe(new
JsonStreamingAsyncSubscriber<>(asyncResponse));
 }
}

When I attempt to invoke this endpoint, I see a NPE in the logs

04-Feb-2018 11:07:20.245 WARNING [http-nio-8080-exec-69]
org.apache.cxf.phase.PhaseInterceptorChain.doDefaultLogging Interceptor for
{http://rest.mycompany.com/}RestController has thrown exception, unwinding
now
  java.lang.NullPointerException
at
org.apache.cxf.jaxrs.impl.AsyncResponseImpl.initContinuation(AsyncResponseImpl.java:306)
at
org.apache.cxf.jaxrs.impl.AsyncResponseImpl.(AsyncResponseImpl.java:68)
at
org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:826)
at
org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:795)
at
org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:214)
at
org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:78)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at
org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267)
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:191)
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:301)
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:225)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:276)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at

Re: Reactive Services & CDI

2018-02-04 Thread John D. Ament
BTW, sample project can be found @
https://github.com/johnament/cxf-demo-reactive-cdi


On Sun, Feb 4, 2018 at 11:13 AM John D. Ament  wrote:

> I built a simple webapp (WAR file, deploying to Tomcat) that depends on
> the CXF 3.2.2 libraries + Weld 3.0.2.  I don't believe CDI has anything to
> do with my problem though.
>
> I registered a feature/server customizer that can deal with the invoker
> logic required, and provided a rest controller that simply invokes the
> postman echo service
>
> Feature/Extension:
>
> @ApplicationScoped
> public class MyAppFeature implements Feature,
> JAXRSServerFactoryCustomizationExtension {
> public boolean configure(FeatureContext featureContext) {
> featureContext.register(JsrProvider.class);
> featureContext.register(ReactorInvokerProvider.class);
> return true;
> }
>
> @Override
> public void customize(JAXRSServerFactoryBean jaxrsServerFactoryBean) {
> ReactorInvoker invoker = new ReactorInvoker();
> invoker.setUseStreamingSubscriberIfPossible(false);
> jaxrsServerFactoryBean.setInvoker(invoker);
> StreamingResponseProvider streamProvider = new
> StreamingResponseProvider<>();
>
> streamProvider.setProduceMediaTypes(Collections.singletonList("application/json"));
> jaxrsServerFactoryBean.setProvider(streamProvider);
> jaxrsServerFactoryBean.getOutInterceptors().add(new
> LoggingOutInterceptor());
> }
> }
>
> RestController:
>
> @RequestScoped
> @Path("/")
> public class RestController {
> @GET
> @Produces(MediaType.APPLICATION_JSON)
> public void doGet(@Suspended AsyncResponse asyncResponse) {
> ClientBuilder.newClient()
> .register(MyAppFeature.class)
> .target("https://postman-echo.com/get;)
> .queryParam("arg1", "arg1")
> .queryParam("arg2", "arg2")
> .request(MediaType.APPLICATION_JSON_TYPE)
> .rx(ReactorInvoker.class)
> .get(JsonObject.class)
> .subscribe(new
> JsonStreamingAsyncSubscriber<>(asyncResponse));
> }
> }
>
> When I attempt to invoke this endpoint, I see a NPE in the logs
>
> 04-Feb-2018 11:07:20.245 WARNING [http-nio-8080-exec-69]
> org.apache.cxf.phase.PhaseInterceptorChain.doDefaultLogging Interceptor for
> {http://rest.mycompany.com/}RestController has thrown exception,
> unwinding now
>  java.lang.NullPointerException
> at
> org.apache.cxf.jaxrs.impl.AsyncResponseImpl.initContinuation(AsyncResponseImpl.java:306)
> at
> org.apache.cxf.jaxrs.impl.AsyncResponseImpl.(AsyncResponseImpl.java:68)
> at
> org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:826)
> at
> org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:795)
> at
> org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:214)
> at
> org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:78)
> at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
> at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
> at
> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267)
> 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:191)
> at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:301)
> at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:225)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
> at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:276)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
> at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
> at
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
> at
> 

Reactive Services & CDI

2018-02-04 Thread John D. Ament
I built a simple webapp (WAR file, deploying to Tomcat) that depends on the
CXF 3.2.2 libraries + Weld 3.0.2.  I don't believe CDI has anything to do
with my problem though.

I registered a feature/server customizer that can deal with the invoker
logic required, and provided a rest controller that simply invokes the
postman echo service

Feature/Extension:

@ApplicationScoped
public class MyAppFeature implements Feature,
JAXRSServerFactoryCustomizationExtension {
public boolean configure(FeatureContext featureContext) {
featureContext.register(JsrProvider.class);
featureContext.register(ReactorInvokerProvider.class);
return true;
}

@Override
public void customize(JAXRSServerFactoryBean jaxrsServerFactoryBean) {
ReactorInvoker invoker = new ReactorInvoker();
invoker.setUseStreamingSubscriberIfPossible(false);
jaxrsServerFactoryBean.setInvoker(invoker);
StreamingResponseProvider streamProvider = new
StreamingResponseProvider<>();

streamProvider.setProduceMediaTypes(Collections.singletonList("application/json"));
jaxrsServerFactoryBean.setProvider(streamProvider);
jaxrsServerFactoryBean.getOutInterceptors().add(new
LoggingOutInterceptor());
}
}

RestController:

@RequestScoped
@Path("/")
public class RestController {
@GET
@Produces(MediaType.APPLICATION_JSON)
public void doGet(@Suspended AsyncResponse asyncResponse) {
ClientBuilder.newClient()
.register(MyAppFeature.class)
.target("https://postman-echo.com/get;)
.queryParam("arg1", "arg1")
.queryParam("arg2", "arg2")
.request(MediaType.APPLICATION_JSON_TYPE)
.rx(ReactorInvoker.class)
.get(JsonObject.class)
.subscribe(new
JsonStreamingAsyncSubscriber<>(asyncResponse));
}
}

When I attempt to invoke this endpoint, I see a NPE in the logs

04-Feb-2018 11:07:20.245 WARNING [http-nio-8080-exec-69]
org.apache.cxf.phase.PhaseInterceptorChain.doDefaultLogging Interceptor for
{http://rest.mycompany.com/}RestController has thrown exception, unwinding
now
 java.lang.NullPointerException
at
org.apache.cxf.jaxrs.impl.AsyncResponseImpl.initContinuation(AsyncResponseImpl.java:306)
at
org.apache.cxf.jaxrs.impl.AsyncResponseImpl.(AsyncResponseImpl.java:68)
at
org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:826)
at
org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:795)
at
org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:214)
at
org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:78)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at
org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267)
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:191)
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:301)
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:225)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:276)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
at