Issue
I'm using the jaxws-maven-plugin
version 2.1
. I've found out very strange code generated for WSDL location from jar resources:
<configuration>
<keep>true</keep>
<sourceDestDir>${basedir}/src/main/java</sourceDestDir>
<extension>true</extension>
<wsdlDirectory>${basedir}/src/main/resources/wsdl</wsdlDirectory>
<packageName>my.package.gen</packageName>
<wsdlLocation>wsdl/*</wsdlLocation>
<wsdlFiles>
<wsdlFile>mywsdl.wsdl</wsdlFile>
</wsdlFiles>
</configuration>
And the code generated is:
static {
URL url = null;
try {
URL baseUrl;
baseUrl = my.package.gen.My_Service.class.getResource(".");
url = new URL(baseUrl, "wsdl/mywsdl.wsdl");
} catch (MalformedURLException e) {
logger.warning("Failed to create URL for the wsdl Location: 'wsdl/mywsdl.wsdl', retrying as a local file");
logger.warning(e.getMessage());
}
MYSERVICE_WSDL_LOCATION = url; }
So the wsdl file is looked up in the directory (package) the generated class residents, and not in the main jar directory, as would be logical. And the WSDL can't be found.
Is it a bug in jaxws-maven-plugin
, or it is the error in my configuration?
Solution
You should use jaxws-maven-plugin version 2.3 instead of 2.1 and the result will be as you would expected.
The output of version 2.3 like this (if your wsdl folder is under src/main/resources):
URL url = <Any>.class.getClassLoader().getResource("wsdl/anywsdl.wsdl");
Answered By - Miklos Krivan
Answer Checked By - Robin (JavaFixing Admin)