Spring,Apache CXF和Embedded Jetty

时间:2011-06-12 17:16:06

标签: web-services jetty cxf embedded-jetty

我正在尝试使用Apache CXF,Spring和嵌入式Jetty服务器创建支持Web服务的服务器。当我运行我的项目时,服务器似乎正确初始化,但是当我导航到http://localhost:8080/SomeService期望看到服务WSDL时,我得到以下异常:

SEVERE: /SomeService
java.lang.NullPointerException
    at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:163)
    at org.apache.cxf.transport.servlet.AbstractCXFServlet.doGet(AbstractCXFServlet.java:145)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:693)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:324)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)

有什么想法吗?

这是Java main()

public static void main(String[] args) throws Exception {                    
    new ClassPathXmlApplicationContext(new String[] {"beans-jetty.xml"});
}

豆-的jetty.xml

<bean id="propertyConfigurer"
      class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location" value="file:conf/server.properties" />
</bean>

<bean id="server"
      class="org.mortbay.jetty.Server"
      init-method="start"
      destroy-method="stop">
    <property name="connectors">
        <list>
            <bean id="connector" class="org.mortbay.jetty.nio.SelectChannelConnector">
                <property name="host" value="${server.address}"/>
                <property name="port" value="${server.port}"/>
            </bean>
        </list>
    </property>
    <property name="handlers">
        <list>
            <ref bean="context-cxf"/>
        </list>
    </property>
</bean>

<bean name="context-cxf" class="org.mortbay.jetty.servlet.Context">
    <property name="contextPath" value="/" />
    <property name="handler">
        <bean class="org.mortbay.jetty.servlet.ServletHandler">
            <property name="servlets">
                <list>
                    <bean class="org.mortbay.jetty.servlet.ServletHolder">
                        <property name="name" value="cxf-servlet-holder" />
                        <property name="servlet">
                            <bean class="org.apache.cxf.transport.servlet.CXFServlet" />
                        </property>
                    </bean>
                </list>
            </property>
            <property name="servletMappings">
                <list>
                    <bean class="org.mortbay.jetty.servlet.ServletMapping">
                        <property name="servletName" value="cxf-servlet-holder" />
                        <property name="pathSpec" value="/*" />
                    </bean>
                </list>
            </property>
        </bean>
    </property>
</bean>

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

豆-cxf.xml

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

<jaxws:endpoint
        id="someService"
        implementor="com.awebster.gitta.services.SomeServiceImpl"
        address="${server.address}" />

我应该提一下,我正在使用Maven one-jar插件,虽然我怀疑这会对这个问题产生任何影响。

非常感谢提前!

安东尼

0 个答案:

没有答案