Vishal Desai
Vishal Desai

Reputation: 327

NoClassDefFoundError : org.apache.commons.lang.StringUtils

Caused by: java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
    at org.apache.maven.wagon.providers.file.FileWagon.resolveDestinationPath(FileWagon.java:206)
    at org.apache.maven.wagon.providers.file.FileWagon.putDirectory(FileWagon.java:157)
    at org.apache.maven.plugins.site.deploy.AbstractDeployMojo.push(AbstractDeployMojo.java:441)
    at org.apache.maven.plugins.site.deploy.AbstractDeployMojo.deploy(AbstractDeployMojo.java:323)
    at org.apache.maven.plugins.site.deploy.AbstractDeployMojo.deployTo(AbstractDeployMojo.java:284)
    at org.apache.maven.plugins.site.deploy.AbstractDeployMojo.execute(AbstractDeployMojo.java:166)
    at org.apache.maven.plugins.site.deploy.SiteStageMojo.execute(SiteStageMojo.java:78)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
    ... 20 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:235)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)
    ... 28 more

This happens when I try to run

mvn site site:stage              

pom.xml is:

<dependencyManagement>
    <dependencies>
        <!-- Appengine Dependencies -->
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-1.0-sdk</artifactId>
            <version>${appengine.target.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-testing</artifactId>
            <version>${appengine.target.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-stubs</artifactId>
            <version>${appengine.target.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-labs</artifactId>
            <version>${appengine.target.version}</version>
        </dependency>
        <!-- Libraries -->
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>18.0</version>
        </dependency>
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.lambdaj</groupId>
            <artifactId>lambdaj</artifactId>
            <version>2.3.3</version>
        </dependency>
    </dependencies>
</dependencyManagement>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-site-plugin</artifactId>
            <version>3.4</version>
            <configuration>
                <port>9000</port>
                <tempWebappDirectory>${basedir}/target/site/tempdir</tempWebappDirectory>
            </configuration>
            <executions>
                <execution>
                    <id>attach-descriptor</id>
                    <goals>
                        <goal>attach-descriptor</goal>
                    </goals>
                </execution>
            </executions>       
        </plugin>
    </plugins>
    <pluginManagement>
        <plugins>
            <!--This plugin's configuration is used to store Eclipse m2e settings 
                only. It has no influence on the Maven build itself. -->
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>
                                        org.codehaus.mojo
                                    </groupId>
                                    <artifactId>
                                        versions-maven-plugin
                                    </artifactId>
                                    <versionRange>
                                        [2.1,)
                                    </versionRange>
                                    <goals>
                                        <goal>
                                            display-dependency-updates
                                        </goal>
                                        <goal>
                                            display-plugin-updates
                                        </goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore></ignore>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
            <!-- standard plugins -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
                <version>2.1</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <version>3.2</version>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.5</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.7</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.5.2</version>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>2.7</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.5</version>
            </plugin>
            <!-- appengine -->
            <plugin>
                <groupId>com.google.appengine</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>${appengine.target.version}</version>
                <configuration>
                    <enableJarClasses>false</enableJarClasses>
                    <!-- Comment in the below snippet to bind to all IPs instead of just 
                        localhost -->
                    <!-- address>0.0.0.0</address> <port>8080</port -->
                    <!-- Comment in the below snippet to enable local debugging with a remove 
                        debugger like those included with Eclipse or IntelliJ -->
                    <!-- jvmFlags> <jvmFlag>-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n</jvmFlag> 
                        </jvmFlags -->
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.17</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>2.17</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.17</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.9</version>
            </plugin>
        </plugins>
    </pluginManagement>
</build>
<reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-project-info-reports-plugin</artifactId>
            <version>2.7</version>
            <reportSets>
                <reportSet>
                    <reports>
                        <report>index</report>
                        <report>dependencies</report>
                        <report>dependency-convergence</report>
                        <report>dependency-management</report>
                        <report>distribution-management</report>
                        <report>modules</report>
                        <report>plugin-management</report>
                        <report>plugins</report>
                        <report>summary</report>
                        <report>issue-tracking</report>
                        <report>scm</report>
                    </reports>
                </reportSet>
            </reportSets>
        </plugin>
    </plugins>
</reporting>

In the repository I see that in commons-lang/commons-lang/ folder
there are four of them 2.1, 2.4, 2.5, 2.6 but 2.1 and 2.4 has no jar in the folder just the other files. There are jars in 2.5 and 2.6 folders.
And in org/apache/commons/commons-lang3 folder I see one 3.1 with the jar

I have broken this down to the point of absolute basic observation so that someone with the similar experience could help me out.

Upvotes: 13

Views: 39673

Answers (7)

Prabhakar Kumar Ojha
Prabhakar Kumar Ojha

Reputation: 59

You should change the commons-lang3.jar dependency version in pom.xml. if you are doing code in java simple project add another jar whatever version you are using. or you can check jar replication shouldn't be there.

Upvotes: 1

naresh meena
naresh meena

Reputation: 49

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.6:stage (default-cli) on project a1: Execution default-cli of goal org.apache.maven.plugins:maven-site-plugin:3.6:stage failed: A required class was missing while executing org.apache.maven.plugins:maven-site-plugin:3.6:stage: org/apache/commons/lang/StringUtils

Number of foreign imports: 1 import: Entry[import from realm ClassRealm[maven.api, parent: null]]


at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:125)
... 20 more

Caused by: java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils at org.apache.maven.wagon.providers.file.FileWagon.resolveDestinationPath(FileWagon.java:206) at org.apache.maven.wagon.providers.file.FileWagon.putDirectory(FileWagon.java:157) at org.apache.maven.plugins.site.deploy.AbstractDeployMojo.push(AbstractDeployMojo.java:452) at org.apache.maven.plugins.site.deploy.AbstractDeployMojo.deploy(AbstractDeployMojo.java:332) at org.apache.maven.plugins.site.deploy.AbstractDeployMojo.deployTo(AbstractDeployMojo.java:293) at org.apache.maven.plugins.site.deploy.AbstractDeployMojo.execute(AbstractDeployMojo.java:172) at org.apache.maven.plugins.site.deploy.SiteStageMojo.execute(SiteStageMojo.java:71) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) ... 20 more Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50) at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259) at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:235) at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)

