我已经实现了与Jersey 2.4的API集成,但是尝试启动tomcat时遇到问题
SEVERE: Servlet.service() for servlet [Jersey REST Service] in context with path [] threw exception [Servlet execution threw an exception] with root cause
java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;
at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:286)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:218)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
也许在使用UriBuilder时会发生冲突,这在org.apache.cxf.jaxrs.impl中的javax.ws.rs.core和UriBuilderImpl中已引用。如果我将WEB-INF \ lib中的cxf-2.6.0.jar重命名为zxf-2.6.0.jar(最后加载),则一切正常。
我该如何优雅地解决该问题?
最佳答案
是的,这绝对是UriBuilder冲突,当您重命名cxf jar时,您将更改查找顺序以使正确的版本排在第一位。我建议使用Maven进行依赖管理,在该管理中,可以将exclude标签用于不需要的子依赖。
关于java - Jersey 2.4和CXF 2.6,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20286807/