Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

Here's another peculiarity I found with the JWSC Ant Task - even though the documentation specifies that the srcdir attribute is mandatory, it is not enforced which leads to falsely reported failures during the 'Processing x JAX-WS web services...' stage.

This one had me stumbled for a while. JWSC was reporting compilation failures, but the final build status was a success. In addition when I examined the produced WAR file, it contained the very classes and packages that JWSC was claiming were missing.

My JWSC task was being used like this...
 JWSC Task
<jwsc destdir="${path.build}" keepgenerated="no"
source="${build.jdk_version}" target="${build.jdk_version}"
debug="${build.debug}" includeAntRuntime="false">
<classpath refid="compile_classpath"/>
<module contextpath="${proj.context}" name="${proj.name}${ws.suffix}-${build.version}" explode="false">
<jwsfileset srcdir="${path.src}" type="JAXWS">
<include name="**/*.java" />
<exclude name="**/package-info.java"/>
</jwsfileset>
...


Since I was using module and jwsfileset and specifying srcdir attribute on the jwsfileset, I didn't think to set the same attribute on the jwsc task itself.



This resulted in output like this (sanitised for readability):
 JWSC Output
[jwsc] JWS: processing module XXXX
[jwsc] Parsing source files
[jwsc] Parsing source files
[jwsc] 1 JWS files being processed for module XXXX
[jwsc] JWS: XXXX.java Validated.
[jwsc] Processing 1 JAX-WS web services...
[jwsc] XXXX.java:8: error: package YYYY does not exist
[jwsc] import YYYY.*;
[jwsc] ^
[jwsc] Compiling 5 source files to /tmp/tmp
[jwsc] Building jar: XXXX.war
[jwsc] Created JWS deployment outputFile: XXXX.war
[jwsc] [EarFile] Application File : XXXX/build/META-INF/application.xml
[AntUtil.deleteDir] Deleting directory /tmp/tmp


Once I set the srcdir attribute on the jwsc task, all of these processing errors went away. It seems a little redundant to have to specify the source directory in multiple places to me, but I guess there is little choice if you want clean build system output.

-i


A quick disclaimer...

Although I put in a great effort into researching all the topics I cover, mistakes can happen. Use of any information from my blog posts should be at own risk and I do not hold any liability towards any information misuse or damages caused by following any of my posts.

All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle). Use of any information contained in this blog post/article is subject to this disclaimer.
Hi! You can search my blog here ⤵
NOTE: (2022) This Blog is no longer maintained and I will not be answering any emails or comments.

I am now focusing on Atari Gamer.