从Java运行weblogic wsdlc任务时出错

时间:2012-04-18 14:06:39

标签: java ant weblogic-10.x wsdlc

在引用this articlethis article之后,我试图从java类运行ant脚本,如下所示:

    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);
    }

以下是build.xml文件:

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

但是当我执行这个java代码时,我在控制台中得到以下异常:

BUILD FAILED
D:\Utility\artifacts\build.xml:21: java.lang.NoSuchMethodError: com.sun.xml.ws.util.JAXWSUtils.getEncodedURL(Ljava/lang/String;)Ljava/net/URL;

我甚至反编译了jaxws-rt.jar以在JAXWSUtils类中查找getEncodedURL方法,但没有找到任何此类方法。

请帮忙! 提前致谢

1 个答案:

答案 0 :(得分:0)

尝试关于此论坛条目的其他实现: https://forums.oracle.com/forums/thread.jspa?threadID=1125462