Setup Environment - Eclipse with Maven

Originally published at: http://www.itversity.com/topic/setup-environment-eclipse-with-maven/

Introduction As part of this topic we will see how to setup and validate IDE to develop map reduce applications. Pre-requisites Download Eclipse with Maven plugin Install Eclipse with Maven plugin Create java application using Maven Project Run the default program of simple java application Setup Eclipse with Maven Plugin Following are the installation steps to…

I am unable to run “mvn install” command in my STS. I have set up STS 3.8.3. in Ubuntu 14.0.4. Java version installed is Java 8. When I run “clean”, it runs fine. But when I run “install”, it gives me below error pasted below. Are there any settings we need to do for Ubuntu ?
Please help me.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project scala-demo: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile failed: A required class was missing while executing org.apache.maven.plugins:maven-compiler-plugin:3.1:compile: org/apache/maven/shared/utils/StringUtils
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.apache.maven.plugins:maven-compiler-plugin:3.1
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/home/anveshan/MvnRepo/repository/org/apache/maven/plugins/maven-compiler-plugin/3.1/maven-compiler-plugin-3.1.jar
[ERROR] urls[1] = file:/home/anveshan/MvnRepo/repository/org/codehaus/plexus/plexus-utils/1.5.1/plexus-utils-1.5.1.jar
[ERROR] urls[2] = file:/home/anveshan/MvnRepo/repository/org/apache/maven/shared/maven-shared-utils/0.1/maven-shared-utils-0.1.jar
[ERROR] urls[3] = file:/home/anveshan/MvnRepo/repository/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.jar
[ERROR] urls[4] = file:/home/anveshan/MvnRepo/repository/org/apache/maven/shared/maven-shared-incremental/1.1/maven-shared-incremental-1.1.jar
[ERROR] urls[5] = file:/home/anveshan/MvnRepo/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
[ERROR] urls[6] = file:/home/anveshan/MvnRepo/repository/org/codehaus/plexus/plexus-compiler-api/2.2/plexus-compiler-api-2.2.jar
[ERROR] urls[7] = file:/home/anveshan/MvnRepo/repository/org/codehaus/plexus/plexus-compiler-manager/2.2/plexus-compiler-manager-2.2.jar
[ERROR] urls[8] = file:/home/anveshan/MvnRepo/repository/org/codehaus/plexus/plexus-compiler-javac/2.2/plexus-compiler-javac-2.2.jar
[ERROR] urls[9] = file:/home/anveshan/MvnRepo/repository/org/apache/xbean/xbean-reflect/3.4/xbean-reflect-3.4.jar
[ERROR] urls[10] = file:/home/anveshan/MvnRepo/repository/log4j/log4j/1.2.12/log4j-1.2.12.jar
[ERROR] urls[11] = file:/home/anveshan/MvnRepo/repository/commons-logging/commons-logging-api/1.1/commons-logging-api-1.1.jar
[ERROR] urls[12] = file:/home/anveshan/MvnRepo/repository/com/google/collections/google-collections/1.0/google-collections-1.0.jar
[ERROR] urls[13] = file:/home/anveshan/MvnRepo/repository/junit/junit/3.8.2/junit-3.8.2.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------: org.apache.maven.shared.utils.StringUtils
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project scala-demo: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile failed: A required class was missing while executing org.apache.maven.plugins:maven-compiler-plugin:3.1:compile: org/apache/maven/shared/utils/StringUtils

realm = plugin>org.apache.maven.plugins:maven-compiler-plugin:3.1
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/home/anveshan/MvnRepo/repository/org/apache/maven/plugins/maven-compiler-plugin/3.1/maven-compiler-plugin-3.1.jar
urls[1] = file:/home/anveshan/MvnRepo/repository/org/codehaus/plexus/plexus-utils/1.5.1/plexus-utils-1.5.1.jar
urls[2] = file:/home/anveshan/MvnRepo/repository/org/apache/maven/shared/maven-shared-utils/0.1/maven-shared-utils-0.1.jar
urls[3] = file:/home/anveshan/MvnRepo/repository/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.jar
urls[4] = file:/home/anveshan/MvnRepo/repository/org/apache/maven/shared/maven-shared-incremental/1.1/maven-shared-incremental-1.1.jar
urls[5] = file:/home/anveshan/MvnRepo/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
urls[6] = file:/home/anveshan/MvnRepo/repository/org/codehaus/plexus/plexus-compiler-api/2.2/plexus-compiler-api-2.2.jar
urls[7] = file:/home/anveshan/MvnRepo/repository/org/codehaus/plexus/plexus-compiler-manager/2.2/plexus-compiler-manager-2.2.jar
urls[8] = file:/home/anveshan/MvnRepo/repository/org/codehaus/plexus/plexus-compiler-javac/2.2/plexus-compiler-javac-2.2.jar
urls[9] = file:/home/anveshan/MvnRepo/repository/org/apache/xbean/xbean-reflect/3.4/xbean-reflect-3.4.jar
urls[10] = file:/home/anveshan/MvnRepo/repository/log4j/log4j/1.2.12/log4j-1.2.12.jar
urls[11] = file:/home/anveshan/MvnRepo/repository/commons-logging/commons-logging-api/1.1/commons-logging-api-1.1.jar
urls[12] = file:/home/anveshan/MvnRepo/repository/com/google/collections/google-collections/1.0/google-collections-1.0.jar
urls[13] = file:/home/anveshan/MvnRepo/repository/junit/junit/3.8.2/junit-3.8.2.jar
Number of foreign imports: 1
import: Entry[import from realm ClassRealm[maven.api, parent: null]]


