wood burning stoves*
The moose likes Struts and the fly likes java.lang.NoClassDefFoundError for interface of included project Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "java.lang.NoClassDefFoundError for interface of included project" Watch "java.lang.NoClassDefFoundError for interface of included project" New topic
Author

java.lang.NoClassDefFoundError for interface of included project

will zhang
Ranch Hand

Joined: Sep 11, 2008
Posts: 46
Dear all,
Here's my situation:

In project 1, I include project 2 in order to use interfaces (interface A, B, C, D.....) of project 2.
For one of the interfaces, A, the system always claim java.lang.NoClassDefFoundError while others are working fine.

If I move interface A from project 2 to project 1, it works.

I named interface A "User.java", is the name the reason which causes this problem, because in interceptor setting, I have <interceptor-stack name="user">. But after I change the name, still doesn't work.

Anyone can help? Thanks very much.

Error message:
Lorand Komaromi
Ranch Hand

Joined: Oct 08, 2009
Posts: 276
will zhang wrote:In project 1, I include project 2 in order to use interfaces


How do you "include" project 2? When deployed, are the required classes/interfaces in you web application's /WEB-INF/classes and jars in /WEB-INF/lib?


OCJP 6 (93%)
will zhang
Ranch Hand

Joined: Sep 11, 2008
Posts: 46
Lorand Komaromi wrote:
will zhang wrote:In project 1, I include project 2 in order to use interfaces


How do you "include" project 2? When deployed, are the required classes/interfaces in you web application's /WEB-INF/classes and jars in /WEB-INF/lib?


I use eclipse to add project 2 to java build path of project 1. I used this method many times to include another project, it works fine.
will zhang
Ranch Hand

Joined: Sep 11, 2008
Posts: 46
I export project 2 as a JAR and the result is the same.
Lorand Komaromi
Ranch Hand

Joined: Oct 08, 2009
Posts: 276
will zhang wrote:I export project 2 as a JAR and the result is the same.


Did you add the jar to WEB-INF/lib..?
will zhang
Ranch Hand

Joined: Sep 11, 2008
Posts: 46
Lorand Komaromi wrote:
will zhang wrote:I export project 2 as a JAR and the result is the same.


Did you add the jar to WEB-INF/lib..?


Adding the jar into WEB-INF/lib solved the problem. Thanks!

I wonder what's the difference between putting jar in build path and putting jar in WEB-INF/lib. Appreciate!
Lorand Komaromi
Ranch Hand

Joined: Oct 08, 2009
Posts: 276
will zhang wrote:I wonder what's the difference between putting jar in build path and putting jar in WEB-INF/lib. Appreciate!


If it's in the build path, Eclipse will be able to compile the project and offer its classes when you hit Ctrl+space, but if it's not in the right folder, it won't be found when your application is deployed. The latest Eclipse automatically adds the jars from WEB-INF/lib to your project's build path!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: java.lang.NoClassDefFoundError for interface of included project
 
Similar Threads
Problem with configurate Spring and Hibernate
SEVERE: Context initialization failed org.springframework.beans.factory.BeanCreationException
bean binding error
Spring error when injecting beans
Error in classdef