You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Patrick Conway (JIRA)" <ji...@apache.org> on 2008/09/03 13:47:44 UTC

[jira] Created: (HTTPCLIENT-793) NoClassDefFoundError

NoClassDefFoundError
--------------------

                 Key: HTTPCLIENT-793
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-793
             Project: HttpComponents HttpClient
          Issue Type: Question
          Components: HttpClient
    Affects Versions: 4.0 Beta 1
         Environment: MAC OSX, Running Authentication example, using eclipse3.2 
            Reporter: Patrick Conway


I downloaded HttpClient and HttpCore.  I want to create a java program which can access my password protected webpage

But I canot get the example to run

Here is the error and the code.

=========ERROR===========

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
	at org.apache.http.impl.client.AbstractHttpClient.<init>(AbstractHttpClient.java:84)
	at org.apache.http.impl.client.DefaultHttpClient.<init>(DefaultHttpClient.java:128)
	at com.mapflow.siteMonitor.SiteMonitor.main(SiteMonitor.java:30)

=========CODE===========

package com.mapflow.siteMonitor;
import java.io.IOException;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

/**
 * @author patrick
 *
 */
public class SiteMonitor {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws ClientProtocolException 
	 */
	public static void main(String[] args) throws ClientProtocolException, IOException {
		// TODO Auto-generated method stub
		DefaultHttpClient httpclient = new DefaultHttpClient();

        httpclient.getCredentialsProvider().setCredentials(
                new AuthScope("******", 80), 
                new UsernamePasswordCredentials("*****", "*****"));
        
        HttpGet httpget = new HttpGet("**********");
        
        System.out.println("executing request" + httpget.getRequestLine());
        HttpResponse response = httpclient.execute(httpget);
        HttpEntity entity = response.getEntity();

        System.out.println("----------------------------------------");
        System.out.println(response.getStatusLine());
        if (entity != null) {
            System.out.println("Response content length: " + entity.getContentLength());
            System.out.println("Chunked?: " + entity.isChunked());
        }
        if (entity != null) {
            entity.consumeContent();
        }

	}

}



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Resolved: (HTTPCLIENT-793) NoClassDefFoundError

Posted by "Patrick Conway (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCLIENT-793?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Patrick Conway resolved HTTPCLIENT-793.
---------------------------------------

    Resolution: Fixed

Downloaded commons.logging and added the jars to the build path

> NoClassDefFoundError
> --------------------
>
>                 Key: HTTPCLIENT-793
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-793
>             Project: HttpComponents HttpClient
>          Issue Type: Question
>          Components: HttpClient
>    Affects Versions: 4.0 Beta 1
>         Environment: MAC OSX, Running Authentication example, using eclipse3.2 
>            Reporter: Patrick Conway
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> I downloaded HttpClient and HttpCore.  I want to create a java program which can access my password protected webpage
> But I canot get the example to run
> Here is the error and the code.
> =========ERROR===========
> Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
> 	at org.apache.http.impl.client.AbstractHttpClient.<init>(AbstractHttpClient.java:84)
> 	at org.apache.http.impl.client.DefaultHttpClient.<init>(DefaultHttpClient.java:128)
> 	at com.mapflow.siteMonitor.SiteMonitor.main(SiteMonitor.java:30)
> =========CODE===========
> package com.mapflow.siteMonitor;
> import java.io.IOException;
> import org.apache.http.HttpEntity;
> import org.apache.http.HttpResponse;
> import org.apache.http.auth.AuthScope;
> import org.apache.http.auth.UsernamePasswordCredentials;
> import org.apache.http.client.ClientProtocolException;
> import org.apache.http.client.methods.HttpGet;
> import org.apache.http.impl.client.DefaultHttpClient;
> /**
>  * @author patrick
>  *
>  */
> public class SiteMonitor {
> 	/**
> 	 * @param args
> 	 * @throws IOException 
> 	 * @throws ClientProtocolException 
> 	 */
> 	public static void main(String[] args) throws ClientProtocolException, IOException {
> 		// TODO Auto-generated method stub
> 		DefaultHttpClient httpclient = new DefaultHttpClient();
>         httpclient.getCredentialsProvider().setCredentials(
>                 new AuthScope("******", 80), 
>                 new UsernamePasswordCredentials("*****", "*****"));
>         
>         HttpGet httpget = new HttpGet("**********");
>         
>         System.out.println("executing request" + httpget.getRequestLine());
>         HttpResponse response = httpclient.execute(httpget);
>         HttpEntity entity = response.getEntity();
>         System.out.println("----------------------------------------");
>         System.out.println(response.getStatusLine());
>         if (entity != null) {
>             System.out.println("Response content length: " + entity.getContentLength());
>             System.out.println("Chunked?: " + entity.isChunked());
>         }
>         if (entity != null) {
>             entity.consumeContent();
>         }
> 	}
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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