Hi,
I have a Resource configured as a EJB 3.1 Stateless Bean. I also have an overridden Application class to customize the context root. However, the client just cannot seem to find the Resource. What am I doing wrong? The Resource is packaged and deployed as a war.
Cross posted: http://www.coderanch.com/t/546565/java-Web-Services-SCDJWS/certification/RESTful-service-EJB-endpoint-cannot#2480046
Tests in error:
testSendRequestAndGetGreeting(name.app.abhi.helloworld.ejb.restful.client.HelloWorldEjbRestfulClientTest): GET http://localhost:9090/practice/helloworld?name=Duke returned a response status of 404 Not Found
Resource:
@Path("helloworld")
@Stateless
public class HelloWorldBean {
@GET
@Produces("text/plain")
public String getQuintessentialGreeting(@QueryParam("name") String name) {
if (name == null) {
throw new WebApplicationException(Response.Status.BAD_REQUEST);
}
return "Say hello to the world, " + name;
}
}
Application class:
@ApplicationPath("practice")
public class ApplicationConfig extends Application {
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> clazzez = super.getClasses();
if (clazzez == null) {
clazzez = new HashSet<Class<?>>();
}
clazzez.add(name.app.abhi.helloworld.ejb.restful.service.HelloWorldBean.class);
return clazzez;
}
}
Client:
public class HelloWorldEjbRestfulClient {
private final static String ENDPOINT_URI = "http://localhost:9090/"
+ "practice/helloworld";
public String sendRequestAndGetGreeting(String name) {
Client client = Client.create();
WebResource webResource = client.resource(ENDPOINT_URI);
webResource.accept(MediaType.TEXT_PLAIN);
return webResource.queryParam("name", name).get(java.lang.String.class);
}
}
Edited by: asarkar on Jul 24, 2011 12:20 PM