While having a J4pClient which sends periodic requests on a server, I restarted that server.
There was a 404 error, probably caused by a request sent during server restart, but then J4p failed with the message "Invalid use of SingleClientConnManager: connection still allocated.
Make sure to release the connection before allocating another one."
20:27:30.062 [main] ERROR c.b.metrics.harvest.HarvestMetrics - Error - cannot harvest metric
org.jolokia.client.exception.J4pException: 404 Not Found
at org.jolokia.client.J4pClient.extractJsonResponse(J4pClient.java:110) ~[jolokia-client-java-0.80.jar:na]
at org.jolokia.client.J4pClient.execute(J4pClient.java:83) ~[jolokia-client-java-0.80.jar:na]
at org.jolokia.client.J4pClient.execute(J4pClient.java:66) ~[jolokia-client-java-0.80.jar:na]
at com.b.metrics.harvest.HarvestMetrics.execute(HarvestMetrics.java:101) [classes/:na]
at com.b.metrics.harvest.HarvestMetrics.main(HarvestMetrics.java:281) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0_22]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[na:1.6.0_22]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0_22]
at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_22]
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115) [idea_rt.jar:na]
Harvesting com.b.metrics:type=GroupOfMetrics,name=ApplicationCollector
20:28:30.066 [main] ERROR c.b.metrics.harvest.HarvestMetrics - Error - cannot harvest metric
java.lang.IllegalStateException: Invalid use of SingleClientConnManager: connection still allocated.
Make sure to release the connection before allocating another one.
at org.apache.http.impl.conn.SingleClientConnManager.getConnection(SingleClientConnManager.java:199) ~[httpclient-4.0.1.jar:4.0.1]
at org.apache.http.impl.conn.SingleClientConnManager$1.getConnection(SingleClientConnManager.java:173) ~[httpclient-4.0.1.jar:4.0.1]
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:390) ~[httpclient-4.0.1.jar:4.0.1]
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641) ~[httpclient-4.0.1.jar:4.0.1]
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576) ~[httpclient-4.0.1.jar:4.0.1]
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:554) ~[httpclient-4.0.1.jar:4.0.1]
at org.jolokia.client.J4pClient.execute(J4pClient.java:82) ~[jolokia-client-java-0.80.jar:na]
at org.jolokia.client.J4pClient.execute(J4pClient.java:66) ~[jolokia-client-java-0.80.jar:na]
at com.b.metrics.harvest.HarvestMetrics.execute(HarvestMetrics.java:101) [classes/:na]
The text was updated successfully, but these errors were encountered:
This error typically occurs in multi threaded environments, but can happen if a response is not properly consumed. Thanks for spotting this. I fixed this by
a) making sure that the response is consumed (and the connection released) even in an error case
b) switched from a SingleClientConnManager to a ThreadSafeClientConnManager in Apache's HttpClient.
Expect this for version 0.81, I still need some tuning for allowing to select the connection manager (and other parameters like timeouts) during construction of the client.
Pushed changes to GIT and extended the construction of the J4pClient with a builder for tuning various parameters like timeouts. By default, the threadsafe connection manager is used now
While having a J4pClient which sends periodic requests on a server, I restarted that server.
There was a 404 error, probably caused by a request sent during server restart, but then J4p failed with the message "Invalid use of SingleClientConnManager: connection still allocated.
Make sure to release the connection before allocating another one."
20:27:30.062 [main] ERROR c.b.metrics.harvest.HarvestMetrics - Error - cannot harvest metric
org.jolokia.client.exception.J4pException: 404 Not Found
at org.jolokia.client.J4pClient.extractJsonResponse(J4pClient.java:110) ~[jolokia-client-java-0.80.jar:na]
at org.jolokia.client.J4pClient.execute(J4pClient.java:83) ~[jolokia-client-java-0.80.jar:na]
at org.jolokia.client.J4pClient.execute(J4pClient.java:66) ~[jolokia-client-java-0.80.jar:na]
at com.b.metrics.harvest.HarvestMetrics.execute(HarvestMetrics.java:101) [classes/:na]
at com.b.metrics.harvest.HarvestMetrics.main(HarvestMetrics.java:281) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0_22]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[na:1.6.0_22]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0_22]
at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_22]
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115) [idea_rt.jar:na]
Harvesting com.b.metrics:type=GroupOfMetrics,name=ApplicationCollector
20:28:30.066 [main] ERROR c.b.metrics.harvest.HarvestMetrics - Error - cannot harvest metric
java.lang.IllegalStateException: Invalid use of SingleClientConnManager: connection still allocated.
Make sure to release the connection before allocating another one.
at org.apache.http.impl.conn.SingleClientConnManager.getConnection(SingleClientConnManager.java:199) ~[httpclient-4.0.1.jar:4.0.1]
at org.apache.http.impl.conn.SingleClientConnManager$1.getConnection(SingleClientConnManager.java:173) ~[httpclient-4.0.1.jar:4.0.1]
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:390) ~[httpclient-4.0.1.jar:4.0.1]
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641) ~[httpclient-4.0.1.jar:4.0.1]
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576) ~[httpclient-4.0.1.jar:4.0.1]
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:554) ~[httpclient-4.0.1.jar:4.0.1]
at org.jolokia.client.J4pClient.execute(J4pClient.java:82) ~[jolokia-client-java-0.80.jar:na]
at org.jolokia.client.J4pClient.execute(J4pClient.java:66) ~[jolokia-client-java-0.80.jar:na]
at com.b.metrics.harvest.HarvestMetrics.execute(HarvestMetrics.java:101) [classes/:na]
The text was updated successfully, but these errors were encountered: