Obtaining HTTP Error 500 Internal Server Error Using Jersey

0

I'm studying REST . I'm using jersey to create a RESTful services. I encountered a problem when trying to create a service that would return a json object. I'm using a client (java) to make the request to the service.

The service looks like this:

    @Path("/profile")
    public class ProfileDataService {

        @GET
        @Produces(MediaType.APPLICATION_JSON)
        public ProfileBean getProfileData() {
            ProfileBean profile = fillProfileInstance();

            return profile;
        }
}

web.xml:

    </web-app ...>
<display-name>cinemak-service</display-name>
    <servlet>
        <servlet-name>Jersey REST Service</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <!-- Register resources and providers under com.vogella.jersey.first package. -->
        <init-param>
            <param-name>jersey.config.server.provider.packages</param-name>
            <param-value>com.cinemak.service.services</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Jersey REST Service</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>
</web-app>

client:

public static void main(String[] args) {
        ClientConfig config = new ClientConfig();
        Client client = ClientBuilder.newClient(config);

        WebTarget target = client.target(getURIBase());

        System.out.println(target.path("rest").path("profile").request().accept(MediaType.APPLICATION_JSON).get(String.class));

    }

    //Build and returns the specific uri base for cinemak-service
    private static URI getURIBase() {
        return UriBuilder.fromUri("http://localhost:8080/cinemak-service").build();
    }

The error I get ...

Exception in thread "main" javax.ws.rs.InternalServerErrorException: HTTP 500 Internal Server Error
    at org.glassfish.jersey.client.JerseyInvocation.convertToException(JerseyInvocation.java:1002)
    at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:799)
    at org.glassfish.jersey.client.JerseyInvocation.access$500(JerseyInvocation.java:91)
    at org.glassfish.jersey.client.JerseyInvocation$2.call(JerseyInvocation.java:687)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:444)
    at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:683)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:411)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:307)
    at com.cinemak.client.ProfileDataClient.main(ProfileDataClient.java:21)
    
asked by anonymous 05.05.2015 / 21:45

0 answers