ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 37272] - Unable to get class annotations when using custom task.
Date Sat, 30 Sep 2006 21:38:07 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=37272>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=37272


peterreilly@apache.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO




------- Additional Comments From peterreilly@apache.org  2006-09-30 14:38 -------
Hi I have a little look at this and cannot get the
problem to occur:
build.xml
<project default="build">
  <target name="build.other">
    <mkdir dir="build/other/classes"/>
    <javac srcdir="other" destdir="build/other/classes" debug="yes"/>
  </target>
  <target name="build" depends="build.other">
    <mkdir dir="build/classes"/>
    <javac srcdir="src" destdir="build/classes" debug="yes"/>
    <taskdef name="webtest" classname="test.Test"
             classpath="build/classes"/>
    <webtest classname="other.Other">
      <path path="build/other/classes"/>
    </webtest>
  </target>
  <target name="clean">
    <delete quiet="yes" dir="build"/>
  </target>
</project>

Test.java:
package test;
import org.apache.tools.ant.*;
import org.apache.tools.ant.types.*;
import javax.xml.ws.WebServiceProvider;

public class Test extends Task {
    private String classname;
    private Path   path;

    public void add(Path path) {
        if (this.path != null) {
            throw new BuildException("Only one path allowed");
        }
        this.path = path;
    }
    
    public void setClassname(String classname) {
        this.classname = classname;
    }
    public void execute() {
        if (path == null) {
            throw new BuildException("Need to specify a path");
        }
        if (classname == null) {
            throw new BuildException("Need to specify a classname");
        }
        ClassLoader loader = getProject().createClassLoader(
            path);
        try {
            Class endpointClass = Class.forName(
                classname, true, loader);
            System.out.println(endpointClass.getAnnotation(
                                   WebServiceProvider.class));
        } catch (Throwable t) {
            throw new BuildException(t);
        }
    }
}

Other.java
package other;


import javax.xml.ws.WebServiceProvider;

@WebServiceProvider(serviceName="myService")
public class Other{
   public String doSomething(){return "something";}
}

layout:
   build.xml
   src/test/Test.java
   other/other/Other.java

running output:
Note: C:\cygwin\home\peter\learning\web\src\test\Test.java uses unchecked or
unsafe operations.

Note: Recompile with -Xlint:unchecked for details.

@javax.xml.ws.WebServiceProvider(wsdlLocation=, targetNamespace=, portName=,
serviceName=myService)



BUILD SUCCESSFUL

--
I suspect that you have a classloading problem
the @WebService class in your task is loaded from
a different classloader than the @WebService class
that the MyWebService class sees.

Can you provide an example tar/zip file containing
the problem?

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message