You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by shortname <sh...@yandex.ru> on 2016/08/07 07:36:35 UTC

Tomee 7.0.1 JAX-RS AsyncReponse throws NullPointerException

I'm trying to deploy war-file with JAX-RS service (without web.xml, 
annotations only) and this service works fine on Glassfish and Wildfly 
without web.xml. Tomee 7.0.1 throws NullPointerException because 
ContinuationProvider not found in context (I'm using @Suspended 
AsyncResponse).

I found this article 
http://blog.clempinch.com/async-rest-cxf-and-the-continuations-api/ 
which suggest to add async-supported tag to web.xml.

Can I enable async support in META-INF/context.xml for example? Or this 
support should be enabled by default for JAX-RS?

Best regards, Ilia

Re: Tomee 7.0.1 JAX-RS AsyncReponse throws NullPointerException

Posted by shortname <sh...@yandex.ru>.
Seems this is keycloak-adapter bug: 
https://issues.jboss.org/browse/KEYCLOAK-3188

Thank for your help!


07.08.2016 15:08, Romain Manni-Bucau \u043f\u0438\u0448\u0435\u0442:
> Hmm,
>
> This code is in cxf right? Pretty sure it works == not where the issue is.
> Is keycloak asyncSupported? If not will likely fail.
>
> Best for such an issue is to share on github a sample project failling -
> either with a tomee unit test or tomee-maven-plugin. Is that an option?
>
> Le 7 ao�t 2016 12:53, "shortname" <sh...@yandex.ru> a �crit :
>
>> Hello Romain,
>>
>> You're right. Seems my issue is not related to tomee async feature. It
>> somehow related to keycloak adapter or both. I created small test project
>> with sync/async and keycloak adapter. Here is results:
>>
>> 1. no keycloak + sync = ok
>> 2. no keycloak + async = ok
>> 3. keycloak + sync = ok
>> 4. keycloak + async = error
>>
>> Stack trace and method:
>>
>> java.lang.NullPointerException
>> org.apache.cxf.jaxrs.impl.AsyncResponseImpl.initContinuation
>> (AsyncResponseImpl.java:305)
>> org.apache.cxf.jaxrs.impl.AsyncResponseImpl.<init>(AsyncResp
>> onseImpl.java:68)
>> org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRS
>> Utils.java:816)
>> org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXR
>> SUtils.java:789)
>> org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processR
>> equest(JAXRSInInterceptor.java:212)
>> org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMe
>> ssage(JAXRSInInterceptor.java:77)
>> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(Phase
>> InterceptorChain.java:308)
>> org.apache.cxf.transport.ChainInitiationObserver.onMessage(C
>> hainInitiationObserver.java:121)
>> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke
>> (AbstractHTTPDestination.java:254)
>> org.apache.openejb.server.cxf.rs.CxfRsHttpListener.doInvoke(
>> CxfRsHttpListener.java:251)
>> org.apache.tomee.webservices.CXFJAXRSFilter.doFilter(CXFJAXR
>> SFilter.java:94)
>> org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
>> org.apache.openejb.server.httpd.EEFilter.doFilter(EEFilter.java:65)
>>
>>      private void initContinuation() {
>>          ContinuationProvider provider = (ContinuationProvider)this.inM
>> essage.get(ContinuationProvider.class.getName());
>> *this.cont = provider.getContinuation();*
>>          this.initialSuspend = true;
>>      }
>>
>>
>> 07.08.2016 11:42, Romain Manni-Bucau \u043f\u0438\u0448\u0435\u0442:
>>
>>> Hello Ilia,
>>>
>>> This works out of the box. With not enough info I d say you put cxf in the
>>> webapp instead of letting tomee do the deployment.
>>>
>>> This service
>>> https://github.com/rmannibucau/rblog/blob/master/src/main/
>>> java/com/github/rmannibucau/rblog/jaxrs/PostResource.java
>>> for instance use asynv jaxrs features - Suspended - and the app has no
>>> web.xml
>>>
>>> Le 7 ao�t 2016 09:36, "shortname" <sh...@yandex.ru> a �crit :
>>>
>>> I'm trying to deploy war-file with JAX-RS service (without web.xml,
>>>> annotations only) and this service works fine on Glassfish and Wildfly
>>>> without web.xml. Tomee 7.0.1 throws NullPointerException because
>>>> ContinuationProvider not found in context (I'm using @Suspended
>>>> AsyncResponse).
>>>>
>>>> I found this article http://blog.clempinch.com/asyn
>>>> c-rest-cxf-and-the-continuations-api/ which suggest to add
>>>> async-supported tag to web.xml.
>>>>
>>>> Can I enable async support in META-INF/context.xml for example? Or this
>>>> support should be enabled by default for JAX-RS?
>>>>
>>>> Best regards, Ilia
>>>>
>>>>


