views:

12968

answers:

6

IBM Rational Application Developer is very slow and has many problems.

I tried to use ant scripts to build EAR/WAR files for Websphere Application Server but it did not work.

A: 

I read this IBM Article and tried to run ant script by RAD

My build.xml

<?xml version="1.0" encoding="UTF-8"?>                     
<project name="xx" default="build" basedir=".">

  <property name="WSAS.home" value="C:\Program Files\IBM\Rational\SDP\6.0\runtimes\base_v6" />

  <path id="lib.path">
    <pathelement location="${WSAS.home}/lib/*.jar"/>
  </path>                                                                                               

  <taskdef name="wsdl2java"
           classname="com.ibm.websphere.ant.tasks.WSDL2Java">
    <classpath refid="lib.path"/>
  </taskdef>

  <taskdef name="java2wsdl"
           classname="com.ibm.websphere.ant.tasks.Java2WSDL">
    <classpath refid="lib.path"/>
  </taskdef>

  <taskdef name="endptenabler"
           classname="com.ibm.websphere.ant.tasks.endptEnabler">
    <classpath refid="lib.path"/>
  </taskdef>

  <taskdef name="wsdeploy"
           classname="com.ibm.websphere.ant.tasks.WSDeploy">
    <classpath refid="lib.path"/>
  </taskdef>

  <taskdef name="wsejbdeploy"
           classname="com.ibm.websphere.ant.tasks.WsEjbDeploy">
     <classpath refid="lib.path"/>
  </taskdef>

  <taskdef name="installapp"
           classname="com.ibm.websphere.ant.tasks.InstallApplication">
    <classpath refid="lib.path"/>
  </taskdef>

  <target name="build" depends="init, j2w, w2j, buildapp, makejar, makeear, endpt, ejbdeploy, deployws, install"/>

  <target name="init">
    <delete dir="${WSAS.home}/bin/tmp"/>
    <mkdir dir="${WSAS.home}/bin/tmp/META-INF"/>
    <copy toDir="${WSAS.home}/bin/tmp/META-INF" overwrite="true">
      <fileset dir="${WSAS.home}/bin">
        <include name="application.xml"/> 
        <include name="ejb-jar.xml"/> 
      </fileset>
    </copy>
  </target>

  <target name="j2w">

    <javac srcdir="${WSAS.home}/bin"
           destdir="${WSAS.home}/bin">
      <classpath refid="lib.path"/>
      <include name="WSExample.java"/>
    </javac> 

    <java2wsdl output="${WSAS.home}/bin/tmp/META-INF/wsdl/WSExample.wsdl"
               classpath="${WSAS.home}/bin"
               className= "example.WSExample"
               namespace="http://example"
               namespaceImpl="http://example"
               location="http://localhost:9080/example/services/WSExample"
               style="document"
               use="literal">
      <mapping namespace="http://example" package="example"/>
    </java2wsdl>

  </target>                


  <target name="w2j">

    <wsdl2java url="${WSAS.home}/bin/tmp/META-INF/wsdl/WSExample.wsdl"
               output="${WSAS.home}/bin/tmp"
               role="develop-server"
               container="EJB"
               introspect="false"
               verbose="false">
    </wsdl2java>

  </target>


  <target name="buildapp">  

    <copy toDir="${WSAS.home}/bin/tmp/example" overwrite="true">
      <fileset dir="${WSAS.home}/bin">
        <include name="WSExampleSoapBindingImpl.java"/> 
      </fileset>
    </copy>

    <javac srcdir="${WSAS.home}/bin/tmp"
           destdir="${WSAS.home}/bin/tmp">
      <classpath refid="lib.path"/>
      <include name="**/*.java"/>
    </javac> 

    <replace file="${WSAS.home}/bin/tmp/META-INF/webservices.xml"
             token="??SET THIS TO ejb-name ELEMENT OF ejb-jar.xml??"
             value="WSExample"/>

  </target>


  <target name="makejar">

    <jar jarfile="${WSAS.home}/bin/tmp/WSExample.jar">
      <fileset dir="${WSAS.home}/bin/tmp">
        <include name="**/*.class"/> 
      </fileset>
      <zipfileset dir="${WSAS.home}/bin/tmp/META-INF" prefix="META-INF">
        <include name="**/*"/>
      </zipfileset>
    </jar>

  </target>


  <target name="makeear">

    <ear earfile="${WSAS.home}/bin/tmp/WSExample.ear"
         appxml="${WSAS.home}/bin/tmp/META-INF/application.xml">
      <fileset dir="${WSAS.home}/bin/tmp">
        <include name="WSExample.jar"/>
      </fileset>
    </ear>

  </target>

  <target name="endpt">

    <endptenabler earfile="${WSAS.home}/bin/tmp/WSExample.ear">
      <property key="verbose" value="false"/>
      <property key="WSExample.transports" value="http"/>
      <property key="WSExample.http.rounterModuleName" value="WSExample_HTTPRouter.war"/>
      <property key="WSExample.http.contextRoot" value="wsexample"/>
    </endptenabler>

  </target>               


  <target name="ejbdeploy">

    <wsejbdeploy inputJar="${WSAS.home}/bin/tmp/WSExample.ear"
                 wasHome="${WSAS.home}"
                 workingDirectory="${WSAS.home}/tmp"
                 outputJar="${WSAS.home}/bin/tmp/WSExampleDeployed.ear"               
                 codegen="false"
                 keepGenerated="false"
                 quiet="true"
                 noValidate="false"
                 noWarnings="false"
                 noInform="false"
                 failonerror="true"
                 trace="false"/>

  </target>  


  <target name="deployws">

    <wsdeploy classPath="" debug="false"
              ignoreErrors="false"
              inputFile="${WSAS.home}/bin/tmp/WSExampleDeployed.ear"
              noValidate="false"
              outputFile="${WSAS.home}/bin/tmp/WSExampleReadyToInstall.ear"
              trace="false"/>

  </target>


  <target name="install">

    <installapp wasHome="${WSAS.home}"
                ear="${WSAS.home}/bin/tmp/WSExampleReadyToInstall.ear"
                options="-usedefaultbindings"
                conntype="NONE"
                failonerror="true"/>

  </target>

