You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by nicolasduminil <ni...@simplex-software.fr> on 2017/06/14 16:50:35 UTC

CXF 3.0.3 - java.lang.IllegalStateException: Entity is not available on the return from a JAX-RS service

Hello,
A JAX-RS endpoint, working properly in order to perform its processing, is
raising the following exception on its return statement.

[14/06/17 18:40:00:743 CEST] 000000bd 0(id=120)]    I   Setting the server's
publish address to be /services/
[14/06/17 18:40:00:837 CEST] 000000bd ServletWrappe I
com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I:
[QuickSignControllerEar] [/qs]
[be.alphacredit.services.esign.rest.QuickSignControllerApp]: Initialization
successful.
[14/06/17 18:40:01:072 CEST] 000000bd EnvironmentPr I   Custom config found
by DeltaSpike. Name: 'META-INF/apache-deltaspike.properties', URL:
'wsjar:file:/C:/Program%20Files/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/cac40Node02Cell/QuickSignControllerEar.ear/QuickSignControllerWar-0.0.1-SNAPSHOT.war/WEB-INF/lib/QuickSignControllerEjb-0.0.1-SNAPSHOT.jar!/META-INF/apache-deltaspike.properties'
[14/06/17 18:40:01:072 CEST] 000000bd EnvironmentPr I   Custom config found
by DeltaSpike. Name: 'META-INF/apache-deltaspike.properties', URL:
'wsjar:file:/C:/Program%20Files/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/cac40Node02Cell/QuickSignControllerEar.ear/QuickSignControllerWar-0.0.1-SNAPSHOT.war/WEB-INF/lib/QuickSignControllerRest-0.0.1-SNAPSHOT.jar!/META-INF/apache-deltaspike.properties'
[14/06/17 18:40:25:134 CEST] 000000bd 0(id=120)]    W
org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging Interceptor for
{http://rest.esign.services.alphacredit.be/}QuickSignControllerServiceImpl
has thrown exception, unwinding now
                                 java.lang.IllegalStateException: Entity is
not available
	at
org.apache.cxf.jaxrs.impl.ResponseImpl.checkEntityIsClosed(ResponseImpl.java:614)
	at
org.apache.cxf.jaxrs.impl.ResponseImpl.getActualEntity(ResponseImpl.java:148)
	at
org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(JAXRSOutInterceptor.java:140)
	at
org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processResponse(JAXRSOutInterceptor.java:119)
	at
org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(JAXRSOutInterceptor.java:83)
	at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
	at
org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:83)
	at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
	at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
	at
org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:256)
	at
com.ibm.ws.jaxrs20.endpoint.AbstractJaxRsWebEndpoint.invoke(AbstractJaxRsWebEndpoint.java:140)
	at
com.ibm.websphere.jaxrs.server.IBMRestServlet.handleRequest(IBMRestServlet.java:179)
	at
com.ibm.websphere.jaxrs.server.IBMRestServlet.doGet(IBMRestServlet.java:145)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
	at
com.ibm.websphere.jaxrs.server.IBMRestServlet.service(IBMRestServlet.java:125)
	at
com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1235)
	at
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:779)
	at
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
	at
com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
	at
com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1124)
	at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:4144)
	at
com.ibm.ws.webcontainer.webapp.WebAppImpl.handleRequest(WebAppImpl.java:2208)
	at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
	at
com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1030)
	at
com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1817)
	at
com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:382)
	at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
	at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:532)
	at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:318)
	at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:289)
	at
com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
	at
com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
	at
com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
	at
com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
	at
com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
	at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
	at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
	at
com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
	at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1892)

I need to mention that the service is deployed with WebSphere AS 9.0 and is
using the JAX-RS 2.0 and CXF 3.0.3 which comes with WebSphere. 

Many thanks in advance for your help.
Nicolas



--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-3-0-3-java-lang-IllegalStateException-Entity-is-not-available-on-the-return-from-a-JAX-RS-service-tp5781201.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: CXF 3.0.3 - java.lang.IllegalStateException: Entity is not available on the return from a JAX-RS service

Posted by nicolasduminil <ni...@simplex-software.fr>.
Hi Sergey,

Yes, this is exactly that. My endpoint is a service and a client of another
service. So it calls an external service, it does what it supposed to with
the Response and simply forward the same Response to its client.

