September 26, 2013

Resolve the portable problem of Netbean JAX-WS libraries for web service clients

Apache Ant and Netbean

Netbean have a useful management of project based on Ant, but when you build a project with inclusion of JAX-WS library it fail on portable aspect. I’m going to explain how I have resolved this issue.

In my job experience if my client or my boss ask me a Java project with delivery of source code and Apache Ant for the management of build process, I work with Netbean. Netbean have a useful management of project based on Apache Ant, but when you build a very big project this Apache Ant management can fail in some aspects. One of this is the inclusion of JAX-WS library. So on my workstation where Netbeans is installed it works well but when I commit on my continuous integration, I have an indefinite classpath problem.

The error anatomy

On my local environment, with Netbeans or with Apache Ant command line compilation, all works very well but when I launch the same project into the continuous integration environment (no Netbeans installation is present) I have this error:


C:\[...]\build.xml: The following error occurred while executing this line:

C:\[...]\nbproject\jaxws-build.xml: taskdef A class needed by class cannot be found: [...]

using the classloader AntClassLoader[]

The reason

Netbean, into the installation process, store some common library on own installation directory and it configure their private Apache Ant installation to use it. Some of this configurations are saved on windows registry or, on linux device, Netbean store the classpath on the launcher of the human interface. On my version of Netbean (from 6.x to 7.2) the configuration of JAX-WS library is stored on variable


and it’s initialized (maybe) at start-up of Netbeans or it’s filled (I think) at opening of project into the editor. This variable is used on auto-generated nbproject/jaxws-build.xml file into the follow section:

    <target name="wsimport-init" depends="init">
        <mkdir dir="${build.generated.sources.dir}/jax-ws"/>
        <taskdef name="wsimport" classname="">
            <classpath path="${libs.jaxws21.classpath}"/>

The solution

Some notifications of this problem exist on Netbean bugtrack system and exist differents method to resolve it. Many times I resolved it with the simple inclusions of all library into the ANT_PROP or Java CLASSPATH or system PATH variables. It sounds good for small projects. Otherwise when the project have too many libraries this tecnique introduce new problems for management or, in some system, it re-introduce problem into the build process.

For me the best solution is overwrite the target named “wsimport-init” on build.xml. The Netbeans project structure allows you to modify the build.xml because Netbean not overwrite this file after one customization of project via Netbean Project Properties panels. So:

  • I download the JAVA-WS library from official site
  • I put it on extra-lib directory. This directory is on the same level of build.xml.
  • On build.xml I copy from jaxws-build.xml the Ant task named “wsimport-init” and I modify it as in the follow mode:
    <target name="wsimport-init" depends="init">
        <mkdir dir="${build.generated.sources.dir}/jax-ws"/>
        <taskdef name="wsimport" classname="">
		        <fileset dir="./extra-lib">
			        <include name="**/*.jar"/>

That’s all, now my project is NetBean installation free!

You may also like...

7 Responses

  1. Akira says:

    Thanks! This worked for me!

  2. sanny says:

    doesnt work for me,

    what could be wrong,
    D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centernbprojectjaxws-build.xml:15: taskdef class cannot be found using the classloader AntClassLoader
    [D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibFastInfoset.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibgmbal-api-only.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibha-api.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibjavax.annotation-api.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibjavax.xml.soap-api.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibjaxb-api.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibjaxb-core.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibjaxb-impl.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibjaxb-jxc.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibjaxb-xjc.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibjaxws-api.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibjaxws-rt.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibjsr181-api.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibmanagement-api.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibmimepull.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibpolicy.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibresolver.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibsaaj-impl.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibstax-ex.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibstax2-api.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibstreambuffer.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibwoodstox-core-asl.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibjaxws-tools.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibpluginscommonj.sdo.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibpluginseclipselink.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibpluginsjavax.persistence.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibpluginsjaxws-eclipselink-plugin.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibpluginsmail.jar;D:cruisecontrol-bin-2.8.4cruisecontrol-bin-2.8.4projectsHSS Control Centerjaxws-rilibpluginssdo-eclipselink-plugin.jar]

    • Odyno says:

      Hi sanny,
      I don’t know what is wrong, but I suspect that you have used a custom version of jax-ws because I see too many jars on jax-ws specific classpath.
      For example in my project it was only this:

      • E:…extra-libjaxwsjaxws-21activation.jar
      • E:…extra-libjaxwsjaxws-21FastInfoset.jar
      • E:…extra-libjaxwsjaxws-21http.jar
      • E:…extra-libjaxwsjaxws-21jaxb-api.jar
      • E:…extra-libjaxwsjaxws-21jaxb-impl.jar
      • E:…extra-libjaxwsjaxws-21jaxb-xjc.jar
      • E:…extra-libjaxwsjaxws-21jaxb1-impl.jar
      • E:…extra-libjaxwsjaxws-21jaxws-api.jar
      • E:…extra-libjaxwsjaxws-21jaxws-rt.jar
      • E:…extra-libjaxwsjaxws-21jaxws-tools.jar (this jar contains the ant extensions)
      • E:…extra-libjaxwsjaxws-21resolver.jar
      • E:…extra-libjaxwsjaxws-21saaj-impl.jar
      • E:…extra-libjaxwsjaxws-21sjsxp.jar
      • E:…extra-libjaxwsjaxws-21stax-ex.jar
      • E:…extra-libjaxwsjaxws-21jaxws-21streambuffer.jar
      • E:…extra-libjaxwsjaxws-exndorsedjaxb-api.jar
      • E:…extra-libjaxwsjaxws-exndorsedjaxws-api.jar
  3. Renata says:


    o link que vc falou com as libs não é esse, é: (JAXWS-RI) ??
    Se possível mando o link correto, poi não estou achando.


    • Odyno says:

      Sorry but I don’t understand all your question. I think your link is the Reference Implementation of jaxws but normally I use the implementation provided from the specific server where my code will be running.

  4. Renata says:

    Hy Odyno!

    I´m sorry to have written in portuguese. So, could you explain me about this phrase?
    “On build.xml I copy from jaxws-build.xml the Ant task named “wsimport-init” and I modify it as in the follow mode:”

    I should copy that code( ) inside build.xml?

    I´ve tried tosolv this problem, but have not achieved.

  5. Ingo says:

    Hello ,
    i found another workaround.
    ant scan the ${user.home}/.ant/lib Directory if its exist, so you can copy all the needed jars into it.
    No modification on jaxws-build.xml is necessary 😉

Leave a Reply

Your email address will not be published. Required fields are marked *