NoClassDefFoundError org / apache / cxf / jaxrs / client / WebClient

时间:2015-01-10 00:38:40

标签: web-services rest cxf

我是CXF网络服务的新手。我需要写一个Rest Client。我正在

 java.lang.NoClassDefFoundError: org/apache/cxf/jaxrs/client/WebClient
 com.test.ws.CXFWebServiceConnector.get(CXFWebServiceConnector.java:21)
 com.test.ws.SimpleServlet.doGet(SimpleServlet.java:29)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
 root cause

 java.lang.ClassNotFoundException: org.apache.cxf.jaxrs.client.WebClient
 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
 com.test.ws.CXFWebServiceConnector.get(CXFWebServiceConnector.java:21)
 com.test.ws.SimpleServlet.doGet(SimpleServlet.java:29)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)

这不是一个maven项目。在我的类路径中添加了以下jar。要获取NoClassDefinition异常,我错过了任何其他库吗?

阿布德拉核-0.4.0-incubating.jar

阿布德拉的扩展-主0.4.0-incubating.jar

阿布德拉-I18N-0.4.0-incubating.jar

阿布德拉解析器-0.4.0-incubating.jar

公理-API-1.2.7.jar

公理-IMPL-1.2.7.jar

CXF-2.2.6.jar

的geronimo激活-1.1.jar

Geronimo的注释-1.0.jar

JAXB-API-2.1.jar

JAXB-IMPL-2.1.12.jar

JRA-1.0-α-4.jar

JSR311-API-1.0.jar

neethi-2.0.4.jar

WSS4J-1.5.8.jar

wstx-ASL-3.2.9.jar

XML的旋转变压器1.2.jar

XMLSchema的1.4.5.jar

这是我访问Restful Web服务的方式

public String get(String url) {
    String response = null;
    WebClient client = WebClient.create(url);
    client.accept(MediaType.APPLICATION_JSON);
    HTTPConduit conduit = WebClient.getConfig(client).getHttpConduit();
    HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
    httpClientPolicy.setAllowChunking(false);
    conduit.setClient(httpClientPolicy);
    TLSClientParameters clientParameters = new TLSClientParameters();
    clientParameters.setDisableCNCheck(true);
    clientParameters.setSecureSocketProtocol("TLS");
    conduit.setTlsClientParameters(clientParameters);
    try {
        response = client.get(String.class);

    } finally {
        if (client != null) {
            client.reset();
        }
    }

    return response;
}

2 个答案:

答案 0 :(得分:1)

在项目根目录中使用以下命令来检测需要哪些依赖项:

mvn dependency:tree -Dincludes=org.apache.cxf

答案 1 :(得分:0)

WebClient是cxf-rt-frontend-jaxrs.jar的一部分。我猜你没有与cxf JAXRS相关的罐子。