</project>

but I got error

BUILD FAILED: D:\SourceCode\Server (RAD)\Common\build.xml:11: taskdef class com.ibm.websphere.ant.tasks.WSDL2Java cannot be found
Fuangwith S.
A: 

My understanding is that you build the EAR/WAR, then open your browser, login to the admin console, then deploy your application.

If my understanding is correct, just add an instance of the WAS server to your workspace, and then right click on the server, select Add/Remove Projects and add your project. This way, you don't have to build the EAR/WAR file at all... Building your project is enough. If the build is successful, then RAD automatically builds the EAR/WAR and publishes the file to the server.

Atleast that's the way we do it.

Shivasubramanian A
I don't want to build it with RAD or WAS Admin Console, just script that i want.
Fuangwith S.
+3  A: 

If Ant can't find the WAS tasks, then it is likely that the WAS API's are missing from the Ant classpath.

See this question for other sample scripts and suggestions.

McDowell
+1  A: 

You need to make sure the jar file containing the com.ibm.websphere.ant.tasks.WSDL2Java is in your lib.path classpath.

<taskdef name="wsdl2java"
    classname="com.ibm.websphere.ant.tasks.WSDL2Java">
    <classpath refid="lib.path"/>
</taskdef>

If you're on UNIX, you can scan for this class using code similar to:

find . -type f -name "*.jar" | while read file
do
    jar tvf $file | grep WSDL2Java && echo $file
done
toolkit
A: 

you ran this script with wsant not ant right?

A: 

If RAD is slow, - try to upgrade to the latest FixPack available. - read the following article https://www.ibm.com/developerworks/wikis/download/attachments/113606723/radtipsv754.pdf?version=1

Or contact support and explain more specifically the problem.

Michael