No such method Error when accessing JAX RS CXF web

2019-07-22 06:36发布

I am getting no such method error when I try to access my JAX RS CXF web service. These are the jars that I have added in the build path:

cxf-core-3.1.2.jar
cxf-rt-frontend-jaxrs-3.1.2.jar
cxf-rt-rs-client-3.1.2.jar
cxf-rt-rs-extension-providers-3.1.2.jar
cxf-rt-rs-extension-search-3.1.2.jar
cxf-rt-transports-http-3.1.2.jar
httpclient-4.4.1.jar
httpcore-4.4.1.jar
httpcore-nio-4.4.1.jar
javax.ws.rs-api-2.0.1.jar
jcl-over-slf4j-1.7.12.jar
jettison-1.3.7.jar
spring-aop-4.1.6.RELEASE.jar
spring-beans-4.1.6.RELEASE.jar
spring-context-4.1.6.RELEASE.jar
spring-core-4.1.6.RELEASE.jar
spring-expression-4.1.6.RELEASE.jar
spring-web-4.1.6.RELEASE.jar
stax2-api-3.1.4.jar
xml-resolver-1.2.jar
xmlbeans-2.6.0.jar
xmlschema-core-2.2.1.jar    
xmlsec-2.0.5.jar

J2EE version is 2.3, Application server is weblogic 12

I know it is some jar issue. But I am not able to resolve it. This is the error thrown:

java.lang.NoSuchMethodError: javax.ws.rs.NotFoundException.validate(Ljavax/ws/rs/core/Response;Ljavax/ws/rs/core/Response$Status;)Ljavax/ws/rs/core/Response;
    at javax.ws.rs.NotFoundException.(NotFoundException.java:126)
    at org.apache.cxf.jaxrs.utils.SpecExceptions.toNotFoundException(SpecExceptions.java:89)
    at org.apache.cxf.jaxrs.utils.ExceptionUtils.toNotFoundException(ExceptionUtils.java:122)
    at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:169)

1条回答
孤傲高冷的网名
2楼-- · 2019-07-22 07:21

The class and method might be present and conflicting with any of the weblogic jars

In your weblogic.xml present in WEB-INF, add javax.ws.rs.* package to instruct weblogic to prefer the package from your WAR classpath as shown below,

<package-name>javax.ws.rs.*</package-name>

Sample weblogic.xml:

    <?xml version="1.0" encoding="UTF-8"?>  
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsdhttp://xmlns.oracle.com/weblogic/weblogic-web-apphttp://xmlns.oracle.com/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd">
    <container-descriptor>  
        <prefer-application-packages>  
            <package-name>com.fasterxml.jackson.*</package-name>
            <package-name>org.eclipse.persistence.*</package-name>
            <package-name>javax.ws.rs.*</package-name>
        </prefer-application-packages>  
    </container-descriptor>  
</weblogic-web-app>
查看更多
登录 后发表回答