Re: Tomee 7.0.1 JAX-RS AsyncReponse throws NullPointerException

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hmm,

This code is in cxf right? Pretty sure it works == not where the issue is.
Is keycloak asyncSupported? If not will likely fail.

Best for such an issue is to share on github a sample project failling -
either with a tomee unit test or tomee-maven-plugin. Is that an option?

Le 7 août 2016 12:53, "shortname" <sh...@yandex.ru> a écrit :

> Hello Romain,
>
> You're right. Seems my issue is not related to tomee async feature. It
> somehow related to keycloak adapter or both. I created small test project
> with sync/async and keycloak adapter. Here is results:
>
> 1. no keycloak + sync = ok
> 2. no keycloak + async = ok
> 3. keycloak + sync = ok
> 4. keycloak + async = error
>
> Stack trace and method:
>
> java.lang.NullPointerException
> org.apache.cxf.jaxrs.impl.AsyncResponseImpl.initContinuation
> (AsyncResponseImpl.java:305)
> org.apache.cxf.jaxrs.impl.AsyncResponseImpl.<init>(AsyncResp
> onseImpl.java:68)
> org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRS
> Utils.java:816)
> org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXR
> SUtils.java:789)
> org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processR
> equest(JAXRSInInterceptor.java:212)
> org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMe
> ssage(JAXRSInInterceptor.java:77)
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(Phase
> InterceptorChain.java:308)
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(C
> hainInitiationObserver.java:121)
> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke
> (AbstractHTTPDestination.java:254)
> org.apache.openejb.server.cxf.rs.CxfRsHttpListener.doInvoke(
> CxfRsHttpListener.java:251)
> org.apache.tomee.webservices.CXFJAXRSFilter.doFilter(CXFJAXR
> SFilter.java:94)
> org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
> org.apache.openejb.server.httpd.EEFilter.doFilter(EEFilter.java:65)
>
>     private void initContinuation() {
>         ContinuationProvider provider = (ContinuationProvider)this.inM
> essage.get(ContinuationProvider.class.getName());
> *this.cont = provider.getContinuation();*
>         this.initialSuspend = true;
>     }
>
>
> 07.08.2016 11:42, Romain Manni-Bucau пишет:
>
>> Hello Ilia,
>>
>> This works out of the box. With not enough info I d say you put cxf in the
>> webapp instead of letting tomee do the deployment.
>>
>> This service
>> https://github.com/rmannibucau/rblog/blob/master/src/main/
>> java/com/github/rmannibucau/rblog/jaxrs/PostResource.java
>> for instance use asynv jaxrs features - Suspended - and the app has no
>> web.xml
>>
>> Le 7 août 2016 09:36, "shortname" <sh...@yandex.ru> a écrit :
>>
>> I'm trying to deploy war-file with JAX-RS service (without web.xml,
>>> annotations only) and this service works fine on Glassfish and Wildfly
>>> without web.xml. Tomee 7.0.1 throws NullPointerException because
>>> ContinuationProvider not found in context (I'm using @Suspended
>>> AsyncResponse).
>>>
>>> I found this article http://blog.clempinch.com/asyn
>>> c-rest-cxf-and-the-continuations-api/ which suggest to add
>>> async-supported tag to web.xml.
>>>
>>> Can I enable async support in META-INF/context.xml for example? Or this
>>> support should be enabled by default for JAX-RS?
>>>
>>> Best regards, Ilia
>>>
>>>
>

