Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.lang.NoClassDefFoundError for interface of included project

 
will zhang
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
will zhang
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I export project 2 as a JAR and the result is the same.
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic