apache cxf 3.2.2无法正常工作

时间:2018-03-14 13:45:56

标签: apache cxf

cxf版本使用3.2.2
 所有cxf版本的lib都在WEB-INF \ lib文件夹中使用  这是抛出的异常

13-Mar-2018 21:38:20.806 WARNING [localhost-startStop-1] 
org.apache.cxf.ws.discovery.internal.WSDiscoveryServiceImpl.startup 
Could not start WS-Discovery Service.
javax.xml.ws.WebServiceException: java.lang.NullPointerException
    at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:375)
    at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:255)
    at 

 org.apache.cxf.ws.discovery.internal.WSDiscoveryServiceImpl.
 startup(WSDiscoveryServiceImpl.java:259)
    at 
 org.apache.cxf.ws.discovery.internal.WSDiscoveryServiceImpl.
 serverStarted(WSDiscoveryServiceImpl.java:154)
    at org.apache.cxf.ws.discovery.listeners.WSDiscoveryServerListener.
 startServer(WSDiscoveryServerListener.java:73)
    at org.apache.cxf.bus.managers.ServerLifeCycleManagerImpl.
 startServer(ServerLifeCycleManagerImpl.java:61)
    at org.apache.cxf.endpoint.ServerImpl.start(ServerImpl.java:137)
    at org.apache.cxf.frontend.ServerFactoryBean.create
 (ServerFactoryBean.java:224)
    at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create
 (JaxWsServerFactoryBean.java:211)
    at org.apache.cxf.jaxws.spring.NamespaceHandler$
  SpringServerFactoryBean.create(NamespaceHandler.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

-------------------------- apache cxf 3.2.2版本示例代码

@WebService(name="HelloWorld")
@SOAPBinding(style = Style.DOCUMENT, use = Use.LITERAL)
public interface HelloWorld {
    String sayHi(String text);
    String sayHiToUser(User user);

    @XmlJavaTypeAdapter(IntegerUserMapAdapter.class)
    Map<Integer, User> getUsers();
}

------------------我正在添加web.xml和cxf-servlet.xml

-------------------------- Apache的CXF-的services.xml http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.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&#34;&gt;                                          ------------------------------------------- Apache的CXF-的services.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:soap="http://cxf.apache.org/bindings/soap" xsi:schemaLocation=" 
  http://www.springframework.org/schema/beans 
  http://www.springframework.org/schema/beans/spring-beans-4.2.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">
    <jaxws:server id="jaxwsService" 
        serviceClass="demo.hw.server.HelloWorld" address="/hello_world">
        <jaxws:serviceBean>
            <bean class="demo.hw.server.HelloWorldImpl"/>
        </jaxws:serviceBean>
    </jaxws:server>
</beans>

1 个答案:

答案 0 :(得分:0)

不幸的是,您发布的堆栈跟踪中缺少真正的原因。我刚刚添加了一个目标来直接从Maven运行Tomcat 8来获取此https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/java_first_jaxws样本。您可以使用mvn cargo:run运行它以查看它是否有效。

我想知道为什么你添加了ws-discovery,它不是样本的一部分。