Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Building a .WAR file

 
Ranch Hand
Posts: 333
1
Mac Eclipse IDE Safari
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
At the moment I wimp out and let eclipse generate a .WAR file for me. However I would like to have a script to do this. I have tried to run a command like the following in the base project directory of my eclipse web project but the resultant .war file structure is not the same as the one that eclipse creates for me and does not work - page not found errors etc.

jar cvf archiveName.war .

For example the .jsp file physically reside in my webcontent directory within the eclipse directory structure. However when eclipse creates the .war file those .jsp files appear in the root.

When I run the command above they remain in a subdirectory.

So do I need to re-jig my eclipse project or do something different for the jar command ?

Thanks in advance

Dave
 
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Devid,

You can do this by ANT.
 
David Garratt
Ranch Hand
Posts: 333
1
Mac Eclipse IDE Safari
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Will that overcome the problems I am experiencing with the JAR command or is it just another way of doing the same. I am aware of ANT but never used it personally so I dont know if it would overcome the structural "path" issues I have with the resultant .WAR file.

Thanks

Dave
 
David Garratt
Ranch Hand
Posts: 333
1
Mac Eclipse IDE Safari
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If it would help anyone understand my problem the source for my project can be downloaded from my open source project www.commander4j.com - all you want it b4web.zip

The b4web.war file on the download page has been created by using the Eclipse IDE export to WAR function rather than any automated build script.

Dave
 
David Garratt
Ranch Hand
Posts: 333
1
Mac Eclipse IDE Safari
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am getting closer to understanding the problem - but not the solution.

When I hunt around in the Project Properties within Eclipse I see this page called a Web Deployment Assembly (see attached screen dump). If shows how the physical project directory structure is mapped (changed) when building a .WAR file from the Eclipse IDE.

When I run the jar command this mapping does not seem to happen and as such I end up with an invalid structure.

So - how do I replicate what Eclipse is doing when it builds the .WAR file for me ?

Thanks

Dave
wda.png
[Thumbnail for wda.png]
Eclipse Screen Dump
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You really should look into Ant or Maven to do this for you. If you insist on just running jar from the command line, then you should first copy all of the files you need into a single directory (preferably not within the existing Eclipse project directory structure ) that matches the desired war contents, and then jar that directory.
 
David Garratt
Ranch Hand
Posts: 333
1
Mac Eclipse IDE Safari
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK - I will look at ANT then - can you recommend a web link or book that would deal with the type of thing I'm trying to do. I don't seem to know the correct key words to find any useful examples. This kind of build which needs to re-arrange the structure of the target file must be very common ?

Is this re-arrangement of directories something unique to how eclipse works ?

Thanks

Dave
 
David Garratt
Ranch Hand
Posts: 333
1
Mac Eclipse IDE Safari
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see I can export an Ant build file from eclipse for this web project - but it does not seem to generate a .war file for me - unless I am doing it wrong.
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
using ant to create a war file
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks,everyone!
 
Honk if you love justice! And honk twice for tiny ads!
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic