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

Apache's JIRA Issue Tracker | Dhawalpatel | 6 months ago
  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(NativeConstructorAccessorImpl.java:86) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:58) at java.lang.reflect.Constructor.newInstance(Constructor.java:542) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1376) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1365) at org.apache.cxf.io.CacheAndWriteOutputStream.postClose(CacheAndWriteOutputStream.java:56) at org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:215) at org.apache.cxf.io.AbstractWrappedOutputStream.close(AbstractWrappedOutputStream.java:77) at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56) at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:651) at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:520) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:429) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:330) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:283) at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96) at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:139) at com.sun.proxy.$Proxy106.inquireWirelinePaymentPlan(Unknown Source) at sun.reflect.GeneratedMethodAccessor360.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56) at java.lang.reflect.Method.invoke(Method.java:620) at AppAdapter.executeWebService(AppAdapter.java:702) Caused by: java.lang.IllegalStateException: Message received on a Client that has been closed or destroyed. at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:707) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1669) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1550) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1347) ... 26 more On further investigation, it seems you changed the code in ClientImpl.java as per https://issues.apache.org/jira/browse/CXF-3765 and change log https://fisheye6.atlassian.com/changelog/cxf?cs=e0ef66391d2e7e62e63e96214eca95e292271892 by adding the additional cleanup code in ClientImpl.java 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(ClientImpl.java:152) org.apache.cxf.jca.outbound.ManagedConnectionImpl.destroy(ManagedConnectionImpl.java:121) com.ibm.ejs.j2c.MCWrapper.destroy(MCWrapper.java:2086) com.ibm.ejs.j2c.FreePool.cleanupAndDestroyMCWrapper(FreePool.java:775) com.ibm.ejs.j2c.PoolManager.claimVictim(PoolManager.java:5190) com.ibm.ejs.j2c.PoolManager.reserve(PoolManager.java:3657) com.ibm.ejs.j2c.PoolManager.reserve(PoolManager.java:3091) com.ibm.ejs.j2c.ConnectionManager.allocateMCWrapper(ConnectionManager.java:1548) com.ibm.ejs.j2c.ConnectionManager.allocateConnection(ConnectionManager.java:1031) org.apache.cxf.jca.outbound.ConnectionFactoryImpl.getConnection(ConnectionFactoryImpl.java:53) com.sbc.cc.clarify.api.util.cxf.XCxfConnectorWebServiceInitializer.getCxfPortImpl(XCxfConnectorWebServiceInitializer.java:217) 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 | 6 months ago | Dhawalpatel
    java.lang.IllegalStateException: Message received on a Client that has been closed or destroyed.
  2. 0

    Apache Ignite Users - Getting IllegalStateException: Cache has been closed or destroyed: cache

    nabble.com | 7 months ago
    java.lang.IllegalStateException: Cache has been closed or destroyed: cache
  3. 0

    Where to find error logs in detail for Apache Ignite?

    Stack Overflow | 6 months ago | Yuci
    java.lang.IllegalStateException: Cache has been closed or destroyed: session-cache
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    GitHub comment 1058#255392309

    GitHub | 2 months ago | ThomasHornschuh
    java.lang.IllegalStateException: Client instance has been closed.

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    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
      ClientImpl.onMessage
      1. org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:707)
      1 frame
    3. Apache CXF Runtime HTTP Transport
      HTTPConduit$WrappedOutputStream.close
      1. org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1669)
      2. org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1550)
      3. org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1347)
      3 frames