Search code examples
web-servicesrestcxf

CXF-RS throwing No operation matching request path /create is found,


I developed the JAX-RS webservices using CXF framework and i deployed in Jboss6. While i try to access the application using the following URL http://localhost:8080/UPCServiceLayer/services/upcLineOfBusiness/create from my HTML page (using POST method only) i am getting following error in the server console

No operation matching request path /create is found,

The following is my cxf.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:jaxrs="http://cxf.apache.org/jaxrs"
    xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd 
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
    <import resource="classpath:META-INF/cxf/cxf.xml" />
    <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
    <import  resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml"/>
    <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
    <import resource="classpath:../upc-spring-dao.xml" />
    <jaxrs:server id="upcLineOfBusinessRestServiceServer" address="/upcLineOfBusiness">
        <jaxrs:serviceBeans>
            <ref bean="upcLineOfBusinessRestService" />
        </jaxrs:serviceBeans>
    </jaxrs:server>
    <bean id="upcLineOfBusinessRestService"
        class="com.tecnotree.upc.services.restservices.impl.UpcLineOfBusinessRestServiceImpl">
        <property name="upcLineOfBusinessDao">
            <ref bean="upcLineOfBusinessDao" />
        </property>
        <property name="upcUserDao">
            <ref bean="upcUserDao" />
        </property>
    </bean>
</beans>

The following is my resource class

@Path("/")
public classUpcLineOfBusinessRestService {
    @POST
    @ConsumeMime("application/xml")
    @ProduceMime("application/xml")
    @Path("/create")
    public UpcLineOfBusinessEntity createUpcLineOfBusinessEntity(
            UpcLineOfBusinessEntity upcLineOfBusinessEntity)
            throws GenericUpcException

and i declared CXF servlet in my web.xml file also.

 <servlet>
            <servlet-name>CXFServlet</servlet-name>
            <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>CXFServlet</servlet-name>
            <url-pattern>/services/*</url-pattern>
        </servlet-mapping>

Please help me


Solution

  • I'm somewhat surprised to see the @ProduceMime and @ConsumeMime annotations there; the current style is to use @Produces and @Consumes instead (from the JAX-RS standard). This is important, because CXF uses the content type annotations as part of its method matching process, which could make things fail to match (and hence give a confusing error message).

    (Also, are you sure you're POSTing “application/xml” to the server? Get that wrong and you'll also have no-match errors. Try turning up the level of logging on the server to see what its actually trying to do during matching; that helps with tracking down this sort of problem but can't be on by default as it is very chatty.)