at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile failed: A required class was missing while executing org.apache.maven.plugins:maven-compiler-plugin:3.1:compile: org/apache/maven/shared/utils/StringUtils

realm = plugin>org.apache.maven.plugins:maven-compiler-plugin:3.1
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/home/anveshan/MvnRepo/repository/org/apache/maven/plugins/maven-compiler-plugin/3.1/maven-compiler-plugin-3.1.jar
urls[1] = file:/home/anveshan/MvnRepo/repository/org/codehaus/plexus/plexus-utils/1.5.1/plexus-utils-1.5.1.jar
urls[2] = file:/home/anveshan/MvnRepo/repository/org/apache/maven/shared/maven-shared-utils/0.1/maven-shared-utils-0.1.jar
urls[3] = file:/home/anveshan/MvnRepo/repository/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.jar
urls[4] = file:/home/anveshan/MvnRepo/repository/org/apache/maven/shared/maven-shared-incremental/1.1/maven-shared-incremental-1.1.jar
urls[5] = file:/home/anveshan/MvnRepo/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
urls[6] = file:/home/anveshan/MvnRepo/repository/org/codehaus/plexus/plexus-compiler-api/2.2/plexus-compiler-api-2.2.jar
urls[7] = file:/home/anveshan/MvnRepo/repository/org/codehaus/plexus/plexus-compiler-manager/2.2/plexus-compiler-manager-2.2.jar
urls[8] = file:/home/anveshan/MvnRepo/repository/org/codehaus/plexus/plexus-compiler-javac/2.2/plexus-compiler-javac-2.2.jar
urls[9] = file:/home/anveshan/MvnRepo/repository/org/apache/xbean/xbean-reflect/3.4/xbean-reflect-3.4.jar
urls[10] = file:/home/anveshan/MvnRepo/repository/log4j/log4j/1.2.12/log4j-1.2.12.jar
urls[11] = file:/home/anveshan/MvnRepo/repository/commons-logging/commons-logging-api/1.1/commons-logging-api-1.1.jar
urls[12] = file:/home/anveshan/MvnRepo/repository/com/google/collections/google-collections/1.0/google-collections-1.0.jar
urls[13] = file:/home/anveshan/MvnRepo/repository/junit/junit/3.8.2/junit-3.8.2.jar
Number of foreign imports: 1
import: Entry[import from realm ClassRealm[maven.api, parent: null]]


at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:168)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more

Caused by: org.apache.maven.plugin.PluginContainerException: A required class was missing while executing org.apache.maven.plugins:maven-compiler-plugin:3.1:compile: org/apache/maven/shared/utils/StringUtils

realm = plugin>org.apache.maven.plugins:maven-compiler-plugin:3.1
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/home/anveshan/MvnRepo/repository/org/apache/maven/plugins/maven-compiler-plugin/3.1/maven-compiler-plugin-3.1.jar
urls[1] = file:/home/anveshan/MvnRepo/repository/org/codehaus/plexus/plexus-utils/1.5.1/plexus-utils-1.5.1.jar
urls[2] = file:/home/anveshan/MvnRepo/repository/org/apache/maven/shared/maven-shared-utils/0.1/maven-shared-utils-0.1.jar
urls[3] = file:/home/anveshan/MvnRepo/repository/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.jar
urls[4] = file:/home/anveshan/MvnRepo/repository/org/apache/maven/shared/maven-shared-incremental/1.1/maven-shared-incremental-1.1.jar
urls[5] = file:/home/anveshan/MvnRepo/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
urls[6] = file:/home/anveshan/MvnRepo/repository/org/codehaus/plexus/plexus-compiler-api/2.2/plexus-compiler-api-2.2.jar
urls[7] = file:/home/anveshan/MvnRepo/repository/org/codehaus/plexus/plexus-compiler-manager/2.2/plexus-compiler-manager-2.2.jar
urls[8] = file:/home/anveshan/MvnRepo/repository/org/codehaus/plexus/plexus-compiler-javac/2.2/plexus-compiler-javac-2.2.jar
urls[9] = file:/home/anveshan/MvnRepo/repository/org/apache/xbean/xbean-reflect/3.4/xbean-reflect-3.4.jar
urls[10] = file:/home/anveshan/MvnRepo/repository/log4j/log4j/1.2.12/log4j-1.2.12.jar
urls[11] = file:/home/anveshan/MvnRepo/repository/commons-logging/commons-logging-api/1.1/commons-logging-api-1.1.jar
urls[12] = file:/home/anveshan/MvnRepo/repository/com/google/collections/google-collections/1.0/google-collections-1.0.jar
urls[13] = file:/home/anveshan/MvnRepo/repository/junit/junit/3.8.2/junit-3.8.2.jar
Number of foreign imports: 1
import: Entry[import from realm ClassRealm[maven.api, parent: null]]


at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:166)
... 21 more

Caused by: java.lang.NoClassDefFoundError: org/apache/maven/shared/utils/StringUtils
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:480)
at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
… 21 more
Caused by: java.lang.ClassNotFoundException: org.apache.maven.shared.utils.StringUtils
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
… 24 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException

Is this java project or scala project?
Can you upload screenshot of your project?

Thanks for your reply . It is Maven project. The error is coming for both java and scala… Not sure why…But when I did some research and added this plugin to pom.xml it,the error vanished…I am now able to run maven install command

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.3</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
           <finalName>myJar</finalName>                 
        </configuration>
      </plugin>