Reputation: 105
I've a maven java projects (say X & Y) and i've added Y to dependency list of the project X (pom file) and imported Y to class in X... and jars are installed to m2 repositorhy and maven build is successful with no errors at compilation, but at runtime it is thorwing a NoClassDefFoundError for the class in Y... am new to this maven please help me to resolve the issue..
java.lang.NoClassDefFoundError: ../nw_diagnosis/SocketExceptionHandler
Thanks Srikanth
Upvotes: 2
Views: 2164
Reputation: 3156
Is your X project a "jar" project, or a "war" project ?
If you build a jar, your Y project (I assume this one is a jar) is not included in the classpath of your X project, which is the normal behavior.
If so, you either have to run your X project with Y.jar in the classpath, or build your X project as a "jar-with-dependencies", see below :
Upvotes: 2
Reputation: 718688
I suspect this is a problem with an optional dependency in one of the artifacts that your application depends on.
Anyway, the general approach to solving this is:
Upvotes: 1
Reputation: 13628
Are you building on command line, then trying to run in Eclipse? M2e doesn't like that. Clean and rebuild all your projects from within eclipse then try running.
Upvotes: 0