سلام دوستان من این کد رو نوشتم اما تو کنسول این ارور رو میده.....لطفا هر چی به ذهنتون میرسه بگید تا مشکلم حل شه...
ارور داخل کنسول :
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.apache.http.impl.client.AbstractHttpClient.<init>(AbstractHttpClient.java:159)
at org.apache.http.impl.client.DefaultHttpClient.<init>(DefaultHttpClient.java:178)
at adakpro.a.main(a.java:28)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 3 more
public static void main(String[] args) throws ClientProtocolException, IOException {
ArrayList<HashMap<String, String>>mylist = new ArrayList<HashMap<String, String>>();
//Get the data (see above)
HttpHost targetHost = new HttpHost("localhost", 8080, "http");
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.getCredentialsProvider().setCredentials(newAuthScope(targetHost.getHostName(), targetHost.getPort()),newUsernamePasswordCredentials("test@liferay.com", "test"));
AuthCache authCache = new BasicAuthCache();
BasicScheme basicAuth = new BasicScheme();
authCache.put(targetHost, basicAuth);
BasicHttpContext ctx = new BasicHttpContext();
//ctx.setAttribute(ClientContext.AUTH_CACHE,authCache);
HttpPost post = new HttpPost("/tunnel-web/secure/json");
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("serviceClassName","com.liferay.portal.service.CountryServiceUtil"));
params.add(new BasicNameValuePair("serviceMethodName", "getCountries"));
params.add(new BasicNameValuePair("serviceParameters", "[]"));
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(params, "UTF-8");
post.setEntity(entity);
HttpResponse resp = httpclient.execute(targetHost, post, ctx);
resp.getEntity().writeTo(System.out);
httpclient.getConnectionManager().shutdown();
}
}
آخرین ویرایش: 19-09-2017 ???? 18:54، توسط رضا رمضانپور