Many thanks,
Nicolas



--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-3-0-3-java-lang-IllegalStateException-Entity-is-not-available-on-the-return-from-a-JAX-RS-service-tp5781201p5781234.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: CXF 3.0.3 - java.lang.IllegalStateException: Entity is not available on the return from a JAX-RS service

Posted by nicolasduminil <ni...@simplex-software.fr>.
Hi Andy,

I'll try that, many thanks.
Nicolas



--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-3-0-3-java-lang-IllegalStateException-Entity-is-not-available-on-the-return-from-a-JAX-RS-service-tp5781201p5781233.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: CXF 3.0.3 - java.lang.IllegalStateException: Entity is not available on the return from a JAX-RS service

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Andy, Nicolas

I just wonder why the exception was raised in the outbound response chain.
Nicolas, do you have service doing a client call first, then reading the 
entity, then returning the same Response ?
As Andy indicated .bufferEntity() can help, but the service client will 
probably see HTTP headers returned from the internal call, may be better 
create a new Response instance

Sergey


On 15/06/17 11:47, Andy McCright wrote:
> Hi Nicolas,
> 
> According to the spec, you can only read an entity once.  If you want to
> read it twice (or more) from the same Response object you should call
> Response.bufferEntity() first.
> 
> Hope this helps,
> 
> Andy
> 
> On Thu, Jun 15, 2017 at 4:36 AM nicolasduminil <
> nicolas.duminil@simplex-software.fr> wrote:
> 
>> Hi Sergey,
>>
>> Many thanks for your reply to my post. No, I don't use any Response.close()
>> anywhere. But there is a:
>>
>>     Response resp = client.target(...)...;
>>     String s = response.readEntity(String.class);
>>     ...
>> Does readEntity() close the response ? Is there anyway to test the response
>> such that to see weather it is closed ?
>>
>> Many thanks in advance,
>> Nicolas DUMINIL
>>
>>
>>
>> --
>> View this message in context:
>> http://cxf.547215.n5.nabble.com/CXF-3-0-3-java-lang-IllegalStateException-Entity-is-not-available-on-the-return-from-a-JAX-RS-service-tp5781201p5781222.html
>> Sent from the cxf-user mailing list archive at Nabble.com.
>>
> 


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Re: CXF 3.0.3 - java.lang.IllegalStateException: Entity is not available on the return from a JAX-RS service

Posted by Andy McCright <j....@gmail.com>.
Hi Nicolas,

According to the spec, you can only read an entity once.  If you want to
read it twice (or more) from the same Response object you should call
Response.bufferEntity() first.

Hope this helps,

Andy

On Thu, Jun 15, 2017 at 4:36 AM nicolasduminil <
nicolas.duminil@simplex-software.fr> wrote:

> Hi Sergey,
>
> Many thanks for your reply to my post. No, I don't use any Response.close()
> anywhere. But there is a:
>
>    Response resp = client.target(...)...;
>    String s = response.readEntity(String.class);
>    ...
> Does readEntity() close the response ? Is there anyway to test the response
> such that to see weather it is closed ?
>
> Many thanks in advance,
> Nicolas DUMINIL
>
>
>
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/CXF-3-0-3-java-lang-IllegalStateException-Entity-is-not-available-on-the-return-from-a-JAX-RS-service-tp5781201p5781222.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>

Re: CXF 3.0.3 - java.lang.IllegalStateException: Entity is not available on the return from a JAX-RS service

Posted by nicolasduminil <ni...@simplex-software.fr>.
Hi Sergey,

Many thanks for your reply to my post. No, I don't use any Response.close()
anywhere. But there is a:

   Response resp = client.target(...)...;
   String s = response.readEntity(String.class);
   ...
Does readEntity() close the response ? Is there anyway to test the response
such that to see weather it is closed ?

Many thanks in advance,
Nicolas DUMINIL



--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-3-0-3-java-lang-IllegalStateException-Entity-is-not-available-on-the-return-from-a-JAX-RS-service-tp5781201p5781222.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: CXF 3.0.3 - java.lang.IllegalStateException: Entity is not available on the return from a JAX-RS service

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

It can happen is somewhere in the chain Response.close() has been 
called, can you please investigate further ?

