3 Replies Latest reply: Feb 19, 2010 2:30 AM by Jay SenSharma MiddlewareMagic RSS

    Ant task web service run error

    379093
      I have deployed a web service and have 2 questions

      1:
      ==
      I am not able to run my client code for testing the web-service.

      When executing run java task using Ant or when directely executing client java class I am getting:

      cu dmwls(286)$ java MyFirstService_Impl.class
      Exception in thread "main" java.lang.NoClassDefFoundError: MyFirstService_Impl/class

      cu dmwls(298)$ java MyFirstService.class
      Exception in thread "main" java.lang.NoClassDefFoundError: MyFirstService/class

      My client jar file has following files

      cu dmwls(302)$ unzip -l MyFirstService_client.jar
      Archive: MyFirstService_client.jar
      Length Date Time Name
      -------- ---- ---- ----
      246 02-18-10 14:40 META-INF/MANIFEST.MF
      205 02-18-10 14:40 clientpkg/MathFace.class
      1877 02-18-10 14:40 clientpkg/MathFace_Stub.class
      1116 02-18-10 14:40 clientpkg/MyFirstService_Impl.class
      1353 02-18-10 14:40 clientpkg/MyFirstService.wsdl
      493 02-18-10 14:40 clientpkg/MyFirstService.class
      233 02-18-10 14:40 clientpkg/MyFirstService.xml
      -------- -------
      5523 7 files

      What I should do to test my web-service.

      2:
      ==
      I have created this webservice in unix server. Now I want to access this from my windows machine. How to do that.

      Web-service URL has localhost which is not working in windows.


      Build.xml
      =====
      <project name="buildWebservice" default="generate-from-WSDL">

      <property name="output.dir" value="output" />
      <property name="staging.dir" value="staging" />
      <property name="package.name" value="ksrpkg" />
      <property name="service.name" value="MyFirstService" />
      <property name="host.name" value="ffstestmisws02.nat.bt.com" />
      <property name="port" value="61069" />
      <property name="wl.user" value="weblogic" />
      <property name="wl.pwd" value="****" />
      <property name="contextURI" value="WebServices" />
      <property name="package.dir" value="${output.dir}/${package.name}" />

      <target name="generate-from-WSDL">
      <wsdl2service
      generateImpl="yes"
      wsdl="${service.name}.wsdl"
      destDir="${output.dir}"
      packageName="${package.name}" />
      </target>

      <target name="compile">
      <javac srcdir="${package.dir}" destdir="${staging.dir}"/>
      </target>

      <target name="ear" depends="compile">
      <servicegen
      destEar="${staging.dir}/${service.name}.ear"
      contextURI="${contextURI}" >
      <service
      javaClassComponents="${package.name}.${service.name}"
      targetNamespace="http://www.bea.com/webservices/basic/statelesSession"
      serviceName="${service.name}"
      serviceURI="/${service.name}"
      generateTypes="True"
      expandMethods="True"
      style="rpc" >
      </service>
      <classpath>
      <pathelement path="${staging.dir}" />
      </classpath>
      </servicegen>
      </target>

      <target name="deploy">
      <wldeploy
      action="deploy"
      adminurl="http://${host.name}:${port}"
      user="${wl.user}"
      password="${wl.pwd}" >
      <files dir="${staging.dir}" includes="${service.name}.ear"/>
      </wldeploy>
      </target>

      <target name="undeploy">
      <wldeploy
      action="undeploy"
      name="${service.name}"
      adminurl="http://${hostname}:${port}"
      user="${wl.user}"
      password="${wl.pwd}"
      targets="admin_dmwls"
      failonerror="false" />
      </target>

      <target name="gclient">
      <clientgen wsdl="MyFirstService.wsdl"
      packageName="clientpkg"
      clientJar="${staging.dir}/${service.name}_client.jar"/>
      </target>

      <target name="run">
      <java classname="clientpkg.MyFirstService" fork="true" >
      <arg value="http://localhost:${port}/WebServices/MyFirstService?WSDL"/>
      <arg value="10"/>
      <arg value="17"/>
      <classpath>
      <pathelement location="staging"/>
      <pathelement path="staging"/>
      </classpath>
      </java>
      </target>

      </project>
        • 1. Re: Ant task web service run error
          Jay SenSharma MiddlewareMagic
          Hi Kuldeep,

          Just change the run target as below....


          <target name="run">
          <javac srcdir="${ClientProgramSourceDirectory}"
          destdir="${staging.dir}"
          includes="MyFirstService.java">
          <classpath>
          <pathelement path="${staging.dir}/${service.name}_client.jar"/>
          <pathelement path="${java.class.path}"/>
          </classpath>
          </javac>

          <java classname="clientpkg.MyFirstService" fork="true" >
          <arg value="http://localhost:${port}/WebServices/MyFirstService?WSDL"/>
          <arg value="10"/>
          <arg value="17"/>
          <classpath>
          <pathelement path="${java.class.path}"/>
          <pathelement path="staging"/>
          <pathelement path="${staging.dir}/${service.name}_client.jar"/>
          *<pathelement path="${staging.dir}"/>*
          </classpath>
          </java>
          </target>



          Thanks
          Jay SenSharma
          http://jaysensharma.wordpress.com (WebLogic Wonders Are Here)
          • 2. Re: Ant task web service run error
            379093
            Hi Jay,

            Thanks for your help.

            I am using weblogic 8.1 and Apache Ant version 1.5.3

            Jay I do not have client source code. When I am generating client using clientgen ant task, it gives me only a .jar file with .class files in it.

            I added .jar file generated by clientgen task in 'run' but now I am getting another error.

            <target name="run">
            <java classname="clientpkg.MathFace_Stub" fork="true" >
            <arg value="http://localhost:${port}/WebServices/MyFirstService?WSDL"/>
            <arg value="10"/>
            <arg value="17"/>
            <classpath>
            <pathelement location="staging"/>
            <pathelement location="${wl.home}/server/lib/weblogic.jar"/>
            <pathelement location="staging/MyFirstService_client.jar"/>
            <pathelement location="/ffdt01/resmgt/kul/ws"/>
            <pathelement path="staging"/>
            </classpath>
            </java>
            </target>

            --- This is giving below error:

            cu dmwls(162)$ ant run
            Buildfile: build.xml

            run:
            +[java] Exception in thread "main" j*ava.lang.NoSuchMethodError:* main+
            +[java] Java Result: 1+

            BUILD SUCCESSFUL
            Total time: 1 second

            Edited by: kuldeep.singhrawat75@gmail.com on Feb 19, 2010 1:53 PM
            • 3. Re: Ant task web service run error
              Jay SenSharma MiddlewareMagic
              Hi Kuldeep,

              The clientgen Task just generates the Artifacts (helper classes for Client Program) It never generates the Actual client Program. So we need to write our Own Client program by using the artifacts generated by the Clientgen tool.

              Means u need to write some client program like..."clientpkg.MyFirstServiceClient" ...then you can run it...you can refer to http://jaysensharma.wordpress.com/webservices/ (if you are using WLS9.x or above)

              For WebLogic 8.x ...as soon as you deploy your webservice in WebLogic Server ...you will find the Client Code snippet in the Testing page of your application in AdminConsole....you can use that code snippet in your Program.

              Thanks
              Jay SenSharma

              Edited by: Jay SenSharma on Feb 19, 2010 1:56 PM