4finance / boot-microservice

Common classes for microservices set up on Spring Boot.
Apache License 2.0
85 stars 41 forks source link

NPE in CorrelationID from Swagger #19

Closed marcingrzejszczak closed 9 years ago

marcingrzejszczak commented 9 years ago

I shot this request

[
    {
        "created_at": "Sat Jul 26 09:38:57 +0000 2014",
        "id": 492967299297845248,
        "id_str": "492967299297845248",
        "text": "Gonna see you at Warsaw",
        "place":
        {
            "attributes":{},
            "bounding_box":
            {
                "coordinates":
                    [[
                        [-77.119759,38.791645],
                        [-76.909393,38.791645],
                        [-76.909393,38.995548],
                        [-77.119759,38.995548]
                    ]],
                "type":"Polygon"
            },
            "country":"United States",
            "country_code":"US",
            "full_name":"Washington, DC",
            "id":"01fbe706f872cb32",
            "name":"Washington",
            "place_type":"city",
            "url": "http://api.twitter.com/1/geo/id/01fbe706f872cb32.json"
        }
    }
]

to /api/{pairId} endpoint

with pairID equal to 13 and got 500 back and in logs this:

2014-12-04 12:14:35.473+0100 | DEBUG | dc3414b6-0a26-4422-8ff4-a4b22a667281 | http-nio-8095-exec-9 | c.o.i.w.r.c.RestTemplate | POST request for "http://localhost:10000/1" resulted in 200 (OK)
2014-12-04 12:14:35.478+0100 | DEBUG | dc3414b6-0a26-4422-8ff4-a4b22a667281 | http-nio-8095-exec-9 | c.o.t.p.e.PlacePropagatingWorker | Sent json [[

                {
                    "pair_id" : 1,
                    "tweet_id" : "492967299297845248"

                        ,"place" :
                        {
                            "name":"Washington",
                            "country_code": "US"
                        },
                        "probability" : "2",
                        "origin" : "twitter_place_section"

                }

                   ]] to collerator
2014-12-04 12:14:35.484+0100 | DEBUG | dc3414b6-0a26-4422-8ff4-a4b22a667281 | http-nio-8095-exec-9 | c.o.i.w.c.CorrelationIdAspect | Wrapping callable with correlation id [dc3414b6-0a26-4422-8ff4-a4b22a667281]
2014-12-04 12:14:35.499+0100 | DEBUG | dc3414b6-0a26-4422-8ff4-a4b22a667281 | http-nio-8095-exec-6 | c.o.i.w.c.CorrelationIdFilter | Found correlationId in response: dc3414b6-0a26-4422-8ff4-a4b22a667281
2014-12-04 12:14:35.511+0100 | ERROR |  | http-nio-8095-exec-6 | o.a.c.c.C.[.[.[.[dispatcherServlet] | Servlet.service() for servlet dispatcherServlet threw exception
java.lang.NullPointerException: null
    at com.ofg.infrastructure.web.correlationid.CorrelationIdAspect$_wrapWithCorrelationId_closure1.doCall(CorrelationIdAspect.groovy:68) ~[micro-infra-spring-base-0.7.1.jar:na]
    at com.ofg.infrastructure.web.correlationid.CorrelationIdAspect$_wrapWithCorrelationId_closure1.call(CorrelationIdAspect.groovy) ~[micro-infra-spring-base-0.7.1.jar:na]
    at com.ofg.infrastructure.correlationid.CorrelationCallable.call(CorrelationCallable.groovy:33) ~[micro-infra-spring-base-0.7.1.jar:na]
    at org.springframework.web.context.request.async.WebAsyncManager$4.run(WebAsyncManager.java:322) ~[spring-web-4.0.7.RELEASE.jar:4.0.7.RELEASE]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_05]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_05]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_05]
2014-12-04 12:14:35.513+0100 | ERROR |  | http-nio-8095-exec-6 | o.a.c.c.C.[.[.[.[dispatcherServlet] | Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
java.lang.NullPointerException: null
    at com.ofg.infrastructure.web.correlationid.CorrelationIdAspect$_wrapWithCorrelationId_closure1.doCall(CorrelationIdAspect.groovy:68) ~[micro-infra-spring-base-0.7.1.jar:na]
    at com.ofg.infrastructure.web.correlationid.CorrelationIdAspect$_wrapWithCorrelationId_closure1.call(CorrelationIdAspect.groovy) ~[micro-infra-spring-base-0.7.1.jar:na]
    at com.ofg.infrastructure.correlationid.CorrelationCallable.call(CorrelationCallable.groovy:33) ~[micro-infra-spring-base-0.7.1.jar:na]
    at org.springframework.web.context.request.async.WebAsyncManager$4.run(WebAsyncManager.java:322) ~[spring-web-4.0.7.RELEASE.jar:4.0.7.RELEASE]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_05]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_05]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_05]

the code is available here:

https://github.com/4finance/boot-microservice/tree/modelForTweets

what I did was that instead of String body I introduced a model (so that Swagger shows it in a nice way)

nurkiewicz commented 9 years ago

See https://github.com/4finance/boot-microservice/commit/020b16a460a0c46fd1f9ab4e0985da8708e255f5, it was an error in boot-microservice itself, not micro-infra-spring. However I get:

java.lang.IllegalStateException: No value for key [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean@12bdda3a] bound to thread [XNIO-1 I/O-1]

From Undertow in async context, can you check?

marcingrzejszczak commented 9 years ago

I have no idea what that is - what has Undertow to do with this anyway? I thought it's running on Jetty?

mchmielarz commented 9 years ago

After upgrading micro-infra-spring dependency to version 0.8.7 there is no such problem happening.