problems with REST configuration in JBossAS 7.1.1.Final
icarusdb Dec 11, 2012 8:35 AMI'm trying to run this simple class
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import javax.ws.rs.core.MediaType;
import org.jboss.resteasy.client.ClientRequest;
import org.jboss.resteasy.client.ClientResponse;
public class RESTEasyClientTest
{
private final String uri = "http://localhost:8080/auth-module/rest/activeusers";
public static void main(String[] args)
{
String output;
BufferedReader br = null;
ClientResponse<?> response = null;
try
{
ClientRequest request = new ClientRequest(uri);
request.accept(MediaType.APPLICATION_JSON);
/* GET example */
response = request.get(String.class);
if (response.getStatus() != 200)
{
throw new RuntimeException("Failed : HTTP error code : "
+ response.getStatus());
}
br = new BufferedReader(new InputStreamReader(
new ByteArrayInputStream(((String)response.getEntity()).getBytes())));
System.out.println("Output from Server .... \n");
while ((output = br.readLine()) != null)
{
System.out.println(output);
}
}
catch (IOException e)
{
e.printStackTrace();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
but I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2406)
at java.lang.Class.getConstructor0(Class.java:2716)
at java.lang.Class.newInstance0(Class.java:343)
at java.lang.Class.newInstance(Class.java:325)
at org.jboss.resteasy.client.ClientRequest.getDefaultExecutor(ClientRequest.java:87)
at org.jboss.resteasy.client.ClientRequest.<init>(ClientRequest.java:97)
at py.org.pti.test.auth.RESTEasyClientGet.main(RESTEasyClientGet.java:35)
Caused by: java.lang.ClassNotFoundException: org.apache.http.client.HttpClient
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334)
... 8 more
I already added
<global-modules> | ||
<module name="org.apache.commons.beanutils" slot="main"/> | ||
<module name="org.apache.commons.collections" slot="main"/> | ||
<module name="org.apache.commons.digester" slot="main"/> | ||
1 | <module name="org.apache.commons.codec" slot="main"/> | |
2 | <module name="org.apache.commons.logging" slot="main"/> | |
3 | <module name="org.apache.james.mime4j" slot="main"/> | |
4 | <module name="org.apache.httpcomponents" slot="main"/> | |
5 | <module name="org.apache.http.client.httpclient" slot="main"/> | |
</global-modules> |
and the folders are exactly as module folder says how they have to be placed
I added the lines numbered from 1 to 5 with no successs
the default executor is org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor
but it's nothing like that in modules
any thing I'm missing ?