2013-01-09 74 views
4

嘗試(使用CXF 2.7.1)來構建從樣品WSDL演示契約優先服務:IllegalArgumentException:鍵不能爲空 - 哪個鍵?

<?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 

我的問題是:

  1. 什麼是關鍵?
  2. 如何提供它,以便我沒有得到例外?
  3. 爲什麼wsdl2java產生的代碼不完整? (即不是.wsdl文件足夠?)

UPDATE:由WSDL2Java命令產生的ANT build.xml文件具有這2個表面上相關的行:

<sysproperty key="java.util.logging.config.file" value="${cxf.etc.dir}/logging.properties"/> 
<sysproperty key="log4j.configuration" value="file:///${cxf.etc.dir}/log4j.properties"/> 
  1. 它們是密鑰(沒有雙關意圖)的問題?
  2. 如果是這樣,我應該把它放在那裏以解決它?
  3. 如何告訴wsdl2java生成我不需要修復的代碼?

回答

3

Jetty的日誌實現讀取系統屬性是這樣的:

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)和您的java命令行中的-D選項檢查所有設置系統屬性的位置。 如果這沒有幫助,請嘗試在發生此異常之前打印系統屬性,或者執行jpda調試會話並在Log行< 122或System.checkKey()處放置斷點。

+0

這是一個偉大的答案,至少告訴我哪個子系統抱怨(碼頭)。我遞歸地grep-ed整個項目(不是那麼大,你可以用OP中描述的wsdl2java命令自己生成)** setProperty **,** checkKey **和'-D',但是沒有找到任何東西。所以,我仍然不知道哪個鍵和/或如何提供它。感謝+1和我會在我找出這兩個問題的答案後接受。 – Withheld

+0

另外,爲什麼'wsdl2java'產生的代碼不完整? 「.wsdl」文件不夠?另外,請參閱我上面的OP更新。其他見解或提示? – Withheld

+0

嘗試一個jpda調試會話並在發生錯誤之前在jetty中設置一個斷點。如果你以前從未做過,現在真的值得去學習它。只需谷歌的jpda。然後你可以看到設置了哪些屬性,並可能從它們設置的位置得到提示。 –

1

空的鍵來自生成的ant腳本build.xml中的cxfrun宏。

評論它像這樣,你應該罰款:

<arg value="@{param1}"/> 
<arg value="@{param2}"/> 
<arg value="@{param3}"/> 
<arg value="@{param4}"/> 
<arg value="@{param5}"/> 
<jvmarg value="${cxf.endorsed.flag}"/> 
<!-- Commented out to remove empty keys in system properties --> 
<!-- jvmarg value="@{jvmarg1}"/> 
<jvmarg value="@{jvmarg2}"/> 
<jvmarg value="@{jvmarg3}"/> 
<jvmarg value="@{jvmarg4}"/> 
<jvmarg value="@{jvmarg5}"/ --> 
+0

這是爲我工作的 –

相關問題