从ant调用WS

时间:2011-03-14 10:54:18

标签: java ant jax-ws

我编写了一个java WS并托管了它

@WebService
public class DBConnectionCheck{

    @WebMethod
    public synchronized boolean dbServerState(final String SERVERNAME,final String USER_ID,final String USER_PASSWORD
            ,final String VENDOR,final String PORT,final String CONNECTOR_TYPE)
    {
             .............}
    @WebMethod
         @WebMethod
    public synchronized boolean oracleDBState(......)
         {
..............
          }

我已经生成了存根并编写了客户端....

      public class CheckRegressionStatus {



public static void main(String args[]) throws PreRequisticException
{

    Properties resourceMangerProps = new Properties();

    /**
     * Instantiate the generated Service
     */
    com.cordys.autopilot.InfraStructure.servercheck.stub.ReadInfraResourceAvaliabiltyService service1 = new com.cordys.autopilot.InfraStructure.servercheck.stub.ReadInfraResourceAvaliabiltyService();

    com.cordys.autopilot.InfraStructure.servercheck.stub.ReadInfraResourceAvaliabilty res = service1.getReadInfraResourceAvaliabiltyPort();

    /**
     * Instantiate the generated Service
     */
    com.cordys.autopilot.InfraStructure.dbstate.stub.DBConnectionCheckService                              service = new com.cordys.autopilot.InfraStructure.dbstate.stub.DBConnectionCheckService();


    com.cordys.autopilot.InfraStructure.dbstate.stub.DBConnectionCheck dbConnectionCheckProxy = service.getDBConnectionCheckPort();

从Eclipse或Netbeans

调用时,这非常有效

但是当我写一个ant代码来调用它时

<java classname="....InfraStructure.CheckRegressionStatus">                 
                    <classpath>
                        <pathelement path="XYZ.jar"/>          
                    </classpath>
</java>

抛出以下错误

  [java] javax.xml.ws.WebServiceException: Provider com.sun.xml.internal.ws.spi.ProviderImpl not f
  [java]     at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:194)
  [java]     at org.apache.tools.ant.taskdefs.Java.run(Java.java:747)
  [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:201)
  [java]     at org.apache.tools.ant.taskdefs.Java.execute(Java.java:104)
  [java]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
  [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
  [java]     at java.lang.reflect.Method.invoke(Method.java:597)
  [java]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
  [java]     at org.apache.tools.ant.Task.perform(Task.java:348)
  [java]     at org.apache.tools.ant.Target.execute(Target.java:357)
  [java]     at org.apache.tools.ant.Target.performTasks(Target.java:385)
  [java]     at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
  [java]     at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
  [java]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41
  [java]     at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
  [java]     at org.apache.tools.ant.Main.runBuild(Main.java:698)
  [java]     at org.apache.tools.ant.Main.startAnt(Main.java:199)
  [java]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
  [java]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
  [java] Caused by: javax.xml.ws.WebServiceException: Provider com.sun.xml.internal.ws.spi.Provide
  [java]     at javax.xml.ws.spi.FactoryFinder.newInstance(FactoryFinder.java:33)
  [java]     at javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:128)
  [java]     at javax.xml.ws.spi.Provider.provider(Provider.java:83)
  [java]     at javax.xml.ws.Service.<init>(Service.java:56)

1 个答案:

答案 0 :(得分:1)

您使用的是JDK 1.6吗?

默认情况下,此类com/sun/xml/internal/ws/spi/ProviderImpl位于JDK 1.6 rt.jar中。您很可能已使用正确的JDK设置Eclipse,但未将Ant设置为使用JDK 1.6。