Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

taskdef class com.sun.tools.ws.ant.WsImport cannot be found Following "The java web services tutorial"

I saw the same issue in many different locations and even after a good portion of googling, I could not resolve it. What I am trying to do (the bigger picture) is to go through The java web services tutorial, which seems at points out of sync,

Specially here, when I try to compile, I get the following message:

C:\javaeetutorial5\examples\jaxws\common\targets.xml:26: taskdef class com.sun.tools.ws.ant.WsImport cannot be found

I have tried many different combinations of placing jars or changing environment variables, but with no result. Any successful stories?

The full build error message is the following:

BUILD FAILED

C:\javaeetutorial5\examples\jaxws\helloservice\build.xml:4: The following error occurred while executing this line:

C:\javaeetutorial5\examples\jaxws\common\targets.xml:26: taskdef A class needed by class com.sun.tools.ws.ant.WsImport cannot be found: org/apache/tools/ant/DynamicConfigurator

using the classloader AntClassLoader[C:\Program Files (x86)\Java\jdk1.6.0_23\lib\tools.jar]

Total time: 0 seconds

And the corresponding taskdef:

<taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport">
    <classpath refid="jaxws.classpath"/>
</taskdef>

Also a peek into the endorsement directory:

C:\javaeetutorial5\kschneid>cd %JAVA_HOME%

C:\Program Files (x86)\Java\jdk1.6.0_23>dir lib\endorsed
 Volume in drive C is OSDisk
 Volume Serial Number is AAAA-BBBB

 Directory of C:\Program Files (x86)\Java\jdk1.6.0_23\lib\endorsed

25/02/2011  09:34    <DIR>          .
25/02/2011  09:34    <DIR>          ..
25/02/2011  09:34           105,134 jaxb-api.jar
25/02/2011  09:33            54,476 jaxws-api.jar
               2 File(s)        159,610 bytes
               2 Dir(s)  110,907,056,128 bytes free

C:\Program Files (x86)\Java\jdk1.6.0_23>
like image 845
Dimitrios Mistriotis Avatar asked Feb 23 '11 13:02

Dimitrios Mistriotis


1 Answers

You can fix the problem in Netbeans x.y as follows:

  1. Go to Tools->Options->Java->Ant.
  2. Click on "Add JAR/ZIP..." under the Classpath section
  3. Navigate to "C:\Program Files\NetBeans x.y\enterprise\modules\ext\metro\"
  4. Select all files.
  5. Click OK, and try the import/regenerate again.

where x.y = 7.1, 7.2, 8.0 etc

like image 80
Babatunde Adeyemi Avatar answered Sep 29 '22 23:09

Babatunde Adeyemi