Here is the what I ultimately ended up doing.  Giving -wsdlLocation
(to provide a "deployed" WSDL location) seems like a good option when
you're using one WSDL at a time.  But in my case, I'm using -wsdlList
to process several WSDLs.

Giving an empty string as -wsdlLocation generates this static
initializer:

    static {
        WSDL_LOCATION = null;
    }

I have to provide the wsdl location when instantiating Services, but
it eliminates the "Can not initialize ..." message when the Service
Class is loaded.

My final wsdl2java command line ended up looking like this:

  java -DexitOnFinish=TRUE org.apache.cxf.tools.wsdlto.WSDLToJava \
   -d /path/to/output/directory \
   -verbose \
   -wsdlLocation "" \
   -validate \
   -databinding xmlbeans \
   -b data/wsdl/dfp.xsdconfig \
   -p my.package.name \
   -wsdlList \
   data/wsdl/wsdl-list.txt

-DexitOnFinish=TRUE tells WSDLToJava to exit with a non-zero status
code if wsdl generation fails (so that build tools can notice).

Steve



Date: Thu, 1 Nov 2012 18:55:32 -0400
From: Steve Revilak <[email protected]>
To: [email protected]
Subject: static intializers and "Can not initialize ..."
Message-ID: <[email protected]>
User-Agent: Mutt/1.5.21 (2010-09-15)

I have a question about the static initializer that WSDL2Java places
in service stubs.

When using wsdl2java to generate code, my service classes have static
initializers like the following:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   static {
       URL url = 
CompanyService.class.getResource("data/wsdl/dfp-CompanyService.wsdl");
       if (url == null) {
           java.util.logging.Logger.getLogger(CompanyService.class.getName())
               .log(java.util.logging.Level.INFO,
                    "Can not initialize the default wsdl from {0}",
       "data/wsdl/dfp-CompanyService.wsdl");
       }
       WSDL_LOCATION = url;
   }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The path "data/wsdl/dfp-CompanyService.wsdl" is the wsdl argument
given to wsdl2java.

I'm a little confused about this initializer.  getResource(...) finds
named a item in the JVM's classpath; and for me, that would be a path
inside a jar file.

I thought, "No problem -- I'll just package the wsdls in a jar, using
the same relative paths that I gave to wsdl2java".  However

 getResource("data/wsdl/dfp-CompanyService.wsdl")

returns a null pointer.  To get a jar:file: URL from getResource(),
you'd need a leading slash:

 getResource("/data/wsdl/dfp-CompanyService.wsdl")

I'd like to avoid the "Can not initialize ..." message every time my
JVM loads a Service class.  How should I be specifying the wsdl
location to wsdl2java to avoid this?

Thanks in advance.

Steve



Attachment: pgp4hl8HcEun2.pgp
Description: PGP signature

Reply via email to