English 中文(简体)
NoClassDefFoundError exception when deploying dynamic web app from eclipse
原标题:

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.

最佳回答

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.

问题回答

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

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





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签