dev@glassfish.java.net

Need some input: apt cannot see javax.jws.WebMethod

From: Bhakti Mehta <Bhakti.Mehta_at_Sun.COM>
Date: Tue, 09 Sep 2008 15:37:24 -0700

Sahoo,
I need some input on how to handle this case.

In 109 we run wsgen which invokes apt using com.sun.tools.apt.Main.process()

this internally will invoke com.sun.tools.apt.main.JavaCompiler . I am
observing since classes in tools.jar have a classloader
which has the following entries
http://javaweb.sfbay/~bhakti/jsr109apt/toolsclassloader.txt


If I do
this.getClass().getClassLoader().loadClass("javax.jws.WebMethod") where
this is JavaCompilerHelper it throws a ClassNotFoundException with the
following stacktrace because it cannot find the WebMethod
http://javaweb.sfbay/~bhakti/jsr109apt/cnfe.txt (Seen inside the debugger)

Thread.currentThread.getContextClassLoader().loadClass("javax.jws.WebMethod")
would work but I did not find any option in apt where I could pass a
classloader .

I have found a solution to this is add javax.javaee.jar or whichever jar
which contains WebMethod class in classpath when invoking wsgen
ie invoking wsgen -classpath "path to javax.javaee-10.0-SNAPSHOT.jar" ....
which gets passed on as an argument to apt then it will work.

Is this the right way to approach this problem or is there a better option?
Regards,
Bhakti