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:

BUILD FAILED

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

C:\[...]\nbproject\jaxws-build.xml: taskdef A class needed by class com.sun.tools.ws.ant.WsImport 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

libs.jaxws21.classpath

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="com.sun.tools.ws.Ant.WsImport">
            <classpath path="${libs.jaxws21.classpath}"/>
        </taskdef>
    </target>
...

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="com.sun.tools.ws.Ant.WsImport">
            <classpath>
		        <fileset dir="./extra-lib">
			        <include name="**/*.jar"/>
		        </fileset>
            </classpath>
        </taskdef>
    </target>
...

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

6 pensieri su “Resolve the portable problem of Netbean JAX-WS libraries for web service clients

  1. doesnt work for me,

    what could be wrong,
    D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\nbproject\jaxws-build.xml:15: taskdef class com.sun.tools.ws.Ant.WsImport cannot be found using the classloader AntClassLoader
    [D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\FastInfoset.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\gmbal-api-only.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\ha-api.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\javax.annotation-api.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\javax.xml.soap-api.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\jaxb-api.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\jaxb-core.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\jaxb-impl.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\jaxb-jxc.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\jaxb-xjc.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\jaxws-api.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\jaxws-rt.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\jsr181-api.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\management-api.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\mimepull.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\policy.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\resolver.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\saaj-impl.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\stax-ex.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\stax2-api.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\streambuffer.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\woodstox-core-asl.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\jaxws-tools.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\plugins\commonj.sdo.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\plugins\eclipselink.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\plugins\javax.persistence.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\plugins\jaxws-eclipselink-plugin.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\plugins\mail.jar;D:\cruisecontrol-bin-2.8.4\cruisecontrol-bin-2.8.4\projects\HSS Control Center\jaxws-ri\lib\plugins\sdo-eclipselink-plugin.jar]

  2. 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-lib\jaxws\jaxws-21\activation.jar
    • E:\…\extra-lib\jaxws\jaxws-21\FastInfoset.jar
    • E:\…\extra-lib\jaxws\jaxws-21\http.jar
    • E:\…\extra-lib\jaxws\jaxws-21\jaxb-api.jar
    • E:\…\extra-lib\jaxws\jaxws-21\jaxb-impl.jar
    • E:\…\extra-lib\jaxws\jaxws-21\jaxb-xjc.jar
    • E:\…\extra-lib\jaxws\jaxws-21\jaxb1-impl.jar
    • E:\…\extra-lib\jaxws\jaxws-21\jaxws-api.jar
    • E:\…\extra-lib\jaxws\jaxws-21\jaxws-rt.jar
    • E:\…\extra-lib\jaxws\jaxws-21\jaxws-tools.jar (this jar contains the ant extensions)
    • E:\…\extra-lib\jaxws\jaxws-21\resolver.jar
    • E:\…\extra-lib\jaxws\jaxws-21\saaj-impl.jar
    • E:\…\extra-lib\jaxws\jaxws-21\sjsxp.jar
    • E:\…\extra-lib\jaxws\jaxws-21\stax-ex.jar
    • E:\…\extra-lib\jaxws\jaxws-21\jaxws-21streambuffer.jar
    • E:\…\extra-lib\jaxws\jaxws-exndorsed\jaxb-api.jar
    • E:\…\extra-lib\jaxws\jaxws-exndorsed\jaxws-api.jar
  3. 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.
    Bye

  4. 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.

Add Comment Register



Lascia un Commento

L'indirizzo email non verrà pubblicato. I campi obbligatori sono contrassegnati *


*

È possibile utilizzare questi tag ed attributi XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>