java.lang.IllegalStateException: Message received on a Client that has been closed or destroyed.

Apache's JIRA Issue Tracker | Dhawalpatel | 10 months ago
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 1

    Hi Daniel, Test Scenario: Install CXF as Resource Adapter in J2EE Container and use below code to call a JAX-WS API. /* Lookup Resource Adapter of JCA and get COnnection*/ CXFConnectionFactory connectionFactory = getCXFConnectionFactory(portClass); CXFConnectionSpec connectionSpec = createCXFConnectionSpec(portClass, serviceName, portName, webServiceDefinition); /* Get the Port from JCA Connection pool*/ connection = connectionFactory.getConnection(connectionSpec); port = connection.getService(portClass); /* Close the JCA Connection*/ if(connection != null) connection.close(); /*WebService call*/ port.getAccount(); Description: When a JCA Connection pool eviction happens due to Max Connections reached state, the existing on-going outgoing JAX-WS Calls errors out with below exception: Message received on a Client that has been closed or destroyed. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance( at sun.reflect.DelegatingConstructorAccessorImpl.newInstance( at java.lang.reflect.Constructor.newInstance( at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException( at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close( at at at at org.apache.cxf.transport.AbstractConduit.close( at org.apache.cxf.transport.http.HTTPConduit.close( at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage( at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept( at org.apache.cxf.endpoint.ClientImpl.doInvoke( at org.apache.cxf.endpoint.ClientImpl.invoke( at org.apache.cxf.endpoint.ClientImpl.invoke( at org.apache.cxf.endpoint.ClientImpl.invoke( at org.apache.cxf.frontend.ClientProxy.invokeSync( at org.apache.cxf.jaxws.JaxWsClientProxy.invoke( at com.sun.proxy.$Proxy106.inquireWirelinePaymentPlan(Unknown Source) at sun.reflect.GeneratedMethodAccessor360.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke( at java.lang.reflect.Method.invoke( at AppAdapter.executeWebService( Caused by: java.lang.IllegalStateException: Message received on a Client that has been closed or destroyed. at org.apache.cxf.endpoint.ClientImpl.onMessage( at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal( at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse( at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close( ... 26 more On further investigation, it seems you changed the code in as per and change log by adding the additional cleanup code in the below lines bus = null; conduitSelector = null; outFaultObserver = null; outboundChainCache = null; inboundChainCache = null; currentRequestContext = null; requestContext.clear(); requestContext = null; responseContext.clear(); responseContext = null; executor = null; The above lines added by you for cleanup has broken the behavior of using the JCA connection for getting port and closing it immediately and then using the port to call the webservice. This leads to above exception when JCA Pool maxes out causing an eviction on JCA Pool by below thread stack causing the ClientImpl's destroy to be called and ultimately the bus obj ref getting set to null by your code and ultimately this exception. The behavior in CXF 2.3 was perfectly fine with no such problems. This was introduced by above mentioned code fix. org.apache.cxf.endpoint.ClientImpl.destroy( org.apache.cxf.jca.outbound.ManagedConnectionImpl.destroy( org.apache.cxf.jca.outbound.ConnectionFactoryImpl.getConnection( Please fix this behavior since its not in the alignment to the behavior mentioned in JCA Spec and as per the documentation provided in CXF as well. Thanks

    Apache's JIRA Issue Tracker | 10 months ago | Dhawalpatel
    java.lang.IllegalStateException: Message received on a Client that has been closed or destroyed.

    Root Cause Analysis

    1. java.lang.IllegalStateException

      Message received on a Client that has been closed or destroyed.

      at org.apache.cxf.endpoint.ClientImpl.onMessage()
    2. Apache CXF Core
      1. org.apache.cxf.endpoint.ClientImpl.onMessage(
      1 frame
    3. Apache CXF Runtime HTTP Transport
      1. org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(
      2. org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(
      3. org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(
      3 frames