我們最近從服務器和客戶端上的Jersey 1.x升級到Jersey 2.22.1。我們現在看到間歇性地澤西島將收到兩個請求。澤西島資源接收到澤西島客戶端的重複請求
- 通過間歇性我的意思是每幾千個請求中的每一個。
- 我們從未遇到過使用Jersey 1.x的這個問題。
- 我不清楚這是否是客戶端或服務器端的問題。
- 在客戶端日誌僅示出了一個單 POST請求和響應(見下文代碼段)
- 在服務器側的日誌顯示 POST請求和響應(見下文代碼段)
我可以通過在此客戶端POST請求上循環數千次來重現它。每個請求都會發送一個唯一的「名稱」,並保存在服務器上。我知道我收到了重複的請求,當我得到一個獨特的約束違規試圖堅持相同的'名稱'兩次。我排除了代碼的其他部分,因爲日誌確認澤西島正在接收兩個POST請求的同一'名稱'
我已啓用服務器上的org.glassfish包中的跟蹤日誌記錄,並在客戶端上註冊了LoggingFilter() 。
客戶端只顯示1個POST請求和響應:
Jun 21, 2016 6:02:51 PM org.glassfish.jersey.filter.LoggingFilter log
INFO: 8291 * Sending client request on thread main
8291 > POST http://localhost:9797/my-webapp/v1/data-feeds/
8291 > Accept: application/json
8291 > Content-Type: application/json
Jun 21, 2016 6:02:51 PM org.glassfish.jersey.filter.LoggingFilter log
INFO: 8291 * Client response received on thread main
8291 < 200
8291 < Cache-Control: no-cache, no-store, max-age=0, must-revalidate
8291 < Content-Length: 181
8291 < Content-Type: application/json
8291 < Date: Wed, 22 Jun 2016 00:02:51 GMT
8291 < Expires: 0
8291 < Pragma: no-cache
8291 < Server: Apache-Coyote/1.1
8291 < Set-Cookie: JSESSIONID=CFF556E7FCDB5B1F644BA04603364DFD; Path=/my-webapp/; HttpOnly
8291 < X-Content-Type-Options: nosniff
8291 < X-Frame-Options: DENY
8291 < X-XSS-Protection: 1; mode=block
服務器顯示了相同的名字'兩個職位:
Jun 21, 2016 6:02:51 PM org.glassfish.jersey.filter.LoggingFilter log
INFO: 8293 * Server has received a request on thread http-bio-9797-exec-21
8293 > POST http://localhost:9797/my-webapp/v1/data-feeds/
8293 > accept: application/json
8293 > authorization: Basic YWRtaW46bmltZGE=
8293 > connection: keep-alive
8293 > content-length: 181
8293 > content-type: application/json
8293 > host: localhost:9797
8293 > user-agent: Jersey/2.22.1 (HttpUrlConnection 1.8.0_31)
2016-06-21 18:02:51,964 [INFO] [c.m.c.r.r.MyResource] Received POST request /data-feeds with args [FeedData{name='pool4146'}]
Jun 21, 2016 6:02:51 PM org.glassfish.jersey.filter.LoggingFilter log
INFO: 8294 * Server has received a request on thread http-bio-9797-exec-97
8294 > POST http://localhost:9797/my-webapp/v1/data-feeds/
8294 > accept: application/json
8294 > authorization: Basic YWRtaW46bmltZGE=
8294 > connection: keep-alive
8294 > content-length: 181
8294 > content-type: application/json
8294 > host: localhost:9797
8294 > user-agent: Jersey/2.22.1 (HttpUrlConnection 1.8.0_31)
2016-06-21 18:02:51,978 [INFO] [c.m.c.r.r.MyResource] Received POST request /data-feeds with args [FeedData{name='pool4146'}]
Jun 21, 2016 6:02:51 PM org.glassfish.jersey.filter.LoggingFilter log
INFO: 8293 * Server responded with a response on thread http-bio-9797-exec-21
8293 < 200
8293 < Content-Type: application/json
Jun 21, 2016 6:02:51 PM org.glassfish.jersey.filter.LoggingFilter log
INFO: 8294 * Server responded with a response on thread http-bio-9797-exec-97
8294 < 200
8294 < Content-Type: application/json
讓我知道是否有任何其他配置信息可能在這裏相關。我們正在使用Tomcat 7.x和Jackson進行序列化/反序列化
嗨,你有這個解決方案...面臨同樣的問題,我使用球衣1.4罐 – user1397770
@ user1397770沒有解決方案,但澤西1.x是非常不同的。我正在使用2.x – Justin
@Jinging只是想知道升級jersey jar會幫助或不在這...看看我的日誌http://stackoverflow.com/questions/39386268/jax-rs-rest- servlet-error – user1397770