I have a Java project X has dependency (in pom file) on project Y.
I was modifying in Y and build X,Y with Maven tool then runing X (on JBoss) without problems.
When I added new class in Y then building with Maven (without problems), then running X, it throws java.lang.NoClassDefFoundError
for the new class.
I think its a Maven dependency versioning or something like that ... I searched mainly at Google but nothing has effect... How to resolve this problem??
Did you install/deploy the new version of Y, upgrade X's dependencies for the new Y version, and re-build X?
Did you try mvn clean on project Y before you built it?
Did you run
mvn install
on Y after adding the new class?Moro, you wrote in a comment that X has the following dependency declared:
First point. You are using a "fixed" version here (as opposed to "
SNAPSHOT
"). When usingSNAPSHOT
, maven will automatically grab the latestSNAPSHOT
every time you build. On the other hand, when you are using 1.0, once maven has downloaded this artifact, it never tries to get a new 1.0. So, you should increment Y's version or, if Y is under active development (enhancements, bug fixes, etc), you should really useSNAPSHOT
. For more informations aboutSNAPSHOT
, check out the chapter 9.3.1.2. SNAPSHOT Versions of Sonatype's book:Second point. You are using a
provided
scope. According to the chapter 9.4.1. Dependency Scope:Is this really what you want? How are you deploying X and Y on JBoss? Shouldn't you use the default
compile
scope?Maven resolves dependencies from local and remote repositories, though IDE plugins such as m2eclipse will also resolve dependencies that are projects within the workspace. If you don't have such a plugin, you will need to install artifact Y to a local repository or deploy it to a remote repository so that you and your peers can access it before Maven will recognise that a change has been made when building project X.
workspace resolution screenshot http://docs.codehaus.org/download/attachments/11403480/project-properties.png
If the two projects are closely related, you could consider creating a multi-module build so that projects X and Y are built at the same time.
Ok, sorry for late info.
The X package is ejb, so the X.jar has no lib directory.
Then Y.jar should be placed in the Jboss/server/default/lib, it worked correctly.
Thanx for all.