Search code examples
javarestseamseam2

How to resolve an exception related to rest api POST request?


I have a call from angular 5 app:

const httpOptions = {
    headers: new HttpHeaders({ 'Accept': 'application/json', 'Content-Type': 'application/json' })
};
...
 addTrip(trip: Trip): Observable<any> {
    return this.http.post(`${this.baseUrl}/Trips/Trip`, JSON.stringify(trip), httpOptions);
  }

The java code is seam component which use rest api:

@Name("tripFacadeREST")
@Scope(ScopeType.EVENT)
@Path("Trips")
public class TripFacadeREST {

    @In private TripDaoHibernateImpl tripDao;

...

@POST
@Path("Trip")
@Consumes("application/json")
public Response addNewTrip(Trip newTrip) {
    tripDao.addTrip(newTrip);
    return Response.ok().entity("trip added successfully").build();
}

I get an exception when trying to send POST request to the server (tomcat - java 7):

java.lang.AbstractMethodError: javax.ws.rs.core.Response.getStatusInfo()Ljavax/ws/rs/core/Response$StatusType

relevant jars

tomcat log:

0:0:0:0:0:0:0:1 - - [23/May/2018:16:07:12 +1000] "OPTIONS /jboss-seam/seam/resource/rest/Trips/Trip HTTP/1.1" 200 - 0:0:0:0:0:0:0:1 - - [23/May/2018:16:07:12 +1000] "POST /jboss-seam/seam/resource/rest/Trips/Trip HTTP/1.1" 500 1386

I can't get this call to work, I have tried also PUT but I understand that put is for update and because the id is created in the server side I've used post. Any idea how to solve this problem? (I was able to use GET annotation in the same service with no issues).


Solution

  • This problem was solved by update the resteasy jars to version 2.1.0. For anyone encountered similar problem. Seam 2.1.2 with resteasy 2.1.