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.
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.
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.
An IDE is no substitute for an Intelligent Developer.
Joined: Aug 02, 2005
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.
Joined: Aug 02, 2005
Any one can help me with this. Some pointers to help me start would be greatly appreciated.
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.
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 ]
"This is not to say that design is unnecessary. But after a certain point, design is just speculation." --Philip Chu
Joined: Aug 02, 2005
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