Cheers, Sergey
On 14/06/17 17:50, nicolasduminil wrote:
> Hello,
> A JAX-RS endpoint, working properly in order to perform its processing, is
> raising the following exception on its return statement.
> 
> [14/06/17 18:40:00:743 CEST] 000000bd 0(id=120)]    I   Setting the server's
> publish address to be /services/
> [14/06/17 18:40:00:837 CEST] 000000bd ServletWrappe I
> com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I:
> [QuickSignControllerEar] [/qs]
> [be.alphacredit.services.esign.rest.QuickSignControllerApp]: Initialization
> successful.
> [14/06/17 18:40:01:072 CEST] 000000bd EnvironmentPr I   Custom config found
> by DeltaSpike. Name: 'META-INF/apache-deltaspike.properties', URL:
> 'wsjar:file:/C:/Program%20Files/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/cac40Node02Cell/QuickSignControllerEar.ear/QuickSignControllerWar-0.0.1-SNAPSHOT.war/WEB-INF/lib/QuickSignControllerEjb-0.0.1-SNAPSHOT.jar!/META-INF/apache-deltaspike.properties'
> [14/06/17 18:40:01:072 CEST] 000000bd EnvironmentPr I   Custom config found
> by DeltaSpike. Name: 'META-INF/apache-deltaspike.properties', URL:
> 'wsjar:file:/C:/Program%20Files/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/cac40Node02Cell/QuickSignControllerEar.ear/QuickSignControllerWar-0.0.1-SNAPSHOT.war/WEB-INF/lib/QuickSignControllerRest-0.0.1-SNAPSHOT.jar!/META-INF/apache-deltaspike.properties'
> [14/06/17 18:40:25:134 CEST] 000000bd 0(id=120)]    W
> org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging Interceptor for
> {http://rest.esign.services.alphacredit.be/}QuickSignControllerServiceImpl
> has thrown exception, unwinding now
>                                   java.lang.IllegalStateException: Entity is
> not available
> 	at
> org.apache.cxf.jaxrs.impl.ResponseImpl.checkEntityIsClosed(ResponseImpl.java:614)
> 	at
> org.apache.cxf.jaxrs.impl.ResponseImpl.getActualEntity(ResponseImpl.java:148)
> 	at
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(JAXRSOutInterceptor.java:140)
> 	at
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processResponse(JAXRSOutInterceptor.java:119)
> 	at
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(JAXRSOutInterceptor.java:83)
> 	at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
> 	at
> org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:83)
> 	at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
> 	at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
> 	at
> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:256)
> 	at
> com.ibm.ws.jaxrs20.endpoint.AbstractJaxRsWebEndpoint.invoke(AbstractJaxRsWebEndpoint.java:140)
> 	at
> com.ibm.websphere.jaxrs.server.IBMRestServlet.handleRequest(IBMRestServlet.java:179)
> 	at
> com.ibm.websphere.jaxrs.server.IBMRestServlet.doGet(IBMRestServlet.java:145)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
> 	at
> com.ibm.websphere.jaxrs.server.IBMRestServlet.service(IBMRestServlet.java:125)
> 	at
> com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1235)
> 	at
> com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:779)
> 	at
> com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
> 	at
> com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
> 	at
> com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1124)
> 	at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:4144)
> 	at
> com.ibm.ws.webcontainer.webapp.WebAppImpl.handleRequest(WebAppImpl.java:2208)
> 	at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
> 	at
> com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1030)
> 	at
> com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1817)
> 	at
> com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:382)
> 	at
> com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
> 	at
> com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:532)
> 	at
> com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:318)
> 	at
> com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:289)
> 	at
> com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
> 	at
> com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
> 	at
> com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
> 	at
> com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
> 	at
> com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
> 	at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
> 	at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
> 	at
> com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
> 	at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
> 	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1892)
> 
> I need to mention that the service is deployed with WebSphere AS 9.0 and is
> using the JAX-RS 2.0 and CXF 3.0.3 which comes with WebSphere.
> 
> Many thanks in advance for your help.
> Nicolas
> 
> 
> 
> --
> View this message in context: http://cxf.547215.n5.nabble.com/CXF-3-0-3-java-lang-IllegalStateException-Entity-is-not-available-on-the-return-from-a-JAX-RS-service-tp5781201.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>