Getting HTTP Error 500 Internal Server Error Using Jersey

Asked

Viewed 972 times

0

I’m studying REST. I’m using jersey to create a service RESTful. I came across a problem trying to create a service that would return an object json. I am using a client (java) to request the service.

The service is 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 mistake 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)
  • Where your app is hosted?

  • This is wrong </web-app ...>&#xA;<display-name>cinemak-service</display-name>? Would not be <web-app ...>&#xA;<display-name>cinemak-service</display-name>?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.