Deploying your Jar with your War in Eclipse

Note: I've done the  following using Rad7 but should also be applicable to Eclipse(since RAD7 is basically made on top of Eclipse).

When you have total control of you web container/app server, deploying jar files is as easy as dropping the folder in your common lib folder. If you don't package your web apps as a war file then it's even easier because you only have to drop the jars in the WEB-INF/lib folder of your webapp. But if you don't have total control of  your web server or application server, your only choice is to package the jars you've used with your war file.

While developing a web project using my recently developed utility(a jar file), I encountered a NoClassDefFound error. Of course, it's pretty obvious that the jar file I've made and using on my web project could not be found(not visible in the CLASSPATH). Adding the jar to the build path only eliminated the compilation problem. Dragging the jar file into the lib folder of my Eclipse workspace isn't a very good idea. It took me a couple of hours before I figured out the solution:

  1. Right Click on your web project
  2. Click Properties
  3. Select J2EE Module Dependencies
  4. Click the Web Libraries Tab
  5. Add external jars(if the jar is outside of your project). An entry will be added under Jar/Module, make sure you click on the checkbox(checked).
And everything should be fine. I tried exporting to a war file and then checked the content and my jar files are indeed deployed with the war.
Published 01-03-2008 9:43 PM by lamia
Filed under: ,


Thursday, October 09, 2008 1:56 AM by haglolno

# re: Deploying your Jar with your War in Eclipse

If you want to

buy viagra online

<a>buy viagra</a>

Friday, October 10, 2008 4:09 PM by Lindsay

# re: Deploying your Jar with your War in Eclipse

Thanks for that. I have been searching for hours.