org.apache.commons.lang.StringUtils missing when running Maven on Ubuntu

Some Maven goals like site:stage fail under Ubuntu 14.04 with

A required class was missing while executing
    org.apache.maven.plugins:maven-site-plugin:3.4:stage: org/apache/commons/lang/StringUtils 

This happens if you use the Ubuntu Maven package which misses the commons-lang dependency. You can either unpack a stand-alone Maven archive or use the following commands: cd /usr/share/maven/lib sudo ln -s ../../java/commons-lang.jar . https://wiki.apache.org/commons/VfsProblems

Upvotes: 0

Sergi
Sergi

Reputation: 1015

For me it seems that the problem was in accessing artifact in local maven repository, so I just deleted the whole org/apache folder from local maven repo and it fixed the problem.

Upvotes: 1

Piotr Findeisen
Piotr Findeisen

Reputation: 20730

Since OP did not specify details I guess this may be about running maven on Ubuntu 14.

Maven packaging on Ubuntu seems to have some "issue". After apt-get install maven in Ubuntu 14.04.1 LTS and attempting to package my project with mvn package I got the same exception.

Workaround from comment on github is:

sudo ln -s ../../java/commons-lang.jar /usr/share/maven/lib

That fixed maven at least in my case.

Upvotes: 8

Mick Williams
Mick Williams

Reputation: 96

Check your version of commons-lang, mine was version 2.6 used sudo find / | grep commons-lang

add to the dependencies before plugins and ensure id starts with I not i:

<dependency> 
    <groupId>commons-lang</groupId> 
    <artifactId>commons-lang</artifactId> 
    <version>2.6</version>
</dependency> 

