2016-10-31 18 views
1

私はApache CXFでspringを使用して、いくつかの残りのリソースを作成しています。私のjaxrsの豆が初期化されていないように見えます。cxf:ObserverのリクエストURLが見つかりません

WARNING:私はここに行方不明です何 http://localhost:8080/cxf-sandbox/home-screen/v1/12345/predefined-templates/universal_templateさん オブザーバー

の要求を見つけることができませんか?

私はすべての要求のために設定しましたが、私はjaxrsサーバBeanを構成した

<?xml version="1.0" encoding="UTF-8"?> 
<web-app 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_3_0.xsd" 
version="3.0"> 

<display-name>cxf-sandbox</display-name> 

<context-param> 
    <param-name>log4j.refresh.interval</param-name> 
    <param-value>120</param-value> 
</context-param> 
<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> 


<context-param> 
    <description>locations of the Spring configuration files</description> 
    <param-name>contextConfigLocation</param-name> 
    <param-value> 
     classpath:META-INF/cxf/cxf.xml, classpath:META-INF/cxf/cxf-servlet.xml 
     </param-value> 
</context-param> 

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

私CXFサーブレットと私の残りのリソースBeanにルーティングする

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" 
xmlns:beans="http://www.springframework.org/schema/beans" 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-4.0.xsd  
http://www.springframework.org/schema/context  
http://www.springframework.org/schema/context/spring-context-4.0.xsd 
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd 
http://www.springframework.org/schema/aop 
http://www.springframework.org/schema/aop/spring-aop.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-servlet.xml" /> 

<jaxrs:server id="myJaxServer" address="/home-screen"> 
    <jaxrs:serviceBeans> 
     <ref bean="PredefinedHomeScreenResourceImpl" /> 
    </jaxrs:serviceBeans> 
    <jaxrs:providers> 
     <bean id="jaxbProvider" class="org.apache.cxf.jaxrs.provider.JAXBElementProvider" /> 
    </jaxrs:providers> 
</jaxrs:server> 
<bean id="PredefinedHomeScreenResourceImpl" class="PredefinedHomeScreenResourceImpl" /> 

これは私の残りの資源です

@Path("/v1/{billingId}/predefined-templates") 
@Produces(MediaType.APPLICATION_JSON) 
public class PredefinedHomeScreenResourceImpl { 

private final static Logger LOGGER = LoggerFactory.getLogger(PredefinedHomeScreenResourceImpl.class); 

@GET 
@Path("/templateName") 
public Response getPredefinedTemplate(String billingId, String templateName) { 
    LOGGER.debug("IN HERE");   
    return Response.ok(new Employee("Abhijith")).build(); 
} 

} 
私はCXFサーブレットのいずれかのルートコンテキストの一部として必要なコンテキストをロードするのに失敗していた

モデル

@XmlRootElement(name="employee") 
public class Employee { 

@XmlElement(name = "name") 
private String name; 

public Employee(String name) { 
    super(); 
    this.name = name; 
} 


} 

答えて

-1

、すなわち、

<context-param> 
    <description>locations of the Spring configuration files</description> 
    <param-name>contextConfigLocation</param-name> 
    <param-value>WEB-INF/CXFServlet-servlet.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> 
    <init-param> 
     <param-name>config-location</param-name> 
     <param-value> 
      /WEB-INF/CXFServlet-servlet.xml 
     </param-value> 
    </init-param> 
    <load-on-startup>1</load-on-startup> 
</servlet> 
関連する問題