views:

139

answers:

5

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.

A: 

On the referenced project, are you exporting the package in which the desired class is?

Mario Marinato -br-
When I go into the project Order and Export settings, the source folder is checked for Export.
Casey
+2  A: 

Project Properties -> Java EE Module Dependencies - check the required project it will be deployed in WEB-INF/lib folder.

cetnar
This is checked. Still fails to find the class.
Casey
Can you see what is deployed to the server? Is it there jar with your dependency project? Maybe you need to clean/full build and then publish again whole application.
cetnar
A: 

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.

ChadNC
A: 

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".

Kelly French
+1  A: 

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.

Casey
Same thing happened to me - deleting the other projects in that workspace and cleaning the project got rid of the issue.
Amber Shah