Re: Tomee 7.0.1 JAX-RS AsyncReponse throws NullPointerException

Posted by shortname <sh...@yandex.ru>.
Hello Romain,

You're right. Seems my issue is not related to tomee async feature. It 
somehow related to keycloak adapter or both. I created small test 
project with sync/async and keycloak adapter. Here is results:

 1. no keycloak + sync = ok
 2. no keycloak + async = ok
 3. keycloak + sync = ok
 4. keycloak + async = error

Stack trace and method:

java.lang.NullPointerException
org.apache.cxf.jaxrs.impl.AsyncResponseImpl.initContinuation(AsyncResponseImpl.java:305)
org.apache.cxf.jaxrs.impl.AsyncResponseImpl.<init>(AsyncResponseImpl.java:68)
org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:816)
org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:789)
org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:212)
org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:77)
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:254)
org.apache.openejb.server.cxf.rs.CxfRsHttpListener.doInvoke(CxfRsHttpListener.java:251)
org.apache.tomee.webservices.CXFJAXRSFilter.doFilter(CXFJAXRSFilter.java:94)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.apache.openejb.server.httpd.EEFilter.doFilter(EEFilter.java:65)

     private void initContinuation() {
         ContinuationProvider provider = 
(ContinuationProvider)this.inMessage.get(ContinuationProvider.class.getName());
*this.cont = provider.getContinuation();*
         this.initialSuspend = true;
     }


07.08.2016 11:42, Romain Manni-Bucau \u043f\u0438\u0448\u0435\u0442:
> Hello Ilia,
>
> This works out of the box. With not enough info I d say you put cxf in the
> webapp instead of letting tomee do the deployment.
>
> This service
> https://github.com/rmannibucau/rblog/blob/master/src/main/java/com/github/rmannibucau/rblog/jaxrs/PostResource.java
> for instance use asynv jaxrs features - Suspended - and the app has no
> web.xml
>
> Le 7 ao�t 2016 09:36, "shortname" <sh...@yandex.ru> a �crit :
>
>> I'm trying to deploy war-file with JAX-RS service (without web.xml,
>> annotations only) and this service works fine on Glassfish and Wildfly
>> without web.xml. Tomee 7.0.1 throws NullPointerException because
>> ContinuationProvider not found in context (I'm using @Suspended
>> AsyncResponse).
>>
>> I found this article http://blog.clempinch.com/asyn
>> c-rest-cxf-and-the-continuations-api/ which suggest to add
>> async-supported tag to web.xml.
>>
>> Can I enable async support in META-INF/context.xml for example? Or this
>> support should be enabled by default for JAX-RS?
>>
>> Best regards, Ilia
>>


Re: Tomee 7.0.1 JAX-RS AsyncReponse throws NullPointerException

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hello Ilia,

This works out of the box. With not enough info I d say you put cxf in the
webapp instead of letting tomee do the deployment.

This service
https://github.com/rmannibucau/rblog/blob/master/src/main/java/com/github/rmannibucau/rblog/jaxrs/PostResource.java
for instance use asynv jaxrs features - Suspended - and the app has no
web.xml

Le 7 août 2016 09:36, "shortname" <sh...@yandex.ru> a écrit :

> I'm trying to deploy war-file with JAX-RS service (without web.xml,
> annotations only) and this service works fine on Glassfish and Wildfly
> without web.xml. Tomee 7.0.1 throws NullPointerException because
> ContinuationProvider not found in context (I'm using @Suspended
> AsyncResponse).
>
> I found this article http://blog.clempinch.com/asyn
> c-rest-cxf-and-the-continuations-api/ which suggest to add
> async-supported tag to web.xml.
>
> Can I enable async support in META-INF/context.xml for example? Or this
> support should be enabled by default for JAX-RS?
>
> Best regards, Ilia
>