Rest service is not getting called when I type in the URL in the browser.

25 views
Skip to first unread message

Raja Khan

unread,
Nov 26, 2018, 2:11:15 PM11/26/18
to RestyGWT
Rest service is not getting called. I used this simple example based on RestyGWT video, but the issue is when I type localhost:8888/api/hellos it does not call this below service. If you see I have used @Path, do I need to specify this path in web.xml too or someplace else?

import java.util.HashMap;
import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

import com.google.api.client.util.Lists;
import com.zrsol.tours.shared.Hello;

@Path("/api/hellos")
public class HelloResource {
private HashMap<String, Hello> database;
public HelloResource(){
System.out.println("Inside HelloResource......");
database = new HashMap<String, Hello>();
Hello helloFirst = new Hello("1", "First");
Hello helloSecond = new Hello("2", "Second");
database.put(helloFirst.getId(), helloFirst);
database.put(helloSecond.getId(), helloSecond);
}
@GET
@Produces("application/json")
public List<Hello> getAll(){
return Lists.newArrayList(database.values());
}
@GET
@Produces("application/json")
@Path("/{id}")
public Hello get(@PathParam("id") String id){
return database.get(id);
}
}

christian

unread,
Nov 26, 2018, 2:26:54 PM11/26/18
to rest...@googlegroups.com
FYI, you have server side problem. RestyGWT is the client and can essentially work with any server (written in any language) - it just needs to over the right API for the RestyGWT client.
regards, Christian

Raja Khan

unread,
Nov 26, 2018, 2:33:36 PM11/26/18
to RestyGWT
Christian, thanks for the reply. But I am testing on inbuilt Jetty that comes with GWT 2.8.2. Do you think that is the issue that Jetty is not supporting Rest based jax-rs service? should I install the application on Tomcat. If you see the video at the end of the page https://resty-gwt.github.io/ . The video at 0:54 shows that he is testing using the inbuilt Jetty service. I am trying to do exactly the same thing and don't understand why it is not working.

christian

unread,
Nov 26, 2018, 2:49:40 PM11/26/18
to rest...@googlegroups.com
I am the wrong person to debug the built in Jetty servlet container have used RestyGWT a lot with ruby servers in the past. but for debugging you probably helps to first get your code working with standalone jetty setup.
Reply all
Reply to author
Forward
0 new messages