File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes ant tomcat dist -wrong file structure specified Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "ant tomcat dist -wrong file structure specified " Watch "ant tomcat dist -wrong file structure specified " New topic
Author

ant tomcat dist -wrong file structure specified

mary morris
Ranch Hand

Joined: Mar 16, 2002
Posts: 97
I am using ant to distribute a set of folders for a web application.
I am using a book called mySQL and jspIt is a zip file, which I unzip.
the xml files I have to change are not read only - but the higher level files are and I have tried unchecking the read only attribute but is gets rechecked to read only.
The build is the build file:
Where I point to:
c:\jakarta-tomcat-4.0.6\webapps\bfg\
----------------------------------------------------------------
<project name="BfgWebsite" default="dist" basedir=".">
<property name="tomcatdir" value="/tomcat"/>
<property name="appdir" value="${tomcatdir}/webapps/bfg"/>
<property name="jarfile" value="bfgclasses.jar"/>
<target name="init">
<tstamp/>
</target>
<target name="compile" depends="init">
<javac srcdir="src">
<classpath>
<pathelement path="${classpath}"/>
<pathelement path="src"/>
<fileset dir="c:\jakarta-tomcat-4.0.6\lib">
<include name="**/*.jar"/>
</fileset>
<fileset dir="c:\jakarta-tomcat-4.0.6\common">
<include name="**/*.jar"/>
</fileset>
<fileset dir="c:\jakarta-tomcat-4.0.6\webapps\bfg\WEB-INF\lib\">
<include name="**/*.jar"/>
<exclude name="bfgclasses.jar"/>
</fileset>
</classpath>
</javac>
</target>

<target name="dist" depends="compile">
<mkdir dir="${appdir}/WEB-INF/lib"/>
<mkdir dir="${appdir}/logs"/>
<jar jarfile="${appdir}/WEB-INF/lib/${jarfile}">
<fileset dir="src" includes="**/*.class"/>
<fileset dir="props" includes="**/*.properties"/>
</jar>
<copy todir="${appdir}/WEB-INF">
<fileset dir="." includes="web.xml"/>
<fileset dir="." includes="TurbineResources.properties"/>
<fileset dir="props" includes="log4j.properties"/>
</copy>
<mkdir dir="${appdir}/jsp"/>
<copy todir="${appdir}/jsp">
<fileset dir="jsp"/>
</copy>
<delete dir="${tomcatdir}/work/localhost/bfg"/>
</target>

<target name="test" depends="dist">
<java classname="com.bfg.customer.Customer" fork="yes">
<classpath>
<pathelement path="${java.class.path}"/>
<fileset dir="c:\jakarta-tomcat-4.0.6\lib">
<include name="**/*.jar"/>
</fileset>
<pathelement path="src"/>
<pathelement path="props"/>
</classpath>
</java>
<java classname="com.bfg.product.Product" fork="yes">
<classpath>
<pathelement path="${java.class.path}"/>
<fileset dir="c:\jakarta-tomcat-4.0.6\lib">
<include name="**/*.jar"/>
</fileset>
<pathelement path="src"/>
<pathelement path="props"/>
</classpath>
</java>
<java classname="com.bfg.product.Category" fork="yes">
<classpath>
<pathelement path="${java.class.path}"/>
<fileset dir="c:\jakarta-tomcat-4.0.6\lib">
<include name="**/*.jar"/>
</fileset>
<pathelement path="src"/>
<pathelement path="props"/>
</classpath>
</java>
</target>
<target name="start">
<exec dir="${tomcatdir}/bin" executable="startup.bat"
os="Windows 2000" vmlauncher="false">
</exec>
</target>
<target name="stop">
<exec dir="${tomcatdir}/bin" executable="shutdown.bat"
os="Windows 2000" vmlauncher="false">
</exec>
</target>
<target name="restart" depends="stop,start">
</target>
</project>
web.xml
<?xml version="1.0"?>

<web-app>
<servlet>
<servlet-name>log4j-init</servlet-name>
<servlet-class>com.bfg.services.Log4jInit</servlet-class>
<init-param>
<param-name>log4j-init-file</param-name>
<param-value>WEB-INF/log4j.properties</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>turbine-init</servlet-name>
<servlet-class>com.bfg.services.TurbineInit</servlet-class>
<init-param>
<param-name>turbine-resource-directory</param-name>
<param-value> c:/jakarta-tomcat-4.0.6/webapps/bfg/WEB-INF</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<session-config>
<session-timeout>5</session-timeout>
</session-config>
<resource-ref>
<res-ref-name>mail/session</res-ref-name>
<res-type>javax.mail.Session</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
<param-value> c:\jakarta-tomcat-4.0.6/webapps/bfg/WEB-INF</param-value>
again points to
c:/jakarta-tomcat-4.0.6/webapps/bfg/
I run ant with the following and I get the below, I do not know why it creates
C:\tomcat\webapps\bfg
Not :
c:\jakarta-tomcat-4.0.6\webapps\bfg
---------------------------------
init:
compile:
dist:
[mkdir] Created dir: C:\tomcat\webapps\bfg\WEB-INF\lib
[mkdir] Created dir: C:\tomcat\webapps\bfg\logs
[jar] Building jar: C:\tomcat\webapps\bfg\WEB-INF\lib\bfgclasses.jar
[copy] Copying 3 files to C:\tomcat\webapps\bfg\WEB-INF
[mkdir] Created dir: C:\tomcat\webapps\bfg\jsp
[copy] Copying 35 files to C:\tomcat\webapps\bfg\jsp
BUILD SUCCESSFUL
Total time: 1 second
C:\TEMP\cartapp\bfg>
(this is where I have the xml and cartapp files) � temp /../
AM I doing something wrong with ant?
I tried taking the read write off the files, but it will not stay off, but it is not on the xml files � would this make a difference?
Not sure what else to try
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Look at these two properties from the beginning of the build file:
<property name="tomcatdir" value="/tomcat"/>
<property name="appdir" value="${tomcatdir}/webapps/bfg"/>

