Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've manually installed sun java 1.6.0_24 and apache maven 3.0.3 into ~/Work on Natty and when I run maven from my terminal it exits.

I've tried various other versions of maven (2.2.1, 2.0.11), previous versions of the jdk (1.6.0_23) without luck.

I've also tried logging in to tty1 and executing mvn from there the result being that my session is lost (ie I'm prompted with the host login).

I am able to duplicate this behaviour with ant so my suspicion is that something is broken in the shell/terminal emulator.

share|improve this question
    
Please have a look at the logs. It's highly unlikely that the shell or terminal emulator is broken. If maven is exiting unexpectedly, hopefully it'll log that somewhere. It sounds like it's crashing, or maybe Java itself is crashing. –  Scott Severance May 8 '11 at 3:49

2 Answers 2

If you have run more than one version of Maven (e.g., Maven2 & Maven3), then check your environment to make sure you aren't referencing more than one installation.

For example, having M2_HOME will cause mvn 3 not to run (note: I have installed various maven's & java's in /opt):

$ type mvn
mvn is /opt/maven3/bin/mvn


$ env | grep 'M.*HOME'
MAVEN_HOME=/opt/maven-1.1
M2_HOME=/opt/maven2

$ /opt/maven3/bin/mvn -v
Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/plexus/classworlds/launcher/Launcher
Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.classworlds.launcher.Launcher
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: org.codehaus.plexus.classworlds.launcher.Launcher.  Program will exit.

$ unset M2_HOME

$ /opt/maven3/bin/mvn -v
Apache Maven 3.0.3 (r1075438; 2011-02-28 09:31:09-0800)
Maven home: /opt/maven3
Java version: 1.6.0_23, vendor: Sun Microsystems Inc.
Java home: /opt/java/jdk1.6.0_23/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.35-28-generic", arch: "amd64", family: "unix"
share|improve this answer
    
This was KILLING me. unset M2_HOME fixed it. Thank you! –  sidewaysmilk May 15 '12 at 23:02
up vote 1 down vote accepted

My bad. To setup my environment to use java/maven/etc I use a series of scripts in ~/bin, for example ~/bin/env-maven; the heads of which were:

#!/bin/bash
set -e

To use the script I source as:

. ~/bin/env-maven

Which then tells bash to exit immediately if a non-zero exit code from a pipeline (ie command) is encountered and in my case running mvn without a pom.xml will do.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.