Today I have spent a lot of time with a very strange issue compiling JAX-WS generated classes. I have been using jbossws wsconsume to generate some classes from a .NET wsdl and I had a very strange behaviour:
- Generate class calling wsconsume
- compile them and its client using ant and run my test perfectly working
- then calling my clean task to remove .class files and recompile them and run my tests doesn’t work!
IOW JAX-WS client have been working only the first time I compile them. I couldn’t figure out why it have been working in that manner, but after a lot of google search I got this commit. In practice what have been happening is better described in “Note on package-info.java” paragraph of javac target in ant manual. Starting from version 1.7.1 ant compile package-info.java only in these 3 case:
- If a
package-info.class file exists and is older than the package-info.java file.
- If the directory for the
package-info.class file does not exist.
- If the directory for the
package-info.class file exists, and has an older modification time than the the package-info.java file. In this case <javac> will touch the corresponding .class directory on successful compilation.
In practice if you havea ant task like mine:
<target name=”compile” depends=”init” description=”Compile the Java source code”>
<javac destdir=”${classes.dir}” classpathref=”build.classpath” debug=”${javac.debug}” deprecation=”${javac.deprecation}” target=”1.5″>
<src path=”${src.java.dir}” />
</javac>
Here the compilation target compile all files and so create directory where package-info.class will be contained during other generated files compilation. In this case the compilation target never re-generate package-info.class because no one of the 3 conditions is true. My workaround have been to change my build.xml file and have this compile target:
<target name=”compile” depends=”init” description=”Compile the Java source code”>
<touch>
<fileset dir=”${src.java.dir}” includes=”**/package-info.java”/>
</touch>
<javac destdir=”${classes.dir}” classpathref=”build.classpath” debug=”${javac.debug}” deprecation=”${javac.deprecation}” target=”1.5″>
<src path=”${src.java.dir}” />
</javac>
Hoping this post would be useful for someone, let me remark that is a problem of ant javac task, not of jbossws and you will get the same problem with any other jaxws stack.
Let me remark also that Wise perfectly work in this case regenerating it’s classes on the fly 