[
http://jira.codehaus.org/browse/MNG-4668?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=220382#action_220382
]
Karla Jacobsen commented on MNG-4668:
-------------------------------------
Good point. Plus, I just found one reason why M2_HOME is used at all
(http://maven.apache.org/guides/development/guide-building-m2.html), and it
makes sense to not strictly enforce the match. Yet, I still think more should
be done to prevent those "subtle errors" that I was talking about before. The
warning message helps, but a single message at the beginning of a build will
easily be overlooked. I just don't know what, other than strict enforcing,
could be done. Maybe, a prominent warning message at the end of a build?? Maybe
the ant script and the .bat script shouldn't use the sample variable??
Just to clarify my position, let me add an example of my dilemma. On my
machine, I have 3 versions of Maven installed (2.09, 2.2.1, and 3.0-beta-1)
which I have to switch between depending on the project I'm working on.
(Different projects use different Maven versions for various reasons such as
restrictions imposed by companies were are collaborating with,
incompatibilities between plugins and Maven versions, and other factors that I
can't control). My M2_HOME was set to C:\maven\apache-maven-2.0.9. When I had
to switch from 2.0.9 to 2.2.1 on the commandline, I was simply executing
"C:\maven\apache-maven-2.2.1\bin\mvn ..." and assumed that was enough. However,
now I see that this still invokes 2.0.9. Of course, there are some work arounds
like removing the M2_HOME property from my environment variables or resetting
it every time, but in my case this isn't practical and it still doesn't take
care of the case when people don't realize that this could potentially be a
problem. I'm convinced that this subtlety was responsible for at least some of
my most confusing problems early on.
I feel like I'm putting a lot of thought into a problem which won't be
encountered very often, but I still think it should be addressed.
> Error executing from commandline on Windows (Exception in thread "main"
> java.lang.NoClassDefFoundError:
> org/codehaus/plexus/classworlds/launcher/Launcher)
> ----------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: MNG-4668
> URL: http://jira.codehaus.org/browse/MNG-4668
> Project: Maven 2 & 3
> Issue Type: Bug
> Components: Command Line
> Affects Versions: 3.0-beta-1
> Environment: Window XP
> Reporter: Karla Jacobsen
> Attachments: mvn_bat_exit_patch.txt, mvn_bat_noexit_patch.txt
>
>
> I get the following error when trying to execute from the commandline:
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/codehaus/plexus/classworlds/launcher/Launcher
> The problem appears when a user has multiple Maven installations and has
> previously set M2_HOME. If M2_HOME points to an installation other than the
> one currently trying to run, and the M2_HOME installation does not have the
> same classworlds jar (plexus-classworlds-*.jar versus classworlds-*.jar), the
> test cases in the .bat script will succeed, but Maven will fail.
> I've attached two possible patches because I wasn't sure what the preferred
> behavior would be. The mvn_bat_noexit_patch.txt adds a check to make sure
> that the M2_HOME directory matches up with the script's parent directory. If
> the directories do not match, it prints a warning message and continued
> executing. This assumes that either there are cases in which we may want to
> allow the batch script's directory and M2_HOME to differ, or we just want to
> give someone a helpful message if the difference breaks things.
> The second patch, mvn_bat_exit_patch.txt adds the same check and exits with
> an error message if the directories don't match. I think this is the better
> approach. It cuts down on the possibility of subtle errors down the road.
> The same changes will probably need to be made to the mvnDebug.bat.
> I did not check whether any of the other scripts need to be updated.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira