Quantcast

Newbie Question: WARNING: No root resource matching request path / has been found.

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Newbie Question: WARNING: No root resource matching request path / has been found.

cxfuser
Hello

I'm trying to access a REST service configured using Spring configuration file. When I access the URL -
http://localhost:8080/cxftest/myService/customer/1, it fails with following error.

WARNING: No root resource matching request path /myService/customer/1 has been found.
Dec 23, 2011 9:46:35 PM org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
WARNING: WebApplicationException has been caught : no cause is available

Also when I tried to acces the home page within Spring Tool Suite (STS), it gives me following error:

WARNING: No root resource matching request path / has been found.
Dec 23, 2011 9:55:05 PM org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
WARNING: WebApplicationException has been caught : no cause is available

My Spring application_context.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: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/jaxrs

http://cxf.apache.org/schemas/jaxrs.xsd"
    default-lazy-init="false">

    <import resource="classpath:META-INF/cxf/cxf.xml" />
    <import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
    <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

    <jaxrs:server id="myService" address="/">
        <jaxrs:serviceBeans>
            <ref bean="serviceImpl" />
        </jaxrs:serviceBeans>
        <jaxrs:extensionMappings>
            <entry key="xml" value="application/xml" />
        </jaxrs:extensionMappings>
    </jaxrs:server>

    <bean id="serviceImpl" class="services.ServiceImpl" />

</beans>


