Rectangle 27 0

java How to build EARWAR for Websphere Application Server by Eclipse?


If you're using a brand new version of Eclipse (like Helios or Indigo) that has the Marketplace, then there is the possibility of deploying directly to Websphere. Here's a link about it: Announcing the new WebSphere Application Server Developer Tools for Eclipse V8.0.4

Note
Rectangle 27 0

java How to build EARWAR for Websphere Application Server by Eclipse?


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

Note
Rectangle 27 0

java How to build EARWAR for Websphere Application Server by Eclipse?


<taskdef name="wsdl2java"
    classname="com.ibm.websphere.ant.tasks.WSDL2Java">
    <classpath refid="lib.path"/>
</taskdef>
com.ibm.websphere.ant.tasks.WSDL2Java
find . -type f -name "*.jar" | while read file
do
    jar tvf $file | grep WSDL2Java && echo $file
done
lib.path

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

Note
Rectangle 27 0

java How to build EARWAR for Websphere Application Server by Eclipse?


Atleast that's the way we do it.

I don't want to build it with RAD or WAS Admin Console, just script that i want.

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.

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

Note
Rectangle 27 0

java How to build EARWAR for Websphere Application Server by Eclipse?


<?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>
BUILD FAILED: D:\SourceCode\Server (RAD)\Common\build.xml:11: taskdef class com.ibm.websphere.ant.tasks.WSDL2Java cannot be found

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

Note
Rectangle 27 0

java How to build EARWAR for Websphere Application Server by Eclipse?


If you're using a brand new version of Eclipse (like Helios or Indigo) that has the Marketplace, then there is the possibility of deploying directly to Websphere. Here's a link about it: Announcing the new WebSphere Application Server Developer Tools for Eclipse V8.0.4

Note
Rectangle 27 0

java How to build EARWAR for Websphere Application Server by Eclipse?


<taskdef name="wsdl2java"
    classname="com.ibm.websphere.ant.tasks.WSDL2Java">
    <classpath refid="lib.path"/>
</taskdef>
com.ibm.websphere.ant.tasks.WSDL2Java
find . -type f -name "*.jar" | while read file
do
    jar tvf $file | grep WSDL2Java && echo $file
done
lib.path

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

Note
Rectangle 27 0

java How to build EARWAR for Websphere Application Server by Eclipse?


Atleast that's the way we do it.

I don't want to build it with RAD or WAS Admin Console, just script that i want.

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.

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

Note
Rectangle 27 0

java How to build EARWAR for Websphere Application Server by Eclipse?


Atleast that's the way we do it.

I don't want to build it with RAD or WAS Admin Console, just script that i want.

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.

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

Note
Rectangle 27 0

java How to build EARWAR for Websphere Application Server by Eclipse?


<taskdef name="wsdl2java"
    classname="com.ibm.websphere.ant.tasks.WSDL2Java">
    <classpath refid="lib.path"/>
</taskdef>
com.ibm.websphere.ant.tasks.WSDL2Java
find . -type f -name "*.jar" | while read file
do
    jar tvf $file | grep WSDL2Java && echo $file
done
lib.path

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

Note