suchitra gowda

Greenhorn
+ Follow
since Oct 15, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by suchitra gowda

Hi,
I wrote one ant script which will do the follwoing:
1) compiles all java files and makes jar file
2) this jar file is deployed to jboss
3) After deploying I need to test the code using junit
I have some problem by the time of testing using junit:
The problem is:
I am getting the following error when i try to run the command:
c:/gonehome> ant -buildfile test.xml
junit:
[junit] Running gonehome.test.ejb.TestEJB
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
[junit] TEST gonehome.test.ejb.TestEJB FAILED
Why is this failing? If i test that thru jbuilder it is working fine.
But when i try to run that using ant script i am getting the above error:
My jar file is under jboss deploy directory and the TestEJB.java
is under c:\gonehome\test\ejb folder
The jar file successfully deployed into jboss but the problem is with junit.
Any help please...
Here is the code i am using..

<?xml version="1.0" encoding="ISO-8859-1" ?>
<project name="test" default="all" basedir=".">
<property name="ejb-jar.filename" value="test.jar"/>
<property name="dist.dir" location="dist"/>
<property name="inf.dir" location="META-INF"/>
<patternset id="class.files">
<include name="**/**/**/*.class" />
</patternset>
<patternset id="source.files">
<include name="**/**/**/*.java" />
</patternset>
<patternset id="xml.files">
<include name="META-INF/*.xml" />
</patternset>
<patternset id="junitTest.files">
<include name="**/test/**/**/*.java" />
</patternset>
<path id="full_classpath">
<pathelement location="c:\gonehome\test\server\lib\j2ee.jar" />
</path>

<target name="compile" depends="clean" >
<javac srcdir="." debug="on" >
<classpath refid ="full_classpath" />
<patternset refid ="source.files" />
<patternset refid = "junitTest.files" />
</javac>
</target>
<target name="jar" depends="compile" >
<mkdir dir="${dist.dir}/lib"/>
<mkdir dir="${inf.dir}" />
<jar jarfile="${dist.dir}/lib/${ejb-jar.filename}" basedir="." >
<patternset refid="class.files" />
<patternset refid="source.files" />
<patternset refid="xml.files" />
</jar>

<copy file="${dist.dir}/lib/${ejb-jar.filename}" todir="c:/jboss-3.2.1/server/default/deploy"/>
</target>
<target name="all" depends="jar" >
<junit printsummary="yes" errorproperty="yes" showoutput ="yes" >
<classpath>
<pathelement location="c:\ant\lib\junit.jar" />
<pathelement location="c:\jboss-3.2.1\server\default\deploy\test.jar" />
</classpath>
<test name=" test.ejb.TestEJB" />
</junit>
</target>
</project>
20 years ago
Hi Tony,
Thanks for your response.
I got solution bu using path and pathelement tags like
<path id="fuclasspath">
<pathelement location="\common.jar" />
<pathelement location="\j2ee.jar" />
</path>
20 years ago
Hi Tony,
I have one question regarding class path.
Here is the code i am using:
<!-- Tool directories as defined by the environment variables -->
<property environment="env"/>
<property name="classpath" value="${env.path}"/>
<!-- Classpath to compile our EJBs -->
<path id="server.classpath">
<pathelement location="${classpath}" />
</path>
<target name="compile" >
<javac srcdir="." classpathref="server.classpath" >
<patternset refid="source.files" />
</javac>
</target>
I am unable to compile my java files because of class path problem.
I tested by setting classpath also in environment variables.
Any help on class path .
thanks,
suchi.
20 years ago
Hi Tony,
Thanks for your quick response.
I got it . What ever you said is correct ..
Thanks,
Suchi.
20 years ago
Hi,
If i try to delete the directory after jar file creation like
<target name="dist" depends="compile" >
<jar jarfile="${dist}/lib/MyProject.jar" basedir="${build}" />
<delete dir="${build}"/>
</target>
now the directory deleted successfully.
If i use that delete tag in different target then the directory is not deleted.
for ex:
<target name="clean" description="clean up" >
<delete dir="${build}"/>
</target>
What is the diff between these and why is not working ...
Any help on this please.
Thanks,
suchi.
20 years ago
Hi,
I am not clear what is mean by -verbose.
I comiled my ant script using ant -v -buildfile test.xml then it is displaying all the stuff except the message in the clean .
I added the following code before compile.
<target name="clean" description="Delete all old files" >
<echo message="Deleting all old class files" />
<delete includeEmptyDirs="true" >
<fileSet dir="" >
<patternSet refid="class.files" />
</fileSet>
</delete>
</target>
I can not see the echo message in the logs which means that this target tag is not executed.
Any help please how I have to solve this problem.
Thanks,
suchi.
20 years ago
Hi,
The problem is my base directory is c:\ and if i say
includes="**/*.java" it picks from all directories. But I want to pick up those class files from 2 or 3 folders not from all the folders.
C drive has many folders and each folder contains lot files.
I have one more question.
Why is my delete is not working. The directory is not deleting. Even if print some message using under tag
<target name="clean" depends="dist" description="clean up" > like
<echo message="Hello" /> this message is also not printing.
Which means control is not entering into this tag.
Thanks,
suchi.
20 years ago
Hi,
I am able to create jar file with all class files but I want to include
class files and java files with corresponding directory structure in the jar file.
I have one folder structure like
c:/src/src1
Now src contains some java files and src1 contains some other files.
What changes i need to do in the following code to include java files
also in the jar file.
<project name="MyProject" default="dist" basedir=".">
<description>
simple example build file
</description>
<!-- set global properties for this build -->
<property name="src" location="src"/>
<property name="build" location="build"/>
<property name="dist" location="dist"/>
<target name="init">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>
</target>
<target name="compile" depends="init" description="compile the source " >
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}" />
</target>
<target name="dist" depends="compile" description="generate the distribution" >
<!-- Create the distribution directory -->
<mkdir dir="${dist}/lib"/>
<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
<jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}" />
</target>
<target name="clean" depends="dist" description="clean up" >
<!-- Delete the ${build} directory trees -->
<delete dir="${build}"/>
</target>
</project>

Any help how to add class files also to jar file.
Thanks,
Suchi.
20 years ago