• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Creating Build.xml for a project

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using WSAD 5.1 and webshphere server and trying to create an application. The project has a
xyz_appsEAR
xyz_apps_WEB
XYZ_BS

The web components jsps, config.xml etc are in xyz_apps_WEB, the xyz_BS contains my business objects and other java programs which I am referring/using in the action classes in xyz_apps_WEB. During run time I am gettin NoClassDefFound error in my action class when it tries to access any of the classes in xyz_BS.

I was told that all the .class files that my web project needs should be there in the classes folder under WEB-INF in my web project. I think I can do this using the ant script and put it in build.xml.

Can anyone help me with the script and give a start as to what needs to be written. Also where should this build.xml be located and how to run it.
After the build how do i invoke my application, is it ok to just start the websphere server and right click the jsp and give run on server.

Any inputs will be greatly appreciated.

Thanks,
Ram
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You've asked a lot, but not sure where you are at to help.

Do you already have an ant script? If so what does it look like, what is missing? If not, where are your classes and other code? Do you have ant installed?

ant manual

Using ant
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with Carol .
In WSAD,If you put your action source in correct place ,they can be complied automatically into WEB-INF/classes directory.That is what a IDE should do,you should not achieve it by ANT.
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I must respectfully disagree with Lucas. There's nothing wrong with having BOTH your IDE and Ant work for you. I've made it a policy that none of my projects require an IDE to build.

Microsoft cured me of that long ago. There's nothing like having all your projects break at a bad time because the new&improved IDE isn't compatible with the old. It's not in the least bit fun. Also, these days I do development under Windows, but the actual production builds are done on a GUI-less Solaris system, so being IDE-dependent isn't even an option.

A good IDE - like Eclipse or IntelliJ won't force an unnatural structure on your project. So the best thing to do is to allow as much stuff as possible be built in a way that makes it easy to assemble it into deployable unit(s). If you prefer, you can use Maven's unnatural structure, if you like. I don't favor it, but at least it's a standard.

Eclipse can assign a distinct output directory for each source directory. By default, I believe source goes in the project root and classes got to a directory named "bin". Myself, I usually have a src/java outputting to build/classes. Some really complex projects have other arrangements, especially those where the ORM classes are used by both a client app and a server app or other stuff where multiple source and output directories apply.

If you look over here,
you'll find an XSL spec that can take an Eclipse .classpath file and build a prototype Ant script.

One final caveat: When Eclipse auto-builds stuff, it may completely erase what's in the target directory. Thus, it's a good idea to adhere to the rule that a given directory be either a source or a destination, but not both. And if that doesn't cure your problems, turn off the auto-erase feature.
 
Ram Murthy
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Carol. Actually I am a beginner and so need help to start. I do have ant installed in c:\ant folder. My initial post has the project structure, basically I want a build.xml which will integrate my java classes in xyz_BS to be recogonized at run time by the action classes in the web project xyz_apps_WEB.

Also where should the build.xml be placed in xyz_BS or xyz_apps_WEB.
How to run this build.xml
What is th o/p if any
how do I run the application, is it any different -- can I just start the WAS server and give the URL in the browser ??

If you can provide me the basic build.xml and some explanation I can build on it by looking at the links you sent me.

Thanks,
Ram
 
Ram Murthy
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any one can help me with this. Some pointers to help me start would be greatly appreciated.

Regards,
Ram
 
Hooplehead
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ram,

You really need to get into ant a bit more. No paragraph of text here on The Ranch is going to save you that initial effort. Go read up on it at http://ant.apache.org/manual/index.html. The learnign curve is pretty shallow. I personally find ant very logical and straight forward. So, don't fret!

Just copy/past-ing a build file into your project root is more than likely not going to work. A build file is part of your project, a source file. Many, if not most of us check the build.xml file into source control along with the our Java files.

The 'noClassDefError' sounds like a classic classpath problem. That means javac cannot find a class referenced in the source java. These referenced class can be either in your project or external jars. This is something that can be solved with a properly configured ant file.

ant needs to configured to reflect the locations of your source java files, destination class files, and external jar file dependances. Everyone seems to have their own idea on what a good folder organization is...there is no one standard. So, when you post questions on this it might help to detail your project directory structure more verbosely. Writing all that in a paragraph of text will likely result in fewer help suggestions. Having something mildy standard would help too. E.g.:


Once your project is complied, then you 'deploy' it to tomcat (or whatever you are using.) This is really a whole other topic. You can just copy over the class files...but you need to have the servlet engine stuff sorted out too.

I would highly suggest following "hello world" tourturials on both using ant and deploying projects to your web container before trying going farther.

Stu

PS: For the record, I agree with Tim. An IDE should not take control of your project. ant is a great LCD.

[ November 05, 2006: Message edited by: Stu Thompson ]
[ November 05, 2006: Message edited by: Stu Thompson ]
 
Ram Murthy
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the inputs, I will do my homework and approach the forum if needed. BTW what di mean by "ant is a good LCD"...what does LCD stand for in this context
 
Stu Thompson
Hooplehead
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lowest Common Denominator.

Sorry. :roll:

Stu
reply
    Bookmark Topic Watch Topic
  • New Topic