2017-04-17 45 views
3

我已經升級了我的項目中的Dropwizard,並在運行單元測試時遇到了問題,儘管服務啓動正常,所有API都正常運行,問題僅在運行測試時纔會出現,我的版本:下面沒有ServiceLocatorGenerator安裝在Dropwizard中運行測試時出錯

Dropwizard: 1.1.0 
Jersey: 2.25.1 
Guice: 4.1.0 
hk2-api: 2.5.0-b36 
hk2-utils: 2.5.0-b36 
javax.ws.rs-api : 2.1-m05 

是錯誤,當我運行 「MVN測試」

java.lang.RuntimeException: java.lang.ClassNotFoundException: Provider org.glassfish.jersey.internal.RuntimeDelegateImpl could not be instantiated: java.lang.IllegalStateException: It appears there is no ServiceLocatorGenerator installed. 
at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:153) 
at javax.ws.rs.ext.RuntimeDelegate.getInstance(RuntimeDelegate.java:121) 
at javax.ws.rs.core.Response$ResponseBuilder.newInstance(Response.java:848) 
at javax.ws.rs.core.Response.status(Response.java:590) 
at javax.ws.rs.core.Response.status(Response.java:601) 
at javax.ws.rs.core.Response.ok(Response.java:622) 
...... ** some more lines here ** 
Caused by: java.lang.ClassNotFoundException: Provider org.glassfish.jersey.internal.RuntimeDelegateImpl could not be instantiated: java.lang.IllegalStateException: It appears there is no ServiceLocatorGenerator installed. 
at javax.ws.rs.ext.FactoryFinder.newInstance(FactoryFinder.java:123) 
at javax.ws.rs.ext.FactoryFinder.find(FactoryFinder.java:226) 
at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:137) 
+0

https://github.com/dropwizard/dropwizard/issues/1772和https://github.com/HubSpot/dropwizard-guice/issues/95 - 看起來像一些依賴性集成問題。 – zloster

+0

其實在'jersey2-guice'項目中有一個待解決問題的請求。看到這個評論:https://github.com/Squarespace/jersey2-guice/pull/39#issuecomment-274853295 – zloster

回答