File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Building a .WAR file

 
David Garratt
Ranch Hand
Posts: 212
Eclipse IDE Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Devid,

You can do this by ANT.
 
David Garratt
Ranch Hand
Posts: 212
Eclipse IDE Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • 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: 212
Eclipse IDE Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • 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: 212
Eclipse IDE Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • 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
Eclipse Screen Dump
[Thumbnail for wda.png]
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • 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: 212
Eclipse IDE Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • 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: 212
Eclipse IDE Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • 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
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
 
sco phone
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,everyone!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic