Search code examples
htmlajaxresteasywildfly-10

405 Method not allowed using Resteasy and ajax


I am facing an issue while login . Registration is working fine. Tech stack - HTML/AJAX/JQuery->Resteasy (Wildfly 10.1.0 Final)

I have the url - https://www.test.com/login.html - (actual URL name is modified)

When I am submitting the form with method type = "POST", it always throws, 405 Method not allowed.

Below is the section of the code:

submitHandler: function(form) { // fires only when form is valid
    var loginData  = formJSONLoginData();
    $.ajax({
        url:"https://"+getUrl()+"/curAuthService/curAuth/authenticateUser/v1",
        type : "POST",
        dataType : "json",
        contentType: "application/json",
        data: loginData,
        success : function(response) {
            },
        error: function( xhr, status, error ){
            }
    }); 
return false;
},

And the Rest API is below:

@Path("/curAuth")
public class FHAuthResource {
    @POST
    @Path("/authenticateUser/v1")
    @Produces("application/json")
    @Consumes("application/json")
    public String authenticateUser( AuthVO authVO ) {
    }
}

It would be great help if someone can help/advice on where I am going wrong.

Registration is in similar format and it works fine.


Solution

  • Ultimate stupid mistake. Missed out "extends Application" for the Application file which is required for resteasy.