jQuery in Action, 3rd edition
The moose likes Ant, Maven and Other Build Tools and the fly likes Regarding Ant issue. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Regarding Ant issue. " Watch "Regarding Ant issue. " New topic

Regarding Ant issue.

arvind kushwaha
Ranch Hand

Joined: Aug 12, 2011
Posts: 32
Dear Team,
I am new babie in ant please help me.
I have created war files using Apache Ant version 1.8.1, war files is generated successfully. I want to start tomcat 7.0.23 and place my project in webapps directory of tomcat but after creating war files build.xml not executing below bold lines. I donot know what is wrong, please look into this i am sending by build.xml files as well as build.properties files

build.xml file:


Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1599
arvind kushwaha wrote:I donot know what is wrong...

Do you know the "error" and its line number ?

Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
arvind kushwaha
Ranch Hand

Joined: Aug 12, 2011
Posts: 32
I am getting the below error.
I donot know which file is not found.

aa@aa-desktop:~/tempworkspace$ ant
Buildfile: /home/aa/tempworkspace/build.xml

[echo] !!!Making directories !!!

[echo] !!!Compiling Java Files !!!
[javac] /home/aa/tempworkspace/build.xml:31: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds

[echo] !!!Creating War files !!!
[war] Building war: /home/aa/tempworkspace/dist/togle.war

[echo] !!!deploy !!!

[echo] !!!install Target!!!

/home/aa/tempworkspace/build.xml:108: java.io.FileNotFoundException: togle (Is a directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:120)
at java.io.FileInputStream.<init>(FileInputStream.java:79)
at org.apache.catalina.ant.DeployTask.execute(DeployTask.java:170)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:390)
at org.apache.tools.ant.Target.performTasks(Target.java:411)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1397)
at org.apache.tools.ant.Project.executeTarget(Project.java:1366)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1249)
at org.apache.tools.ant.Main.runBuild(Main.java:801)
at org.apache.tools.ant.Main.startAnt(Main.java:218)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

Total time: 7 seconds
Peter Johnson

Joined: May 14, 2008
Posts: 5852

Look carefully at the error message:

/home/aa/tempworkspace/build.xml:108: java.io.FileNotFoundException: togle (Is a directory)

The part in red is the file name, the part in blue is what Ant doesn't like. If you go back to the "install" target, you will note that the "war" property on line 106 is set to a directory, but it expects a file.

JBoss In Action
arvind kushwaha
Ranch Hand

Joined: Aug 12, 2011
Posts: 32
Thanks Peter for your's precious comment. The Problem is solved.

Thanks to all guys who help on this matter. I had make some changes and it worked. But on below bold line No: 29 want to pass dynamic file name instead of hard code. Can Any one Help on this. I am
attaching build. xml and build.properties file.



#build.properties file

Peter Johnson

Joined: May 14, 2008
Posts: 5852

I assume, based on the file name, that the file is generated by some process somewhere and that process includes a date/time string in the filename, and what you want to do is set up the build.xml generically enough to handle whatever name was generated. This requires two steps:

1) First, change line 29 to be:

2) Set the sql.fileName property to the file's name. Exactly how that is done depends on who or what generated the file. Possibilities include updating the build.properties with the name and passing it using -D or setting an environment variable. There are probably other ways. But without knowing how the file gets generated, I can't be more specific.
arvind kushwaha
Ranch Hand

Joined: Aug 12, 2011
Posts: 32
Dear Peter,

The file is given by user, i don't have to worried about that, thank you so much, but supposed above file run it created database, table and inserted all value. but i had updated some jsp again i have to run the build.xml file, in this scenario though table is created already it again try to do the same . I want to skip the database part when its run second time or all the data is already present in user machine. how would i achieve this in single build.xml file.

If provide me some code it will appreciated.
Peter Johnson

Joined: May 14, 2008
Posts: 5852

Here is what I would do.

Do not make "init" depend on "createDatabaseAndTable" (remove the depends clause from line 33)

Then when you need to create the database and build th code, run as:

ant createDatabaseAndTable war

Later when you just want to rebuild the app, run:

I agree. Here's the link: http://aspose.com/file-tools
subject: Regarding Ant issue.
It's not a secret anymore!