You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Madeleine Wright <m....@ru.ac.za> on 2004/11/22 13:55:30 UTC

problem with version 3?

I have no problem with running code using version  2.0.1.  I have just 
tried running (suitably amended) code with version 3 and I get an error 
I can't explain.  The main code as far as the problem is:
        String url = "http://www.apache.org";
        HttpClient client = new HttpClient();
        client.getParams().setAuthenticationPreemptive(true);
        AuthScope as = new AuthScope("host", portnum);
        Credentials creds = new UsernamePasswordCredentials("user", 
"password");
        client.getState().setProxyCredentials(as, creds);
        client.getHostConfiguration().setProxy("host", hostNum);
        
client.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,new 
DefaultHttpMethodRetryHandler(1, false));
       
        setProperty("org.apache.commons.logging.Log", 
"org.apache.commons.logging.impl.SimpleLog");
        setProperty("org.apache.commons.logging.simplelog.showdatetime", 
"true");
        
setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire.header", 
"debug");
        
setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", 
"debug");
       
        GetMethod method = new GetMethod(url);

It all compiles OK but the problem is with the last line (?), where it 
throws the following exception:
    Exception in thread "main" java.lang.NoClassDefFoundError: 
org/apache/commons/codec/DecoderException
    at 
org.apache.commons.httpclient.HttpMethodBase.<init>(HttpMethodBase.java:217)
    at 
org.apache.commons.httpclient.methods.GetMethod.<init>(GetMethod.java:88)
    at FileFinder.main(FileFinder.java:60)

Can anyone tell me what this means, please?  Surely it finds the 
GetMethod class???

Thanks.

Madeleine


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


Re: problem with version 3?

Posted by Oleg Kalnichevski <ol...@apache.org>.
Madeleine,

Parameters applied to an HTTP method will affect the execution of that
specific method only. Parameters aplied to an HTTP client will affect
the execution of all methods executed with that specific client.

For details see the HttpClient preferences guide:

http://jakarta.apache.org/commons/httpclient/3.0/preference-api.html

Oleg


On Mon, Nov 22, 2004 at 03:12:49PM +0200, Madeleine Wright wrote:
> Great.  It works perfectly now.  Is there any difference between
>    client.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,new 
> DefaultHttpMethodRetryHandler(1, false));
> and
>    method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,new 
> DefaultHttpMethodRetryHandler(1, false));
> 
> They both seem to work.  Is there any advantage of using one over the other?
> 
> Thanks.
> 
> Madeleine
> 
> Oleg Kalnichevski wrote:
> 
> >Madeleine,
> >As of version 3.0 HttpClient requires Commons Codec library as a runtime
> >dependency:
> >
> >http://jakarta.apache.org/commons/codec/
> >
> >Hope this helps
> >
> >Oleg
> > 
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


Re: problem with version 3?

Posted by Madeleine Wright <m....@ru.ac.za>.
Thanks also.  Just been looking at those docs and trying out some of the 
example code.  Looks very useful.

Madeleine

Ortwin Glück wrote:

> Madeleine,
>
> please have a look at the new Preferences API:
> http://jakarta.apache.org/commons/httpclient/3.0/preference-api.html
>
> In 3.0 you can set options (like the retry handler) on different 
> levels. It depends on your applications, on which level you want to 
> manage certain config options. In general I guess having one retry 
> handler at the client level is fair. Doing it at the method level just 
> provides more flexibility when your application needs this complexity.



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


Re: problem with version 3?

Posted by Ortwin Glück <or...@nose.ch>.
Madeleine,

please have a look at the new Preferences API:
http://jakarta.apache.org/commons/httpclient/3.0/preference-api.html

In 3.0 you can set options (like the retry handler) on different levels. 
It depends on your applications, on which level you want to manage 
certain config options. In general I guess having one retry handler at 
the client level is fair. Doing it at the method level just provides 
more flexibility when your application needs this complexity.

Madeleine Wright wrote:

> Great.  It works perfectly now.  Is there any difference between
>    client.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,new 
> DefaultHttpMethodRetryHandler(1, false));
> and
>    method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,new 
> DefaultHttpMethodRetryHandler(1, false));
> 
> They both seem to work.  Is there any advantage of using one over the 
> other?
> 
> Thanks.
> 
> Madeleine



-- 
  _________________________________________________________________
  NOSE applied intelligence ag

  ortwin glück                      [www]      http://www.nose.ch
  software engineer
  hardturmstrasse 171               [pgp id]           0x81CF3416
  8005 zürich                       [office]      +41-1-277 57 35
  switzerland                       [fax]         +41-1-277 57 12

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


Re: problem with version 3?

Posted by Madeleine Wright <m....@ru.ac.za>.
Great.  It works perfectly now.  Is there any difference between
    client.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,new 
