Link to home
Start Free TrialLog in
Avatar of chaitu chaitu
chaitu chaituFlag for India

asked on

how to run oc4j server using ant

build.xml

i want to run oc4j server after ear deploying and also want to open broswer with name http://localhost:8888/etrans/index.jsp but i am getting error; should i use parallel or sequetial keyword for running oc4j?
my oc4j batch file is in c:/oc4j/j2ee/home

<?xml version="1.0"?>
<project name="ant" default="all" basedir=".">
  <property file="myantproperties.properties"/>
  <property name="source" value="."/>
  <property name="cvs.dir" value="${cvsdir}"/>
  <property name="cvsroot" value="${cvsrootaddress}"/>
  <property name="password" value=".cvspass"/>
  <property name="module" value="${module}"/>
  <property name="ejbsrc" value="${ejbsrc}"/>
  <property name="websrc" value="${websrc}"/>
  <property name="jarname" value="${jarname}"/>
  <property name="warname" value="${warname}"/>
  <property name="ejbbuild" value="ejbbuild"/>
  <property name="webbuild" value="webbuild"/>
  <property name="app.ear" value="${earname}"/>
  <property name="oc4j" value="${oc4jdirectory}"/>
<property name="browser" location="C:/Program Files/Internet Explorer/iexplore.exe"/>
<property name="file" location="http://localhost:8888/etrans/index.jsp"/>

  <path id="ejb.jar">      
      <pathelement path="${deploy}"/>
      <fileset dir="${deploy}">
            <include name="ejb.jar"/>
      </fileset>
  </path>

  <path id="classpath">
      <pathelement path="${applicationJars}"/>
      <fileset dir="${applicationJars}">
            <include name="*.jar"/>
      </fileset>
      <fileset dir="${utilityJars}">
            <include name="*.jar"/>
      </fileset>
  </path>

 <target name="all" depends="clean, login, checkout"/>

 <target name="clean">
    <!--delete dir="${cvs.dir}"/-->
    <delete dir="${ejbbuild}"/>
    <delete dir="${webbuild}"/>
    <delete dir="${deploy}"/>
 </target>

 <target name="login" description="Login to repository">
    <cvspass cvsroot="${cvsroot}" password="${password}"/>
 </target>

 <target name="checkout" description="Checkout project" depends="login">
  <mkdir dir="${cvs.dir}"/>
  <cvs cvsroot="${cvsroot}" package="${module}" dest="${cvs.dir}"/>
  <antcall target="makeEar"/>
 </target>

  <target name="makeEar" depends="earinit, compile_ejb, jar.ejb,compile_webclasses,copy_images,copy_jsps,war.web,ear_app,deploy_app,cleanoc4jlog,runoc4j"/>

  <target name="earinit">
    <!-- Create the time stamp -->
    <tstamp/>
    <!-- Create the build directory structure used by compile
    and copy the deployment descriptors into it-->
    <mkdir dir="${ejbbuild}"/>
    <mkdir dir="${ejbbuild}/META-INF"/>
    <mkdir dir="${webbuild}/WEB-INF"/>
    <mkdir dir="${webbuild}/WEB-INF/classes"/>
    <mkdir dir="${deploy}"/>
    <copy todir="${ejbbuild}/META-INF">
      <fileset dir="${source}/xml">
        <include name="ejb-jar.xml"/>
        <include name="orion-ejb-jar.xml"/>
      </fileset>
    </copy>
  </target>

  <!-- Compile ejb classes into the build directory (jar preparation) -->
  <target name="compile_ejb" depends="earinit">
    <javac srcdir="${ejbsrc}" destdir="${ejbbuild}" includes="**/*.java">
      <classpath refid="classpath"/>
    </javac>
    <copy todir="${ejbbuild}">
      <fileset dir="${ejbsrc}">
        <include name="*.properties"/>
      </fileset>
    </copy>
  </target>

  <!-- Update ejb jar file or create it if it doesn't exist, including XML
    deployment descriptors -->
  <target name="jar.ejb"  depends="compile_ejb">
    <jar jarfile="${deploy}/${jarname}" basedir="${ejbbuild}" update="yes">
    </jar>
  </target>
 
  <!-- Compile client app into the clientclasses directory, and move the client jar file (created by appc) there as well -->
  <target name="compile_webclasses" depends="jar.ejb">
    <javac srcdir="${websrc}/com" destdir="${webbuild}/WEB-INF/classes" includes="**/*.java">
      <classpath refid="classpath"/>
      <classpath refid="ejb.jar"/>
    </javac>

  </target>

  <target name="copy_images" depends="compile_webclasses">
    <copy todir="${webbuild}/images">
      <fileset dir="${websrc}/images">
        <include name="**/*.*"/>
      </fileset>
    </copy>
  </target>
 
  <target name="copy_jsps" depends="copy_images">
    <copy todir="${webbuild}/customer">
      <fileset dir="${websrc}/customer">
        <include name="**/*.*"/>
      </fileset>
    </copy>
    <copy todir="${webbuild}/eaccounts">
      <fileset dir="${websrc}/eaccounts">
        <include name="**/*.*"/>
      </fileset>
    </copy>
    <copy todir="${webbuild}/etrans">
      <fileset dir="${websrc}/etrans">
        <include name="**/*.*"/>
      </fileset>      
    </copy>
    <copy todir="${webbuild}/vendor">
      <fileset dir="${websrc}/vendor">
        <include name="**/*.*"/>
      </fileset>      
    </copy>
    <copy todir="${webbuild}">
      <fileset dir="${websrc}">
        <include name="*.*"/>
      </fileset>      
    </copy>
    <copy todir="${webbuild}/html">
      <fileset dir="${websrc}/html">
        <include name="*.*"/>
      </fileset>      
    </copy>
    <copy todir="${webbuild}/flash">
      <fileset dir="${websrc}/flash">
        <include name="*.*"/>
      </fileset>      
    </copy>
    <copy todir="${webbuild}/WEB-INF">
      <fileset dir="${websrc}/WEB-INF">
        <include name="*.*"/>
      </fileset>      
    </copy>
    <copy todir="${webbuild}/WEB-INF">
      <fileset dir="${source}/xml">
        <include name="web.xml"/>
      <include name="orion-web.xml"/>
      </fileset>      
    </copy>
    <copy todir="${webbuild}/WEB-INF/lib">
      <fileset dir="${websrc}/WEB-INF/lib">
        <include name="*.*"/>
      </fileset>      
    </copy>
    <copy todir="${webbuild}/WEB-INF/xml">
      <fileset dir="${websrc}/WEB-INF/xml">
        <include name="*.*"/>
      </fileset>      
    </copy>
  </target>

  <!-- Update ejb jar file or create it if it doesn't exist, including XML
    deployment descriptors -->
  <target name="war.web"  depends="copy_images">
    <jar jarfile="${deploy}/${warname}" basedir="${webbuild}" update="yes">
    </jar>
  </target>

  <!-- Put the ejb into an ear, to be deployed from the ${apps.dir} dir -->
  <target name="ear_app" depends="jar.ejb,war.web">
    <ear earfile="${deploy}/${app.ear}" appxml="${source}/xml/application.xml">
      <fileset dir="${deploy}" includes="${jarname}"/>
      <fileset dir="${deploy}" includes="${warname}"/>      
    </ear>
  </target>

  <!-- Put the ear to be deployed into an OC4J server-->
  <target name="deploy_app" depends="ear_app">
    <copy file="${deploy}/${app.ear}" todir="${oc4j}/applications"/>
    </target>

