Thursday, 22 August 2013

Restful WebService call with Jersey client

Restful WebService call with Jersey client

CASE
I am trying to fetch User data from Servlet filter using REST service.
CODE
public class LoginFilter implements Filter {
private static final String BaseURI =
"http://localhost:8080/insame/webresources/com.insame.entity.users/count";
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
ClientConfig config = new DefaultClientConfig();
Client client = Client.create(config);
WebResource webResource = client.resource(BaseURI);
String s = webResource.get(String.class);
PROBLEM
com.sun.jersey.api.client.UniformInterfaceException: GET
http://localhost:8080/insame/webresources/com.insame.entity.users/count
returned a response status of 500 Internal Server Error
QUESTION
1) What is the wisest way to fetch data from servlet filter using REST + JPA?
2) If there is another way to do this, better I mean, pls let me know?
3) Is the Jersey Client the only way
4) How can I get EntityManager and call the rest service straight from
filter without Jersey Client?
Thanks, Sami

No comments:

Post a Comment