Hallo,
ich versuche eine anfrage mit HttpClient zu senden und erhalte folgende fehlermeldung:
[JAVA=1]run:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.apache.commons.httpclient.HttpClient.<clinit>(HttpClient.java:66)
at Test.main(Test.java:37)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 2 more
Java Result: 1
ERSTELLEN ERFOLGREICH (Gesamtzeit: 0 Minuten 0 Sekunden)
[/code]
und hier ist der Code:
[JAVA=1]import java.util.Scanner;
import org.apache.commons.httpclient.cookie.CookiePolicy;
import org.apache.commons.httpclient.methods.*;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
import org.apache.commons.httpclient.params.HttpMethodParams;
import java.io.*;
public class Test {
/** Creates a new instance of Test */
public Test() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
try {
HttpClient client = new HttpClient();
GetMethod getMethod1 = new GetMethod("http://www.mysite.de");
client.executeMethod(getMethod1);
System.out.println("Aufruf ohne Login -----------------");
System.out.println(getMethod1.getResponseBodyAsString());
System.out.println("-----------------------------------");
PostMethod postMethod1 = new PostMethod("http://www.mysite.de");
postMethod1.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
postMethod1.addParameter("username", "ich");
postMethod1.addParameter("password", "geheim");
client.executeMethod(postMethod1);
System.out.println("Login -----------------------------");
System.out.println(postMethod1.getResponseBodyAsString());
System.out.println("-----------------------------------");
client.executeMethod(getMethod1);
System.out.println("Aufruf nach Login -----------------");
System.out.println(getMethod1.getResponseBodyAsString());
System.out.println("-----------------------------------");
} catch (Exception e) {
e.printStackTrace();
}
}
}
[/code]
woran liegt denn das Problem?
Danke schonmal.
MfG
ich versuche eine anfrage mit HttpClient zu senden und erhalte folgende fehlermeldung:
[JAVA=1]run:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.apache.commons.httpclient.HttpClient.<clinit>(HttpClient.java:66)
at Test.main(Test.java:37)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 2 more
Java Result: 1
ERSTELLEN ERFOLGREICH (Gesamtzeit: 0 Minuten 0 Sekunden)
[/code]
und hier ist der Code:
[JAVA=1]import java.util.Scanner;
import org.apache.commons.httpclient.cookie.CookiePolicy;
import org.apache.commons.httpclient.methods.*;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
import org.apache.commons.httpclient.params.HttpMethodParams;
import java.io.*;
public class Test {
/** Creates a new instance of Test */
public Test() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
try {
HttpClient client = new HttpClient();
GetMethod getMethod1 = new GetMethod("http://www.mysite.de");
client.executeMethod(getMethod1);
System.out.println("Aufruf ohne Login -----------------");
System.out.println(getMethod1.getResponseBodyAsString());
System.out.println("-----------------------------------");
PostMethod postMethod1 = new PostMethod("http://www.mysite.de");
postMethod1.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
postMethod1.addParameter("username", "ich");
postMethod1.addParameter("password", "geheim");
client.executeMethod(postMethod1);
System.out.println("Login -----------------------------");
System.out.println(postMethod1.getResponseBodyAsString());
System.out.println("-----------------------------------");
client.executeMethod(getMethod1);
System.out.println("Aufruf nach Login -----------------");
System.out.println(getMethod1.getResponseBodyAsString());
System.out.println("-----------------------------------");
} catch (Exception e) {
e.printStackTrace();
}
}
}
[/code]
woran liegt denn das Problem?
Danke schonmal.
MfG