0

Following is one of the many end points in the project -

import javax.ws.rs.*;

@Path("/some/api")
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.APPLICATION_JSON)
public PanDetails savePan(@FormParam("pan_number") String pan_number,
                          @FormParam("dob") String dob,
                          @Context SecurityContext security)
            throws Exception {

    }

Curl request -

curl --location --request POST 'http://127.0.0.1:8084/service/v2/some/api' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'pan_number=<pan>' \
--data-urlencode 'dob=08/09/<year>'

Getting response -

{
    "timestamp": 1591773545909,
    "status": 404,
    "error": "Not Found",
    "message": "Not Found",
    "path": "/service/v2/some/api"
}

Application logs -

2020-06-10 12:49:05,905 752003 [XNIO-3 task-16] WARN  [WebComponent.java:692] - A servlet request to the URI http://127.0.0.1:8084/service/v2/some/api contains form parameters in the request body but the request body has been consumed by the servlet or a servlet filter accessing the request parameters. Only resource methods using @FormParam will work as expected. Resource methods consuming the request body by other means will not work as expected.
2020-06-10 12:49:05,906 752004 [XNIO-3 task-16] INFO  [LoggingFilter.java:155] - 15 * Server has received a request on thread XNIO-3 task-16
15 > POST http://127.0.0.1:8084/service/v2/some/api
15 > Accept: */*
15 > Accept-Encoding: gzip, deflate, br
15 > Authorization: Bearer <token>
15 > Cache-Control: no-cache
15 > Connection: keep-alive
15 > Content-Length: 40
15 > Content-Type: application/x-www-form-urlencoded
15 > Host: 127.0.0.1:8084
15 > Postman-Token: c233cd0f-4689-4947-aa5e-ecea3b4a49d7
15 > User-Agent: PostmanRuntime/7.25.0

2020-06-10 12:49:05,907 752005 [XNIO-3 task-16] INFO  [LoggingFilter.java:155] - 15 * Server responded with a response on thread XNIO-3 task-16
15 < 404

2020-06-10 12:49:05,910 752008 [XNIO-3 task-16] INFO  [LoggerInterceptor.java:42] - Visitor [j7PvTZWa_O4XUrqXIvZ7xguZcD8D-DlGfORGuhPH] [POST] [/error] [pan_number=<pan>|dob=08/09/<year>|] [1ms] [OK]

It's not like all end points are failing. This end point too was working fine till 2 days back. I played around with jenv for Java versions yesterday. Now, I am running Maven via jenv on command line -

jenv exec mvn install -Denv=live -Dmaven.test.skip=true

So that Java 1.8 is taken.

SandeepanNath:prepaid sandeepan.nath$ jenv exec mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T22:11:47+05:30)
Maven home: /Users/sandeepan.nath/.sdkman/candidates/maven/current
Java version: 1.8.0_20, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.3", arch: "x86_64", family: "mac"

Javax.ws.rs 2.0.1 is being used -

<dependency>
    <groupId>javax.ws.rs</groupId>
    <artifactId>javax.ws.rs-api</artifactId>
    <version>2.0.1</version>
</dependency>

And yes, this is a legacy application, so a lot of dependency inclusions.

Hakan Dilek
  • 2,178
  • 2
  • 23
  • 35
Sandeepan Nath
  • 9,966
  • 17
  • 86
  • 144
  • Where is the port number and context path set? (:8084 and /service/v2) – morsor Jun 10 '20 at 08:34
  • Have you checked to see if there are any errors on the server side? If you don't configure Jersey, any errors will result in a 404. See [here](https://stackoverflow.com/a/36600434/2587435) – Paul Samsotha Jun 14 '20 at 15:29

0 Answers0