Re: [Resteasy-users] Resetting connection?

2013-10-31 Thread John D. Ament
I wanted to circle back to this.

I use this to generate a stub:

String contextUrl = co.getValue();
ClientConnectionManager cm = new ThreadSafeClientConnManager();
HttpClient httpClient = new DefaultHttpClient(cm);
ClientExecutor executor = new ApacheHttpClient4Executor(httpClient);
RegisterBuiltin.register(ResteasyProviderFactory.getInstance());
return (T) ProxyFactory.create(className, contextUrl, executor);

However, Bill mentions I need to use ClientResponse.releaseConnection(). I
don't see a way to do this in this scenario.  I don't actually have the
ClientResponse here.  Should I make that the return value of my interface
methods?

Thanks,

JOhn


On Wed, Oct 16, 2013 at 8:12 AM, Bill Burke  wrote:

> You should be calling ClientResponse.releaseConnection() after you are
> done with the ClientResponse.  Resteasy should automatically clean up
> the connection, but this only happens on a GC.
>
> In JAX-RS 2.0 you are also required to call Response.close().
>
> On 10/15/2013 5:15 PM, John D. Ament wrote:
> > I've seen this error lots of times:
> >
> > Caused by: java.lang.IllegalStateException: Invalid use of
> > BasicClientConnManager: connection still allocated.
> > Make sure to release the connection before allocating another one.
> >  at
> org.apache.http.impl.conn.BasicClientConnectionManager.getConnection(BasicClientConnectionManager.java:161)
> >  at
> org.apache.http.impl.conn.BasicClientConnectionManager$1.getConnection(BasicClientConnectionManager.java:138)
> >  at
> org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:455)
> >  at
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
> >  at
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
> >  at
> org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor.execute(ApacheHttpClient4Executor.java:182)
> > [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]
> >  at
> org.jboss.resteasy.core.interception.ClientExecutionContextImpl.proceed(ClientExecutionContextImpl.java:39)
> > [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]
> >  at
> org.jboss.resteasy.plugins.interceptors.encoding.AcceptEncodingGZIPInterceptor.execute(AcceptEncodingGZIPInterceptor.java:40)
> > [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]
> >  at
> org.jboss.resteasy.core.interception.ClientExecutionContextImpl.proceed(ClientExecutionContextImpl.java:45)
> > [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]
> >  at
> org.jboss.resteasy.client.ClientRequest.execute(ClientRequest.java:443)
> > [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]
> >  at
> org.jboss.resteasy.client.ClientRequest.httpMethod(ClientRequest.java:677)
> > [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]
> >  at
> org.jboss.resteasy.client.core.ClientInvoker.invoke(ClientInvoker.java:111)
> > [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]
> >
> > When trying to use the resteasy client.  However, how do I reset
> > connection as is indicated in here when I'm using a proxy object?
> >
> > John
> >
> >
> --
> > October Webinars: Code for Performance
> > Free Intel webinars can help you accelerate application performance.
> > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
> from
> > the latest Intel processors and coprocessors. See abstracts and register
> >
> >
> http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
> > ___
> > Resteasy-users mailing list
> > Resteasy-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/resteasy-users
> >
>
> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com
>
>
> --
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
> from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
> ___
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>
--
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gam

Re: [Resteasy-users] Resetting connection?

2013-10-16 Thread Bill Burke
You should be calling ClientResponse.releaseConnection() after you are 
done with the ClientResponse.  Resteasy should automatically clean up 
the connection, but this only happens on a GC.

In JAX-RS 2.0 you are also required to call Response.close().

On 10/15/2013 5:15 PM, John D. Ament wrote:
> I've seen this error lots of times:
>
> Caused by: java.lang.IllegalStateException: Invalid use of
> BasicClientConnManager: connection still allocated.
> Make sure to release the connection before allocating another one.
>  at 
> org.apache.http.impl.conn.BasicClientConnectionManager.getConnection(BasicClientConnectionManager.java:161)
>  at 
> org.apache.http.impl.conn.BasicClientConnectionManager$1.getConnection(BasicClientConnectionManager.java:138)
>  at 
> org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:455)
>  at 
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
>  at 
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
>  at 
> org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor.execute(ApacheHttpClient4Executor.java:182)
> [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]
>  at 
> org.jboss.resteasy.core.interception.ClientExecutionContextImpl.proceed(ClientExecutionContextImpl.java:39)
> [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]
>  at 
> org.jboss.resteasy.plugins.interceptors.encoding.AcceptEncodingGZIPInterceptor.execute(AcceptEncodingGZIPInterceptor.java:40)
> [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]
>  at 
> org.jboss.resteasy.core.interception.ClientExecutionContextImpl.proceed(ClientExecutionContextImpl.java:45)
> [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]
>  at 
> org.jboss.resteasy.client.ClientRequest.execute(ClientRequest.java:443)
> [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]
>  at 
> org.jboss.resteasy.client.ClientRequest.httpMethod(ClientRequest.java:677)
> [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]
>  at 
> org.jboss.resteasy.client.core.ClientInvoker.invoke(ClientInvoker.java:111)
> [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]
>
> When trying to use the resteasy client.  However, how do I reset
> connection as is indicated in here when I'm using a proxy object?
>
> John
>
> --
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
> ___
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>

-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com

--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users