2016-07-14 58 views
0

運行我的JUnit測試時,我不斷收到此錯誤。只有當我嘗試將Jersey自定義ExceptionMappers從.jar文件導入到我的.war文件時纔會出現這種情況。可以將Jersey自定義的ExceptionMappers從.jar war文件導入到.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?

+0

我很困惑,你嘗試包括球衣罐例外映射器到你的戰爭應用程序? –

回答

0

是的,你可以做到這一點。

但是,您似乎尚未在Jersey註冊異常映射器search.internal.datapower.InvalidUserInfoException,或者您需要捕獲此異常並在您的資源方法中處理它。

您可以通過創建一個實現ExceptionMapper<InvalidUserInfoException>的Jersey @Provider類來實現此目的。

更多詳情,參見實例7.6位置:https://jersey.java.net/documentation/latest/representations.html#d0e6665