开发者

NoClassDefFoundError exception when deploying dynamic web app from eclipse

开发者 https://www.devze.com 2022-12-11 04:45 出处:网络
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 othe

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 开发者_C百科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.


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


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.


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消