java - Getting "No services have been found." error -


i'm new maven, spring , cxf , trying small 'hello world' thing going have rest service available use. i've spent day on , still i'm getting dreaded "no services have been found." error when run project on tomcat inside eclipse. below i've posted important code few files. i'm hoping can tell me i'm doing wrong:

web.xml:

<web-app>     <display-name>archetype created web application</display-name>     <context-param>         <param-name>contextconfiglocation</param-name>         <param-value>/web-inf/beans.xml</param-value>     </context-param>     <servlet>         <servlet-name>cxfservlet</servlet-name>         <display-name>cxf servlet</display-name>         <servlet-class>org.apache.cxf.transport.servlet.cxfservlet</servlet-class>     </servlet>     <servlet-mapping>         <servlet-name>cxfservlet</servlet-name>         <url-pattern>/*</url-pattern>     </servlet-mapping> </web-app> 

beans.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: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  http://cxf.apache.org/jaxws  http://cxf.apache.org/schemas/jaxws.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-servlet.xml" />     <bean id="bookserviceclass" class="org.ahmad.resttest1.restservices.bookservice" />     <jaxrs:server id="bookservice" address="/">         <jaxrs:servicebeans>             <ref bean="bookserviceclass" />         </jaxrs:servicebeans>     </jaxrs:server> </beans> 

bookservice.java:

package org.ahmad.resttest1.restservices;  import org.ahmad.resttest1.vo.bookvo; import javax.ws.rs.*; import javax.ws.rs.core.mediatype; import javax.ws.rs.core.response; import java.io.unsupportedencodingexception; import java.net.urldecoder; import java.util.hashmap;  @path("/") public class bookservice {   private static hashmap < bookvo, bookvo > hashmap;   @get  @path("/randommsg/{name}")  @produces({   mediatype.application_json  })  public response getsomemessage(@pathparam("name") string name) {    return response.ok(name + "123").build();  } } 

you have configuration errors.

include spring listener in web.xml

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

remove lines in beans.xml . not needed in latest versions of cxf

<import resource="classpath:meta-inf/cxf/cxf-extension-soap.xml" /> <import resource="classpath:meta-inf/cxf/cxf-servlet.xml" /> 

after this, server available executing

http://localhost:8080/yourdeploydir/randommsg/hello 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -