• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

ant tomcat dist -wrong file structure specified

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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}">
 
Sheriff
Posts: 3034
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3034
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
D'oh! What Tom said. I'm off to practice my speed typing.
 
mary morris
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
That's a very big dog. I think I want to go home now and hug this tiny ad:
Enterprise-grade Excel API for Java
https://products.aspose.com/cells/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!