Nali Nali - 1 year ago 111
Java Question

Maven build fails

I imported the following package:

import org.apache.commons.lang.ArrayUtils;

I added therefore this dependency in my POM:


Then my Maven build fails and this is my error message in Jenkins:

11:07:45 INFO: [INFO] 2 errors
11:07:45 INFO: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project stripe: Compilation failure: Compilation failure:
11:07:45 INFO: [ERROR] /mnt/jenkinsSlaveWorkspace/xmakeProdSlave/workspace/somepath/util/[7,32] package org.apache.commons.lang3 does not exist
11:07:45 INFO: [ERROR] /mnt/jenkinsSlaveWorkspace/xmakeProdSlave/workspace/somepath/gen/tmp/src/src/main/java/somepath/util/[25,37] cannot find symbol
11:07:45 INFO: [ERROR] symbol: variable ArrayUtils
11:07:45 INFO: [ERROR] location: class

I read about something that I might have the wrong version or a version which is in conflict because of the version that is downloaded, so I tried 3.0, 2.6 and at the end 2.4 but nothing helped. I found a question here on StackOverflow some years ago and they talked about doing some commands in Maven. The point is I'm using a Maven plugin in Eclipse so I couldn't use the advice that was made there, anyone having the same problem?

Ray Ray
Answer Source

If your import statement is exactly as you pasted above, then use this dependency:


However, if you wish to use commons-lang's latest version, the import has to be:

import org.apache.commons.lang3.ArrayUtils;

And the latest dependency for this is:


Background: Since version 3, commons-lang depends on Java 5 (or later) and broke backwards compatibility. Consequently, the project renamed all the packages so that legacy code wouldn't stop working while enabling developers to use the added capabilities side-by-side. At the same time, the project decided to adapt the maven coordinates to the conventions.

Read more here: What's new in Commons Lang 3.0?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download