4

I have seen in tutorial (Jersey) that there is possibility to pass in JAX-RS @PathParam of type Long.

But when I have tried to do this with RESTEasy I'm getting error:

 21:50:32,353 WARN  [org.jboss.resteasy.core.ExceptionHandler] (default task-15) failed to execute: javax.ws.rs.NotSupportedException: Could not find message body reader for type: long of content type: */*
    at org.jboss.resteasy.core.interception.ServerReaderInterceptorContext.throwReaderNotFound(ServerReaderInterceptorContext.java:52)
    at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.getReader(AbstractReaderInterceptorContext.java:73)

I tested it with Integer, but it also don't work...

22:14:45,590 WARN  [org.jboss.resteasy.core.ExceptionHandler] (default task-18) failed to execute: javax.ws.rs.NotSupportedException: Could not find message body reader for type: class java.lang.Integer of content type: */*
at org.jboss.resteasy.core.interception.ServerReaderInterceptorContext.throwReaderNotFound(ServerReaderInterceptorContext.java:52)

Moreover I am trying to take this ID value as String and then convert it to Long using Long.valueOf(String s) or Long.parseLong(String s) and in both cases I am getting error

Caused by: java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Long.parseLong(Long.java:601)
at java.lang.Long.parseLong(Long.java:631)
at pl.salonea.jaxrs.UserAccountResource.getUserAccount(UserAccountResource.java:41)

It's the code of my web service resource method:

@GET
@Path("/{userId}")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public UserAccount getUserAccount(@PathParam("userId") String userId) {

    return userAccountFacade.find(Long.parseLong(userId));
}

SOLVED

I have bad import not import javax.ws.rs.PathParam;, but something from web sockets PathParam... I just relay on IntelliJ automatic imports and haven't seen that it was wrong.

Michał Ziobro
  • 10,759
  • 11
  • 88
  • 143

0 Answers0