Return-Path: Delivered-To: apmail-hc-httpclient-users-archive@www.apache.org Received: (qmail 63988 invoked from network); 23 Jan 2008 14:43:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Jan 2008 14:43:08 -0000 Received: (qmail 42728 invoked by uid 500); 23 Jan 2008 14:42:57 -0000 Delivered-To: apmail-hc-httpclient-users-archive@hc.apache.org Received: (qmail 42712 invoked by uid 500); 23 Jan 2008 14:42:57 -0000 Mailing-List: contact httpclient-users-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpClient User Discussion" Delivered-To: mailing list httpclient-users@hc.apache.org Received: (qmail 42703 invoked by uid 99); 23 Jan 2008 14:42:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Jan 2008 06:42:57 -0800 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of sebbaz@gmail.com designates 72.14.202.183 as permitted sender) Received: from [72.14.202.183] (HELO ro-out-1112.google.com) (72.14.202.183) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Jan 2008 14:42:30 +0000 Received: by ro-out-1112.google.com with SMTP id d36so997740roh.13 for ; Wed, 23 Jan 2008 06:42:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=nq1LdK5o+uGWPjlxhvJFXk/aiCHQ3n75TorLalHuiGM=; b=qbXTvHR+pwFtnNQ2TbURaWxLMp3mICWw8QWCIBbGerbGxdPdzyZ84W6pRKZE+GfK6Uuiw4Po9Lzk8mHkFxb2qMjPIIhch0e4BN3y/NitaQj/O/kapMCdEwkGhDeuketDLpDFPhrl06uiiU4T1j5h9x+MNfFpAIxScg9j06iDZRA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=gt1ou64fBd0Isf8s0LAjA/GXoC3V5Hx0MsqPfMCnJzIdSL9k991W6k4eDbfgcyrjSHZu+WQVqJV7CKaMHnM1aKJZAhqTBINZOktzZyCKKTXK2R/JlosEE42aomKEJan0+3FPKcA4aMlMJlCusKg004eH9Dz1fQrGR20Rg3EJPZI= Received: by 10.142.165.9 with SMTP id n9mr373987wfe.58.1201099353746; Wed, 23 Jan 2008 06:42:33 -0800 (PST) Received: by 10.142.229.10 with HTTP; Wed, 23 Jan 2008 06:42:33 -0800 (PST) Message-ID: <25aac9fc0801230642k524f3effx19b128ceaee234f9@mail.gmail.com> Date: Wed, 23 Jan 2008 14:42:33 +0000 From: sebb To: "HttpClient User Discussion" Subject: Re: java.lang.IllegalArgumentException: host parameter is null In-Reply-To: <15041125.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <15040749.post@talk.nabble.com> <15041125.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org Just guessing, but try: http://localhost/ On 23/01/2008, AbelMacAdam wrote: > > Sorry, theUrl should be "http://localhost". :-[ > > AbelMacAdam wrote: > > > > Hi, > > > > After a few fruitless days struggling with JSSE, I finally found > > Commons-HTTPClient. I'm trying out the example TrivialApp you can download > > from the examples directory. And that example gives me an > > IllegalArgumentException headache. > > > > The code looks like: > > static String username = ""; > > static String password = ""; > > static String theUrl = "localhost"; > > static Logger logger; > > > > private static final void printUsage(String text) > > { > > logger.info(text); > > System.out.println (text); > > } > > > > public static void main(String[] args) > > { > > logger = Logger.getLogger(TrivialApp.class); > > > > Credentials creds = null; > > creds = new UsernamePasswordCredentials(username, password); > > > > //create a singular HttpClient object > > HttpClient client = new HttpClient(); > > > > //establish a connection within 5 seconds > > client.getHttpConnectionManager(). > > getParams().setConnectionTimeout(5000); > > > > //set the default credentials > > if (creds != null) { > > client.getState().setCredentials(AuthScope.ANY, creds); > > } > > > > String url = theUrl; > > HttpMethod method = null; > > > > //create a method object > > method = new GetMethod(url); > > method.setFollowRedirects(true); > > > > //execute the method > > String responseBody = null; > > try{ > > client.executeMethod(method); > > responseBody = method.getResponseBodyAsString(); > > } catch (HttpException he) { > > printUsage("Http error connecting to '" + url + "'"); > > printUsage(he.getMessage()); > > System.exit(-4); > > } catch (IOException ioe){ > > printUsage("Unable to connect to '" + url + "'"); > > System.exit(-3); > > } > > > > //write out the request headers > > printUsage("*** Request ***"); > > printUsage("Request Path: " + method.getPath()); > > printUsage("Request Query: " + method.getQueryString()); > > Header[] requestHeaders = method.getRequestHeaders(); > > for (int i=0; i > System.out.print(requestHeaders[i]); > > } > > > > //write out the response headers > > printUsage("*** Response ***"); > > printUsage("Status Line: " + method.getStatusLine()); > > Header[] responseHeaders = method.getResponseHeaders(); > > for (int i=0; i > System.out.print(responseHeaders[i]); > > } > > > > //write out the response body > > System.out.println("*** Response Body ***"); > > System.out.println(responseBody); > > > > //clean up the connection resources > > method.releaseConnection(); > > > > System.exit(0); > > } > > > > The stack trace I got for the Exception is: > > Exception in thread "main" java.lang.IllegalArgumentException: host > > parameter is null > > at > > org.apache.commons.httpclient.HttpConnection.(HttpConnection.java:206) > > at > > org.apache.commons.httpclient.HttpConnection.(HttpConnection.java:155) > > at > > org.apache.commons.httpclient.SimpleHttpConnectionManager.getConnectionWithTimeout(SimpleHttpConnectionManager.java:175) > > at > > org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:153) > > at > > org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) > > at > > org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323) > > at TrivialApp.main(TrivialApp.java:107) > > > > Long introduction. Concluding: Am I wrong in assuming the assignment > > theURL = "localhost"; > > is wrong? > > > > It is a real head scratcher. If you could point out where this goes wrong, > > I would be obliged. > > > > TIA, > > Abel > > > > -- > View this message in context: http://www.nabble.com/java.lang.IllegalArgumentException%3A-host-parameter-is-null-tp15040749p15041125.html > Sent from the HttpClient-User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org > For additional commands, e-mail: httpclient-users-help@hc.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org For additional commands, e-mail: httpclient-users-help@hc.apache.org