Websphere NoClassDefFoundError:org/apache/cxf/phase/PhaseInterceptorChain,位于LibertyProfile 16中,带有Cpacke cxf 3.1.10
我编写了以下代码来拦截传入的请求Websphere NoClassDefFoundError:org/apache/cxf/phase/PhaseInterceptorChain,位于LibertyProfile 16中,带有Cpacke cxf 3.1.10,websphere,cxf,websphere-liberty,Websphere,Cxf,Websphere Liberty,我编写了以下代码来拦截传入的请求 @Provider public class RequestInterceptor implements ReaderInterceptor { @Override public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException { Message message = PhaseI
@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
在my server.xml中,启用了以下功能:
<featureManager>
<feature>webProfile-7.0</feature>
<feature>localConnector-1.0</feature>
</featureManager>
如果我运行的应用程序没有拦截器代码,那么它运行得很好。您的应用程序中是否已打包了
cxf-rt-frountend-jaxrs-x.x.x.jar
PhaseInterceptorChain.class
位于cxf-core-x.x.x.jar
中。也许可以尝试将所有cxf JAR包含在.war的lib目录中。这是由于Liberty的cxf impl与您在应用程序中捆绑的cxf impl之间的类加载冲突造成的。由于webProfile-7.0
功能包括jaxrs-2.0
功能(及其API),您可以不在应用程序中打包CXF实现吗?它仍然会给我带来错误:您知道Liberty的CXF impl版本号吗?这取决于您确切的Liberty版本,但您可以签入${wlp.install.dir}/lib/com.ibm.ws.org.apache.cxf rt core.X.X.jar
查看liberty对我的liberty使用的版本。它的com.ibm.ws.org.apache.cxf-rt-core.2.6.2_1.0.14I从war文件中删除了jar cxf jar,但仍然得到了相同的错误…我还能做些什么吗?
<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]