And then look at where your stuff is going. See the relationship?
Look where you are creating the jar...
<jar jarfile="${appdir}/WEB-INF/lib/${jarfile}">


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2848
    
  11

I'm not sure what's going on with the read/write permissions, but your main question seems to be why stuff shows up in: C:\tomcat\webapps\bfg instead of c:\jakarta-tomcat-4.0.6\webapps\bfg. That has nothing to do with write permissions. It's because you define the appdir property to be ${tomcatdir}/webapps/bfg and the tomcatdir property to be /tomcat. I think Ant is just doing what you're telling it to do. Maybe I misunderstood the question though?
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2848
    
  11

D'oh! What Tom said. I'm off to practice my speed typing.
mary morris
Ranch Hand

Joined: Mar 16, 2002
Posts: 97
Thanks for the help - is this what you meant Thomas?
-Now I get a
different error message when run ant
--------------
C:\>cd\temp\cartapp\bfg
C:\TEMP\CARTAPP\bfg>ant dist
Buildfile: build.xml
init:
compile:
BUILD FAILED
C:\TEMP\CARTAPP\bfg\build.xml:11: srcdir "C:\TEMP\CARTAPP\bfg\src" does not exist!
--------------------
this is the build file
-----------------------
<project name="BfgWebsite" default="dist" basedir=".">
<property name="C:\jakarta-tomcat-4.0.6" value="/tomcat"/>
<property name="appdir" value="${tomcatdir}/webapps/bfg"/>
<property name="jarfile" value="bfgclasses.jar"/>
<target name="init">
<tstamp/>
</target>
<target name="compile" depends="init">
<javac srcdir="src">
<classpath>
<pathelement path="${classpath}"/>
<pathelement path="src"/>
<fileset dir="c:\tomcat\lib">
<include name="**/*.jar"/>
</fileset>
<fileset dir="c:\tomcat\common">
<include name="**/*.jar"/>
</fileset>
<fileset dir="c:\tomcat\webapps\bfg\WEB-INF\lib\">
<include name="**/*.jar"/>
<exclude name="bfgclasses.jar"/>
</fileset>
</classpath>
</javac>
</target>

<target name="clean">
<delete>
<fileset dir="src/com/bfg" includes="**/*.class"/>
</delete>
</target>
<target name="dist" depends="compile">
<mkdir dir="${appdir}/WEB-INF/lib"/>
<mkdir dir="${appdir}/logs"/>
<jar jarfile="${appdir}/WEB-INF/lib/${jarfile}">
<fileset dir="src" includes="**/*.class"/>
<fileset dir="props" includes="**/*.properties"/>
</jar>
<copy todir="${appdir}/WEB-INF">
<fileset dir="." includes="web.xml"/>
<fileset dir="." includes="TurbineResources.properties"/>
<fileset dir="props" includes="log4j.properties"/>
</copy>
<mkdir dir="${appdir}/jsp"/>
<copy todir="${appdir}/jsp">
<fileset dir="jsp"/>
</copy>
<delete dir="${tomcatdir}/work/localhost/bfg"/>
</target>
<target name="javadoc">
<mkdir dir="javadoc"/>
<javadoc sourcepath="src" destdir="javadoc" author="true"
version="true" use="true" packagenames="com.bfg.*">
<classpath>
<pathelement path="${classpath}"/>
<fileset dir="c:\tomcat\lib">
<include name="**/*.jar"/>
</fileset>
</classpath>
</javadoc>
</target>
<target name="test" depends="dist">
<java classname="com.bfg.customer.Customer" fork="yes">
<classpath>
<pathelement path="${java.class.path}"/>
<fileset dir="c:\tomcat\lib">
<include name="**/*.jar"/>
</fileset>
<pathelement path="src"/>
<pathelement path="props"/>
</classpath>
</java>
<java classname="com.bfg.product.Product" fork="yes">
<classpath>
<pathelement path="${java.class.path}"/>
<fileset dir="c:\tomcat\lib">
<include name="**/*.jar"/>
</fileset>
<pathelement path="src"/>
<pathelement path="props"/>
</classpath>
</java>
<java classname="com.bfg.product.Category" fork="yes">
<classpath>
<pathelement path="${java.class.path}"/>
<fileset dir="c:\tomcat\lib">
<include name="**/*.jar"/>
</fileset>
<pathelement path="src"/>
<pathelement path="props"/>
</classpath>
</java>
</target>
<target name="start">
<exec dir="${tomcatdir}/bin" executable="startup.bat"
os="Windows 2000" vmlauncher="false">
</exec>
</target>
<target name="stop">
<exec dir="${tomcatdir}/bin" executable="shutdown.bat"
os="Windows 2000" vmlauncher="false">
</exec>
</target>
<target name="restart" depends="stop,start">
</target>
</project>
--------------------
file sturcture on pc
----------------
C:\temp\cartapp\bfg\build.xml
...
c:\temp\cartapp\src
any ideas - I am very new to ant - thanks again
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ant tomcat dist -wrong file structure specified