<target name="cleanoc4jlog" depends="deploy_app">
<delete includeemptydirs="true">
  <fileset dir="${oc4j}/log" includes="**/*"/>
 </delete>
</target>


<target name="runoc4j" depends="cleanoc4jlog">
 <apply executable="test_run" dir="${oc4j}" failonerror="true" parallel="true">
 </apply>
</target>

<target name="cleanoc4jlog" depends="openbrowser">
<exec executable="${browser}" spawn="true">
    <arg value="${file}"/>
</exec>
 </apply>
</target>

</project>

Avatar of petmagdy
petmagdy
Flag of Canada image

for the last 2 targets I think it should be:

<target name="runoc4j" depends="cleanoc4jlog">
 <apply executable="test_run" dir="${oc4j}" failonerror="true" parallel="true">
 </apply>
</target>

<target name="openbrowser" depends="runoc4j">
<exec executable="${browser}" spawn="true">
    <arg value="${file}"/>
</exec>
 </apply>
</target>
Also I see no value set for: ${oc4jdirectory}
Avatar of chaitu chaitu

ASKER

i set ${oc4jdirectory} value in myantproperties.properties;
as i was changed my build.xml specified by u but i am getting this error;


BUILD FAILED
C:\ChaitanyaAnt\build.xml:53: The following error occurred while executing this
line:
C:\ChaitanyaAnt\build.xml:198: no filesets and no filelists specified
can u post the contents of test_run?
while ant is running  i want to run the oc4j server in another window

test_run.bat file is this:


set path=c:\j2sdk1.4.2_06\bin;
java -Xmx512m -Djdbc.connection.debug=true -Dp6.home=C:\OC4J_EXTENDED\j2ee\home\lib -Dp6trace=true  -jar oc4j.jar  -userThreads -verbosity 10 -out log\std_out.log -err log\std_err.log
ASKER CERTIFIED SOLUTION
Avatar of petmagdy
petmagdy
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Chaituu,

did u try it?
 tell me if it went ok or not

BR