I have a small Dynamic web project in Eclipse gallileo that references another project. When I deploy my project to Glassfish v2.1, as soon as I try instantiating the class that is located in the other project I get a NoClassDefFoundError. I can't figure out what setting I am missing to make sure that the referenced project is also deployed with it.
views:
139answers:
5On the referenced project, are you exporting the package in which the desired class is?
Project Properties -> Java EE Module Dependencies - check the required project it will be deployed in WEB-INF/lib folder.
Include the jar file from the referenced project with your project when building the WAR file. Right click on your project and select "build path" then select "configure build path" the properties window for your project should now be open. Click on "Java EE Module Dependencies" from there you can add the jar file built from the other project and when you build the WAR file that jar will be included in the WAR file which will allow you to use the classes in the other project.
In the manifest of your WAR file include an entry like
/lib/dependent.jar
Then make sure dependent.jar gets copied into the /lib
folder inside the WAR. Eclipse won't do that by default which is why most shops use ANT to build their WAR/EAR files.
If you don't want to mess with the MANIFEST file, you will have to copy the dependent.jar to somewhere on the target server and then modify the CLASSPATH of the application to include "lib-jar-folder/dependent.jar".
Apparently I have run into an issue with Eclipse. I have a few projects in my workspace and I imported my current project from another place outside of my current workspace. Moving that project into my workspace fixed the problem.