7

Trying to build a demo contract-first service from a sample WSDL (using 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>

I issued the following:

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

Source code generation goes fine but when I try to build the server, using ant OrderProcessServer, I receive the following exception:

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

My questions are:

  1. What key?
  2. How do provide it so that I don't get the exception?
  3. Why is wsdl2java producing code that is incomplete? (i.e. isn't the .wsdl file sufficient?)

UPDATE: The ANT build.xml file produced by the wsdl2java command has these 2 seemingly relevant lines:

<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. Are they key (no pun intended) to the problem?
  2. If so, what values should I put there in order to fix it?
  3. How do I tell wsdl2java to generate code that I don't need to fix?
Withheld
  • 4,603
  • 10
  • 45
  • 76

3 Answers3

5

Jetty's Log implementation is reading the system properties like this:

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

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

For some reason you have managed to have an empty key: "" in your System properties. So check all the places where you set System Properties programmatically (System.setProperty) and your java commandline for -D options. If that doesn't help, try to print your system properties before this exception occurs or do a jpda debug session and place a breakpoint either at Log line <122 or at System.checkKey().

Joakim Erdfelt
  • 46,896
  • 7
  • 86
  • 136
Thomas Becker
  • 934
  • 8
  • 16
  • That's a great answer that at least tells me which subsystem was complaining (Jetty). I recursively grep-ed the entire project (not that big, you can generate it yourself with the `wsdl2java` command described in the OP) for **setProperty**, for **checkKey** and for `-D`, but didn't find anything. So, I still don't know which key and/or how to provide it. Thanks +1 and I will accept once I figure out the answers to these 2 questions. – Withheld Jan 10 '13 at 16:55
  • Also, why is `wsdl2java` producing code that is incomplete? Isn't the `.wsdl` file sufficient? Also, see my update to the OP above. Additional insights or tips? – Withheld Jan 10 '13 at 17:07
  • Try a jpda debug session and set a breakpoint inside jetty right before the error occurs. If you've never done it before, it's really worthwhile to learn it now. Just google for jpda. Then you can see what properties are set and maybe get a hint from where they're set. – Thomas Becker Jan 11 '13 at 09:45
  • I'm facing an issue with gradle project which says "Cause: key can't be empty" on building it, any ideas on how to resolve it? – Bhala T R Jul 29 '22 at 08:14
1

The empty keys come from the cxfrun macro in the generated ant script, build.xml.

Comment it out like so and you should be fine:

<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}"/ -->
knut
  • 36
  • 3
0

The empty key can also come from "comments", of this type:

=====================================

This line above may have been marked as a comment, but the system is going to think of the equals sign as a key value marker.

Amrinder Arora
  • 686
  • 7
  • 17