NoClassDefFoundError:带有Cpacke CXF 3.1.10的LibertyProfile 16中的org / apache / cxf / phase / PhaseInterceptorChain

时间:2017-03-23 21:51:57

标签: websphere cxf websphere-liberty

我已编写以下代码来拦截传入的请求。

@Provider
public class RequestInterceptor implements  ReaderInterceptor {
    @Override
    public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException {
        Message message = PhaseInterceptorChain.getCurrentMessage();
        OperationResourceInfo cri = message.getExchange().get(OperationResourceInfo.class);
        return null;
    }
}

我正在使用Apache CXF 3.1.10和Liberty Profile 16。

在我的server.xml中,启用了以下功能:

<featureManager>
    <feature>webProfile-7.0</feature>
    <feature>localConnector-1.0</feature>
</featureManager>

以下是我的pom.xml文件:

<repositories>
        <repository>
            <id>prime-repo</id>
            <name>PrimeFaces Maven Repository</name>
            <url>http://repository.primefaces.org</url>
            <layout>default</layout>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>7.0</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>6.0</version>
        </dependency>
        <dependency>
            <groupId>org.primefaces.themes</groupId>
            <artifactId>all-themes</artifactId>
            <version>1.0.10</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.5</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.12</version>
        </dependency>

        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.6</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>20.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils -->
        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.9.3</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/joda-time/joda-time -->
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>2.9.6</version>
        </dependency>

        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxrs</artifactId>
            <version>3.1.10</version>
        </dependency>


    </dependencies>

当我运行应用程序时,我收到以下错误:

[INFO    ] Setting the server's publish address to be /rest/
[INFO    ] SRVE0242I: [TestApp] [/TestApp] [javax.ws.rs.core.Application]: Initialization successful.
[ERROR   ] SRVE0777E: Exception thrown by application class 'framework.rest.interceptors.RequestInterceptor.aroundReadFrom:32'
java.lang.NoClassDefFoundError: org/apache/cxf/phase/PhaseInterceptorChain
    at framework.rest.interceptors.RequestInterceptor.aroundReadFrom(RequestInterceptor.java:32)
    at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBodyReader(JAXRSUtils.java:1356)
    at [internal classes]

如果我在没有拦截器代码的情况下运行我的应用程序,那么它的运行就好了。

1 个答案:

答案 0 :(得分:1)

您的应用程序中是否包含cxf-rt-frountend-jaxrs-x.x.x.jarPhaseInterceptorChain.class位于cxf-core-x.x.x.jar。也许尝试在.war的lib目录中包含所有cxf jar。