Does not build as per wiki there is no controller/opendaylight/distribution/opendaylight/target in order to ./run.sh So I am looking for that now ??

Upvotes: 8

Jens
Jens

Reputation: 69440

You do not declare commons-lang as a dependency. Add

<dependencies>
<dependency>
    <groupId>commons-lang</groupId>
    <artifactId>commons-lang</artifactId>
    <version>2.3</version>
</dependency>
</dependencies>

To your pom.xml

Your pom.xml should looks like:

<dependencies>
<dependency>
    <groupId>commons-lang</groupId>
    <artifactId>commons-lang</artifactId>
    <version>2.3</version>
</dependency>
</dependencies>

<dependencyManagement>
    <dependencies>
        <!-- Appengine Dependencies -->
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-1.0-sdk</artifactId>
            <version>${appengine.target.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-testing</artifactId>
            <version>${appengine.target.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-stubs</artifactId>
            <version>${appengine.target.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-labs</artifactId>
            <version>${appengine.target.version}</version>
        </dependency>
        <!-- Libraries -->
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>18.0</version>
        </dependency>
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.lambdaj</groupId>
            <artifactId>lambdaj</artifactId>
            <version>2.3.3</version>
        </dependency>
    </dependencies>
</dependencyManagement>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-site-plugin</artifactId>
            <version>3.4</version>
            <configuration>
                <port>9000</port>
                <tempWebappDirectory>${basedir}/target/site/tempdir</tempWebappDirectory>
            </configuration>
            <executions>
                <execution>
                    <id>attach-descriptor</id>
                    <goals>
                        <goal>attach-descriptor</goal>
                    </goals>
                </execution>
            </executions>       
        </plugin>
    </plugins>
    <pluginManagement>
        <plugins>
            <!--This plugin's configuration is used to store Eclipse m2e settings 
                only. It has no influence on the Maven build itself. -->
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>
                                        org.codehaus.mojo
                                    </groupId>
                                    <artifactId>
                                        versions-maven-plugin
                                    </artifactId>
                                    <versionRange>
                                        [2.1,)
                                    </versionRange>
                                    <goals>
                                        <goal>
                                            display-dependency-updates
                                        </goal>
                                        <goal>
                                            display-plugin-updates
                                        </goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore></ignore>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
            <!-- standard plugins -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
                <version>2.1</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <version>3.2</version>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.5</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.7</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.5.2</version>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>2.7</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.5</version>
            </plugin>
            <!-- appengine -->
            <plugin>
                <groupId>com.google.appengine</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>${appengine.target.version}</version>
                <configuration>
                    <enableJarClasses>false</enableJarClasses>
                    <!-- Comment in the below snippet to bind to all IPs instead of just 
                        localhost -->
                    <!-- address>0.0.0.0</address> <port>8080</port -->
                    <!-- Comment in the below snippet to enable local debugging with a remove 
                        debugger like those included with Eclipse or IntelliJ -->
                    <!-- jvmFlags> <jvmFlag>-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n</jvmFlag> 
                        </jvmFlags -->
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.17</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>2.17</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.17</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.9</version>
            </plugin>
        </plugins>
    </pluginManagement>
</build>
<reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-project-info-reports-plugin</artifactId>
            <version>2.7</version>
            <reportSets>
                <reportSet>
                    <reports>
                        <report>index</report>
                        <report>dependencies</report>
                        <report>dependency-convergence</report>
                        <report>dependency-management</report>
                        <report>distribution-management</report>
                        <report>modules</report>
                        <report>plugin-management</report>
                        <report>plugins</report>
                        <report>summary</report>
                        <report>issue-tracking</report>
                        <report>scm</report>
                    </reports>
                </reportSet>
            </reportSets>
        </plugin>
    </plugins>
</reporting>

Upvotes: 3

ranj
ranj

Reputation: 33

Try adding this dependency to your pom.xml

<dependency>
    <groupId>commons-lang</groupId>
    <artifactId>commons-lang</artifactId>
    <version>2.6</version>
</dependency>

Upvotes: 2

Related Questions