After referring this article and this article, I am trying to run the ant script from a java class as follows:
File buildFile = new File("D:\\Utility\\artifacts\\build.xml");
Project p = new Project();
p.setUserProperty("ant.file", buildFile.getAbsolutePath());
DefaultLogger consoleLogger = new DefaultLogger();
consoleLogger.setErrorPrintStream(System.err);
consoleLogger.setOutputPrintStream(System.out);
consoleLogger.setMessageOutputLevel(Project.MSG_INFO);
p.addBuildListener(consoleLogger);
try
{
p.fireBuildStarted();
p.init();
ProjectHelper helper = ProjectHelper.getProjectHelper();
p.addReference("ant.projectHelper", helper);
helper.parse(p, buildFile);
p.executeTarget(p.getDefaultTarget());
p.fireBuildFinished(null);
}
catch (BuildException e)
{
p.fireBuildFinished(e);
}
Following is the build.xml file:
<project name="buildWebservice" default="generate-from-wsdlc">
<taskdef name="wsdlc" classname="weblogic.wsee.tools.anttasks.WsdlcTask"
classpath="D:\bea\wlserver_10.3\server\lib\weblogic.jar" />
<target name="generate-from-wsdlc">
<wsdlc srcWsdl="D:\Utility\WSDLs\someWSDL.wsdl"
type="JAXWS" destJwsDir="temp\JWS_InterfaceDir" destImplDir="temp\JWS_ImplDir">
</wsdlc>
</target>
</project>
But when i execute this java code, i get the following Exception in the console:
BUILD FAILED
D:\Utility\artifacts\build.xml:21: java.lang.NoSuchMethodError: com.sun.xml.ws.util.JAXWSUtils.getEncodedURL(Ljava/lang/String;)Ljava/net/URL;
I even decompiled the jaxws-rt.jar to look for getEncodedURL method in JAXWSUtils class but didn't find any such method.
Please help! Thanks in advance