[英]Can you import Jersey custom ExceptionMappers from a .jar war file into a .war file?
運行JUnit測試時,我一直收到此錯誤。 僅當我嘗試將Jersey自定義ExceptionMappers從.jar文件導入到.war文件時,才會發生這種情況。
我知道映射器在.war文件中時可以正常工作,但是我有兩個單獨的模塊需要它們,並且不希望復制映射器以使每個模塊中都有一個。
[RxCachedThreadScheduler-1] ERROR
c.s.j.s.container.ContainerResponse - The exception contained within
MappableContainerException could not be mapped to a response, re
throwing to the HTTP container
search.internal.datapower.InvalidUserInfoException:
WRRC003: The required X-UserInfo header was missing from the
request.
有誰知道如何從.jar文件導入ExceptionMapper?
是的,您可以這樣做。
但是,您似乎尚未在Jersey上為search.internal.datapower.InvalidUserInfoException
注冊異常映射器,或者您需要捕獲此異常並在資源方法中對其進行處理。
您可以通過創建一個實現ExceptionMapper<InvalidUserInfoException>
的Jersey @Provider
類來完成此操作。
有關更多詳細信息,請參見此處的示例7.6: https : //jersey.java.net/documentation/latest/representations.html#d0e6665
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.