DefaultHttpMethodRetryHandler(1, false));
and
    method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,new 
DefaultHttpMethodRetryHandler(1, false));

They both seem to work.  Is there any advantage of using one over the other?

Thanks.

Madeleine

Oleg Kalnichevski wrote:

>Madeleine,
>As of version 3.0 HttpClient requires Commons Codec library as a runtime
>dependency:
>
>http://jakarta.apache.org/commons/codec/
>
>Hope this helps
>
>Oleg
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


Re: problem with version 3?

Posted by Madeleine Wright <m....@ru.ac.za>.
Thanks.  I'll add that.

Madeleine

Oleg Kalnichevski wrote:

>Madeleine,
>As of version 3.0 HttpClient requires Commons Codec library as a runtime
>dependency:
>
>http://jakarta.apache.org/commons/codec/
>
>Hope this helps
>
>Oleg
>
>
>On Mon, Nov 22, 2004 at 02:55:30PM +0200, Madeleine Wright wrote:
>  
>
>>I have no problem with running code using version  2.0.1.  I have just 
>>tried running (suitably amended) code with version 3 and I get an error 
>>I can't explain.  The main code as far as the problem is:
>>       String url = "http://www.apache.org";
>>       HttpClient client = new HttpClient();
>>       client.getParams().setAuthenticationPreemptive(true);
>>       AuthScope as = new AuthScope("host", portnum);
>>       Credentials creds = new UsernamePasswordCredentials("user", 
>>"password");
>>       client.getState().setProxyCredentials(as, creds);
>>       client.getHostConfiguration().setProxy("host", hostNum);
>>       
>>client.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,new 
>>DefaultHttpMethodRetryHandler(1, false));
>>      
>>       setProperty("org.apache.commons.logging.Log", 
>>"org.apache.commons.logging.impl.SimpleLog");
>>       setProperty("org.apache.commons.logging.simplelog.showdatetime", 
>>"true");
>>       
>>setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire.header", 
>>"debug");
>>       
>>setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", 
>>"debug");
>>      
>>       GetMethod method = new GetMethod(url);
>>
>>It all compiles OK but the problem is with the last line (?), where it 
>>throws the following exception:
>>   Exception in thread "main" java.lang.NoClassDefFoundError: 
>>org/apache/commons/codec/DecoderException
>>   at 
>>org.apache.commons.httpclient.HttpMethodBase.<init>(HttpMethodBase.java:217)
>>   at 
>>org.apache.commons.httpclient.methods.GetMethod.<init>(GetMethod.java:88)
>>   at FileFinder.main(FileFinder.java:60)
>>
>>Can anyone tell me what this means, please?  Surely it finds the 
>>GetMethod class???
>>
>>Thanks.
>>
>>Madeleine
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org
>>
>>    
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org
>
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


Re: problem with version 3?

Posted by Oleg Kalnichevski <ol...@apache.org>.
Madeleine,
As of version 3.0 HttpClient requires Commons Codec library as a runtime
dependency:

http://jakarta.apache.org/commons/codec/

Hope this helps

Oleg


On Mon, Nov 22, 2004 at 02:55:30PM +0200, Madeleine Wright wrote:
> I have no problem with running code using version  2.0.1.  I have just 
> tried running (suitably amended) code with version 3 and I get an error 
> I can't explain.  The main code as far as the problem is:
>        String url = "http://www.apache.org";
>        HttpClient client = new HttpClient();
>        client.getParams().setAuthenticationPreemptive(true);
>        AuthScope as = new AuthScope("host", portnum);
>        Credentials creds = new UsernamePasswordCredentials("user", 
> "password");
>        client.getState().setProxyCredentials(as, creds);
>        client.getHostConfiguration().setProxy("host", hostNum);
>        
> client.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,new 
> DefaultHttpMethodRetryHandler(1, false));
>       
>        setProperty("org.apache.commons.logging.Log", 
> "org.apache.commons.logging.impl.SimpleLog");
>        setProperty("org.apache.commons.logging.simplelog.showdatetime", 
> "true");
>        
> setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire.header", 
> "debug");
>        
> setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", 
> "debug");
>       
>        GetMethod method = new GetMethod(url);
> 
> It all compiles OK but the problem is with the last line (?), where it 
> throws the following exception:
>    Exception in thread "main" java.lang.NoClassDefFoundError: 
> org/apache/commons/codec/DecoderException
>    at 
> org.apache.commons.httpclient.HttpMethodBase.<init>(HttpMethodBase.java:217)
>    at 
> org.apache.commons.httpclient.methods.GetMethod.<init>(GetMethod.java:88)
>    at FileFinder.main(FileFinder.java:60)
> 
> Can anyone tell me what this means, please?  Surely it finds the 
> GetMethod class???
> 
> Thanks.
> 
> Madeleine
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org