You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Yuzwa, Erik" <Er...@encana.com> on 2004/10/04 17:39:35 UTC

GetMethod instantiation throwing exception?

Hi all,
 
I'm trying to get HttpClient working alongside NTLM authentication to
automagically grab some XML data for users.
 
The docs are fairly clear on using HttpClient with NTLM, however my
GetMethod instantiation regularly blows up throwing a 
"java.lang.NoClassDefFoundError: org/apache/commons/codec/DecoderException"
 
//begin-code snippet
 
//according to HttpClient docs, run this code before using NTLM...
String secProviderName = "com.sun.crypto.provider.SunJCE";
java.security.Provider secProvider =
(java.security.Provider)Class.forName(secProviderName).newInstance();
Security.addProvider(secProvider);
 
HttpClient client = new HttpClient();

//grabbing server names from a file to do the requestin'
String sUrl    = "http://" + sServer + "/onenet/xtier-login"; //DOES build
valid URLs
 
client.getState().setCredentials(
             AuthScope.ANY,
             new NTCredentials(sUser, sPass, sServer, "stovokor.com")
 );
 
GetMethod http_get = new GetMethod( sUrl ); //wammo! Here's the offender

//end-code snippet
 
There's no documentation with the GetMethod object concerning any exceptions
thrown during instantiation, so I'm stuck
trying to figure out what the hey is happening.
 
Thanks!

Re: GetMethod instantiation throwing exception?

Posted by Michael Becke <be...@u.washington.edu>.
Hi Erik,

HttpClient 3.0 has added a dependency for commons-codec.  Adding this to 
your classpath should fix the problem.

Mike

Yuzwa, Erik wrote:
> Hi all,
>  
> I'm trying to get HttpClient working alongside NTLM authentication to
> automagically grab some XML data for users.
>  
> The docs are fairly clear on using HttpClient with NTLM, however my
> GetMethod instantiation regularly blows up throwing a 
> "java.lang.NoClassDefFoundError: org/apache/commons/codec/DecoderException"
>  
> //begin-code snippet
>  
> //according to HttpClient docs, run this code before using NTLM...
> String secProviderName = "com.sun.crypto.provider.SunJCE";
> java.security.Provider secProvider =
> (java.security.Provider)Class.forName(secProviderName).newInstance();
> Security.addProvider(secProvider);
>  
> HttpClient client = new HttpClient();
> 
> //grabbing server names from a file to do the requestin'
> String sUrl    = "http://" + sServer + "/onenet/xtier-login"; //DOES build
> valid URLs
>  
> client.getState().setCredentials(
>              AuthScope.ANY,
>              new NTCredentials(sUser, sPass, sServer, "stovokor.com")
>  );
>  
> GetMethod http_get = new GetMethod( sUrl ); //wammo! Here's the offender
> 
> //end-code snippet
>  
> There's no documentation with the GetMethod object concerning any exceptions
> thrown during instantiation, so I'm stuck
> trying to figure out what the hey is happening.
>  
> Thanks!
> 

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