运维开发网

ant – IllegalArgumentException:key不能为空 – 哪个键?

运维开发网 https://www.qedev.com 2020-05-09 11:17 出处:网络 作者:运维开发网整理
尝试从示例WSDL(使用CXF 2.7.1)构建演示契约优先服务: <?xml version='1.0' encoding='UTF-8'?> <wsdl:definitions name="OrderProcessService" targetNamespace="http://order.demo/" xmlns:ns1="http://schemas.xmlsoap.org/soap/ht
尝试从示例WSDL(使用CXF 2.7.1)构建演示契约优先服务:

<?xml version='1.0' encoding='UTF-8'?>
<wsdl:definitions name="OrderProcessService" targetNamespace="http://order.demo/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://order.demo/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <wsdl:types>
        <xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://order.demo/" xmlns:tns="http://order.demo/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
            <xs:element name="processOrder" type="tns:processOrder" />
            <xs:element name="processOrderResponse" type="tns:processOrderResponse" />
            <xs:complexType name="processOrder">
                <xs:sequence>
                    <xs:element minOccurs="0" name="arg0" type="tns:order" />
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="order">
                <xs:sequence>
                    <xs:element minOccurs="0" name="customerID" type="xs:string" />
                    <xs:element minOccurs="0" name="itemID" type="xs:string" />
                    <xs:element name="price" type="xs:double" />
                    <xs:element name="qty" type="xs:int" />
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="processOrderResponse">
                <xs:sequence>
                    <xs:element minOccurs="0" name="return" type="xs:string" />
                </xs:sequence>
            </xs:complexType>
        </xs:schema>
    </wsdl:types>
    <wsdl:message name="processOrderResponse">
        <wsdl:part element="tns:processOrderResponse" name="parameters">
        </wsdl:part>
    </wsdl:message>
    <wsdl:message name="processOrder">
        <wsdl:part element="tns:processOrder" name="parameters">
        </wsdl:part>
    </wsdl:message>
    <wsdl:portType name="OrderProcess">
        <wsdl:operation name="processOrder">
            <wsdl:input message="tns:processOrder" name="processOrder">
            </wsdl:input>
            <wsdl:output message="tns:processOrderResponse" name="processOrderResponse">
            </wsdl:output>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="OrderProcessServiceSoapBinding" type="tns:OrderProcess">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="processOrder">
            <soap:operation soapAction="" style="document" />
            <wsdl:input name="processOrder">
                <soap:body use="literal" />
            </wsdl:input>
            <wsdl:output name="processOrderResponse">
                <soap:body use="literal" />
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="OrderProcessService">
        <wsdl:port binding="tns:OrderProcessServiceSoapBinding" name="OrderProcessPort">
            <soap:address location="http://localhost:8080/OrderProcess" />
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

我发布了以下内容:

wsdl2java -ant -impl -server -d src OrderProcess.wsdl

源代码生成很顺利但是当我尝试使用ant OrderProcessServer构建服务器时,我收到以下异常:

OrderProcessServer:
     [java] Starting Server
     [java] Exception in thread "main" java.lang.ExceptionInInitializerError
     [java]     at org.eclipse.jetty.util.component.AbstractLifeCycle.<clinit>(AbstractLifeCycle.java:33)
     [java]     at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.activate(JettyHTTPDestination.java:178)
     [java]     at org.apache.cxf.transport.AbstractObservable.setMessageObserver(AbstractObservable.java:48)
     [java]     at org.apache.cxf.binding.AbstractBaseBindingFactory.addListener(AbstractBaseBindingFactory.java:95)
     [java]     at org.apache.cxf.binding.soap.SoapBindingFactory.addListener(SoapBindingFactory.java:895)
     [java]     at org.apache.cxf.endpoint.ServerImpl.start(ServerImpl.java:131)
     [java]     at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:360)
     [java]     at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:251)
     [java]     at org.apache.cxf.jaxws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:152)
     [java]     at javax.xml.ws.Endpoint.publish(Endpoint.java:57)
     [java]     at demo.order.OrderProcess_OrderProcessPort_Server.<init>(OrderProcess_OrderProcessPort_Server.java:19)
     [java]     at demo.order.OrderProcess_OrderProcessPort_Server.main(OrderProcess_OrderProcessPort_Server.java:23)
     [java] Caused by: java.lang.IllegalArgumentException: key can't be empty
     [java]     at java.lang.System.checkKey(System.java:774)
     [java]     at java.lang.System.getProperty(System.java:647)
     [java]     at org.eclipse.jetty.util.log.Log$1.run(Log.java:122)
     [java]     at java.security.AccessController.doPrivileged(Native Method)
     [java]     at org.eclipse.jetty.util.log.Log.<clinit>(Log.java:85)
     [java]     ... 12 more
     [java] Java Result: 1

BUILD SUCCESSFUL
Total time: 2 seconds

我的问题是:

>什么关键?

>如何提供它以便我不会得到例外?

>为什么wsdl2java生成的代码不完整? (即.wsdl文件不够?)

更新:wsdl2java命令生成的ANT build.xml文件具有以下两条看似相关的行:

<sysproperty key="java.util.logging.config.file" value="${cxf.etc.dir}/logging.properties"/>
<sysproperty key="log4j.configuration" value="file:///${cxf.etc.dir}/log4j.properties"/>

>他们是否对这个问题很关键(没有双关语)?

>如果是这样,我应该放在那里以便修复它?

>我如何告诉wsdl2java生成我不需要修复的代码?

Jetty的Log实现正在读取系统属性,如下所示:

Enumeration<String> systemKeyEnum = Enumeration<String>)System.getProperties().propertyNames();

while (systemKeyEnum.hasMoreElements())
{
    String key = systemKeyEnum.nextElement();
    String val = System.getProperty(key);
    // ... (process key/values)
}

出于某种原因,您已设法在系统属性中设置了一个空键:“”.因此,请检查以编程方式设置系统属性的所有位置(System.setProperty)和用于-D选项的java命令行.如果这没有帮助,请尝试在发生此异常之前打印系统属性,或者执行jpda调试会话并在Log line< 122或System.checkKey()处放置断点.

0

精彩评论

暂无评论...
验证码 换一张
取 消