[英]Error in deployment on JBoss - Swagger for Java Guice Jersey
我正在嘗試將Swagger與我的Java REST服務集成以生成文檔。 我正在使用Jersey-帶有Dependency Injection的REST服務的向導。 Jersey版本是1.18.2。 我正在使用JBOSS 5.1.2進行部署。 我們的設置與示例項目略有不同。 我們使用Jersey作為偵聽器,而不是servlet。 我的web.xml看起來像這樣-
com.mitchell.services.estimatehelper.ioc.GuiceServletConfig
<filter>
<filter-name>guiceFilter</filter-name>
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>guiceFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
我有一個像這樣的GuiceServletConfig-
com.mitchell.services.estimatehelper.ioc.GuiceServletConfig
<filter>
<filter-name>guiceFilter</filter-name>
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>guiceFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
AppInjector如下-
公共類AppInjector擴展了ServletModule {
protected void configureServlets() {
bind(ServletContainer.class).in(Singleton.class);
final Map<String, String> params = new HashMap<String, String>();
params.put("com.sun.jersey.api.json.POJOMappingFeature", "true");
params.put("javax.ws.rs.Application", Application.class.getName());
params.put("jersey.config.server.wadl.disableWadl", "true");
ReflectiveJaxrsScanner scanner = new ReflectiveJaxrsScanner();
scanner.setResourcePackage(getClass().getPackage().getName());
ScannerFactory.setScanner(scanner);
bind(EstimateController.class);
bind(EstimateHelper.class)
.to(EstimateHelperImpl.class);
serve("/*").with(GuiceContainer.class, params);
}
}
當我嘗試部署它時,掃描儀將引發以下異常
2014-12-22 12:58:40,573錯誤[STDERR](RMI TCP Connection(2)-127.0.0.1)SLF4J:slf4j-api 1.6.x(或更高版本)與此綁定不兼容。 2014-12-22 12:58:40,573錯誤[STDERR](RMI TCP Connection(2)-127.0.0.1)SLF4J:您的綁定版本為1.5.5或更早版本。 2014-12-22 12:58:40,573錯誤[STDERR](RMI TCP Connection(2)-127.0.0.1)SLF4J:將綁定升級到版本1.6.x。 或2.0.x 2014-12-22 12:58:40,573錯誤[org.apache.catalina.core.ContainerBase。[jboss.web]。[localhost]。[/ estimate-helper-rs-1.0.0]]( RMI TCP Connection(2)-127.0.0.1)向上下文com.mitchell.services.estimatehelper.ioc.GuiceServletConfig java.lang.NoSuchMethodError:org.slf4j.impl.StaticLoggerBinder.getSingleton()Lorg的偵聽器實例發送上下文初始化事件/ slf4j / impl / StaticLoggerBinder; 在org.slf4j.LoggerFactory.bind(LoggerFactory.java:128)在org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:108)在org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:279)在org.slf4j。 org.slf4j的LoggerFactory.getLogger(LoggerFactory.java:252)com.wordnik.swagger.jaxrs.config.ReflectiveJaxrsScanner。(ReflectiveJaxrsScanner.scala:21)的org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:265)的com.mitchell。 services.estimatehelper.ioc.AppInjector.configureServlets(AppInjector.java:30)位於com.google.inject.servlet.ServletModule.configure(ServletModule.java:53)位於com.google.inject.AbstractModule.configure(AbstractModule.java: 59)com.google.inject.spi.Elements.getElements(Elements.java:101)com.google.inject.spi.Elements.getElements(Elements.java:101)處com.google.inject.internal .com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:103)的.InjectorShell $ Builder.build(InjectorShell.java:133)在com.google.inject.Guice.c reateInjector(Guice.java:95)位於com.google.inject.Guice.createInjector(Guice.java:72)位於com.google.inject.Guice.createInjector(Guice.java:62)
在進一步研究之后,我意識到此錯誤是由於JBoss使用的日志記錄庫引起的。 錯誤是將上下文初始化事件發送到com.mitchell.services.estimatehelper.ioc.GuiceServletConfig java.lang.NoSuchMethodError類的偵聽器實例的異常:
有什么我可以解決的嗎? 請幫忙!!
謝謝,SDD
檢查依賴關系,如果您的應用程序。
Swagger-Core使用SLF4J 1.6.3,似乎您具有將其覆蓋到1.5.5或更低版本的依賴項。
如果使用的是maven,則可以使用mvn depdendency:tree
mvn dependency:list
查看有效的依賴mvn dependency:list
並使用mvn depdendency:tree
查看舊版本中的哪個依賴關系。
同樣,如果您使用的是maven,則可以使用<exclusions>
引入它的對象中刪除較舊的SLF4J依賴項,也可以將依賴項顯式添加到您自己的pom.xml中。
如果您使用的是其他構建工具(漸變等),我想他們會使用類似的幫助工具來查看SLF4J的較舊版本來自何處。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.