Web.xml
==============================================
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" 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.xsd">

    <display-name>cxftest</display-name>
    <description>CXF REST Example</description>
    <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>

    <context-param>
        <param-name>webAppRootKey</param-name>
        <param-value>cxf.rest.example.root</param-value>
    </context-param>


    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/classes/application-context.xml</param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <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>/*</url-pattern>
    </servlet-mapping>

</web-app>

ServiceImpl.java
=====================================

package services;

import java.io.IOException;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

import model.Customer;

import org.codehaus.jackson.map.ObjectMapper;

@Path("/customer/{id}")
@Produces("application/json")

public class ServiceImpl {

        @GET
        public String getCustomer( @PathParam("id") final String customerId) throws IOException {
                Customer customer = new Customer();
                customer.setName("customer1");
                return javaToJSON(customer);
        }
       
        private String javaToJSON(final Object object) throws IOException {
                ObjectMapper mapper = null;
                mapper = new ObjectMapper();
                return mapper.writeValueAsString(object);
        }
       
}




Thanks for the help
Prakash










Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Newbie Question: WARNING: No root resource matching request path / has been found.

Jeff Wang-2
instead of:
 <jaxrs:server id="myService" address="/">
try
 <jaxrs:server id="myService" address="/myService">

the CXF servlet is matching /*, and your url base is /cxftest (which
is the name of your deployed war, I assume.)  CXF can't find
/myService/customer/1 because you have declared /customer/1 instead.

Jeff

On Fri, Dec 23, 2011 at 8:01 PM, cxfuser <[hidden email]> wrote:

> Hello
>
> I'm trying to access a REST service configured using Spring configuration
> file. When I access the URL -
> http://localhost:8080/cxftest/myService/customer/1, it fails with following
> error.
>
> WARNING: No root resource matching request path /myService/customer/1 has
> been found.
> Dec 23, 2011 9:46:35 PM
> org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
> WARNING: WebApplicationException has been caught : no cause is available
>
> Also when I tried to acces the home page within Spring Tool Suite (STS), it
> gives me following error:
>
> WARNING: No root resource matching request path / has been found.
> Dec 23, 2011 9:55:05 PM
> org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
> WARNING: WebApplicationException has been caught : no cause is available
>
> My Spring application_context.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: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/jaxrs
>
> http://cxf.apache.org/schemas/jaxrs.xsd"
>    default-lazy-init="false">
>
>    <import resource="classpath:META-INF/cxf/cxf.xml" />
>    <import
> resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
>    <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
>
>    <jaxrs:server id="myService" address="/">
>        <jaxrs:serviceBeans>
>            <ref bean="serviceImpl" />
>        </jaxrs:serviceBeans>
>        <jaxrs:extensionMappings>
>            <entry key="xml" value="application/xml" />
>        </jaxrs:extensionMappings>
>    </jaxrs:server>
>
>    <bean id="serviceImpl" class="services.ServiceImpl" />
>
> </beans>
>
>
> Web.xml
> ==============================================
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
> 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.xsd">
>
>    <display-name>cxftest</display-name>
>    <description>CXF REST Example</description>
>    <welcome-file-list>
>    <welcome-file>index.html</welcome-file>
>    <welcome-file>index.htm</welcome-file>
>    <welcome-file>index.jsp</welcome-file>
>    <welcome-file>default.html</welcome-file>
>    <welcome-file>default.htm</welcome-file>
>    <welcome-file>default.jsp</welcome-file>
>  </welcome-file-list>
>
>    <context-param>
>        <param-name>webAppRootKey</param-name>
>        <param-value>cxf.rest.example.root</param-value>
>    </context-param>
>
>
>    <context-param>
>        <param-name>contextConfigLocation</param-name>
>        <param-value>/WEB-INF/classes/application-context.xml</param-value>
>    </context-param>
>
>    <listener>
>
> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
>    </listener>
>
>    <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>/*</url-pattern>
>    </servlet-mapping>
>
> </web-app>
>
> ServiceImpl.java
> =====================================
>
> package services;
>
> import java.io.IOException;
>
> import javax.ws.rs.GET;
> import javax.ws.rs.Path;
> import javax.ws.rs.PathParam;
> import javax.ws.rs.Produces;
>
> import model.Customer;
>
> import org.codehaus.jackson.map.ObjectMapper;
>
> @Path("/customer/{id}")
> @Produces("application/json")
>
> public class ServiceImpl {
>
>        @GET
>        public String getCustomer( @PathParam("id") final String customerId) throws
> IOException {
>                Customer customer = new Customer();
>                customer.setName("customer1");
>                return javaToJSON(customer);
>        }
>
>        private String javaToJSON(final Object object) throws IOException {
>                ObjectMapper mapper = null;
>                mapper = new ObjectMapper();
>                return mapper.writeValueAsString(object);
>        }
>
> }
>
>
>
>
> Thanks for the help
> Prakash
>
>
>
>
>
>
>
>
>
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Newbie-Question-WARNING-No-root-resource-matching-request-path-has-been-found-tp5098573p5098573.html
> Sent from the cxf-user mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Newbie Question: WARNING: No root resource matching request path / has been found.

Tcharl
In reply to this post by cxfuser
Hi,

I'm a newbie too, but my cxf conf works and I noticed the server URL is hard coded:

          <import resource="classpath:META-INF/cxf/cxf.xml"/>
  <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
         
        <osgi:reference id="valuesTestDao" interface="net.osgiliath.dao.ValuesTestDao" />

        <context:annotation-config />
        <context:component-scan base-package="net.osgiliath.ws.server.internal" />
        <jaxrs:server id="ValuesTestServer"
                address="http://${ws.server.url}:8080/${ws.context.url}/ws/">
                <jaxrs:features>
                        <cxf:logging></cxf:logging>
                </jaxrs:features>
                <jaxrs:serviceBeans>
                        <ref bean="valuesTestWsServer" />
                </jaxrs:serviceBeans>
                <jaxrs:providers>
                        <ref bean="jaxbProvider" />
                </jaxrs:providers>
                <jaxrs:extensionMappings>
                        <entry key="json" value="application/json" />
                        <entry key="xml" value="application/xml" />
                </jaxrs:extensionMappings>
                <jaxrs:languageMappings>
                        <entry key="en" value="en-gb" />
                </jaxrs:languageMappings>
        </jaxrs:server>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Newbie Question: WARNING: No root resource matching request path / has been found.

Sergey Beryozkin
In reply to this post by Jeff Wang-2
On 25/12/11 22:36, Jeff Wang wrote:
> instead of:
>   <jaxrs:server id="myService" address="/">
> try
>   <jaxrs:server id="myService" address="/myService">
>
> the CXF servlet is matching /*, and your url base is /cxftest (which
> is the name of your deployed war, I assume.)  CXF can't find
> /myService/customer/1 because you have declared /customer/1 instead.

Thanks Jeff for this tip,

Sergey

>
> Jeff
>
> On Fri, Dec 23, 2011 at 8:01 PM, cxfuser<[hidden email]>  wrote:
>> Hello
>>
>> I'm trying to access a REST service configured using Spring configuration
>> file. When I access the URL -
>> http://localhost:8080/cxftest/myService/customer/1, it fails with following
>> error.
>>
>> WARNING: No root resource matching request path /myService/customer/1 has
>> been found.
>> Dec 23, 2011 9:46:35 PM
>> org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
>> WARNING: WebApplicationException has been caught : no cause is available
>>
>> Also when I tried to acces the home page within Spring Tool Suite (STS), it
>> gives me following error:
>>
>> WARNING: No root resource matching request path / has been found.
>> Dec 23, 2011 9:55:05 PM
>> org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
>> WARNING: WebApplicationException has been caught : no cause is available
>>
>> My Spring application_context.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: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/jaxrs
>>
>> http://cxf.apache.org/schemas/jaxrs.xsd"
>>     default-lazy-init="false">
>>
>>     <import resource="classpath:META-INF/cxf/cxf.xml" />
>>     <import
>> resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
>>     <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
>>
>>     <jaxrs:server id="myService" address="/">
>>         <jaxrs:serviceBeans>
>>             <ref bean="serviceImpl" />
>>         </jaxrs:serviceBeans>
>>         <jaxrs:extensionMappings>
>>             <entry key="xml" value="application/xml" />
>>         </jaxrs:extensionMappings>
>>     </jaxrs:server>
>>
>>     <bean id="serviceImpl" class="services.ServiceImpl" />
>>
>> </beans>
>>
>>
>> Web.xml
>> ==============================================
>> <?xml version="1.0" encoding="UTF-8"?>
>> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
>> 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.xsd">
>>
>>     <display-name>cxftest</display-name>
>>     <description>CXF REST Example</description>
>>     <welcome-file-list>
>>     <welcome-file>index.html</welcome-file>
>>     <welcome-file>index.htm</welcome-file>
>>     <welcome-file>index.jsp</welcome-file>
>>     <welcome-file>default.html</welcome-file>
>>     <welcome-file>default.htm</welcome-file>
>>     <welcome-file>default.jsp</welcome-file>
>>   </welcome-file-list>
>>
>>     <context-param>
>>         <param-name>webAppRootKey</param-name>
>>         <param-value>cxf.rest.example.root</param-value>
>>     </context-param>
>>
>>
>>     <context-param>
>>         <param-name>contextConfigLocation</param-name>
>>         <param-value>/WEB-INF/classes/application-context.xml</param-value>
>>     </context-param>
>>
>>     <listener>
>>
>> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
>>     </listener>
>>
>>     <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>/*</url-pattern>
>>     </servlet-mapping>
>>
>> </web-app>
>>
>> ServiceImpl.java
>> =====================================
>>
>> package services;
>>
>> import java.io.IOException;
>>
>> import javax.ws.rs.GET;
>> import javax.ws.rs.Path;
>> import javax.ws.rs.PathParam;
>> import javax.ws.rs.Produces;
>>
>> import model.Customer;
>>
>> import org.codehaus.jackson.map.ObjectMapper;
>>
>> @Path("/customer/{id}")
>> @Produces("application/json")
>>
>> public class ServiceImpl {
>>
>>         @GET
>>         public String getCustomer( @PathParam("id") final String customerId) throws
>> IOException {
>>                 Customer customer = new Customer();
>>                 customer.setName("customer1");
>>                 return javaToJSON(customer);
>>         }
>>
>>         private String javaToJSON(final Object object) throws IOException {
>>                 ObjectMapper mapper = null;
>>                 mapper = new ObjectMapper();
>>                 return mapper.writeValueAsString(object);
>>         }
>>
>> }
>>
>>
>>
>>
>> Thanks for the help
>> Prakash
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> --
>> View this message in context: http://cxf.547215.n5.nabble.com/Newbie-Question-WARNING-No-root-resource-matching-request-path-has-been-found-tp5098573p5098573.html
>> Sent from the cxf-user mailing list archive at Nabble.com.


--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Newbie Question: WARNING: No root resource matching request path / has been found.

cxfuser
In reply to this post by cxfuser
Thanks Jeff, your suggestion worked
Loading...