Manuel Lucero
Manuel Lucero

Reputation: 21

unable to resolve class org.apache.commons.lang3.StringUtils grails

I'm developing an application in grails version 2.2.1 with Eclipse, the problem is, when I run the app, i get the next message:

 unable to resolve class org.apache.commons.lang3.StringUtils

I add the common-lang-jar to my project and as a dependency, but i get the same issue. What can I do?

Upvotes: 2

Views: 12474

Answers (2)

user2618844
user2618844

Reputation: 352

If the answer from Burt does not work for you, make sure you have the following order in your BuildConfig:

repositories {
    grailsHome()
    mavenLocal()
    mavenRepo "http://repo1.maven.org/maven2/"
    grailsPlugins()
    grailsCentral()
    mavenCentral()
}

It helps to right-click on the your project->Build Path->Configure Build Path->Add External JARS.

Upvotes: 1

Burt Beckwith
Burt Beckwith

Reputation: 75671

You shouldn't use jar files in the lib directory unless they're not available in a Maven repo. If it's shared code at your company or something else that isn't publicly available then you can, but try to use BuildConfig.groovy dependencies if possible.

In this case the jar is available in Maven Central, so this should work in the dependencies section in BuildConfig.groovy:

compile 'org.apache.commons:commons-lang3:3.1'

In the rare cases where you do need to use a jar file in the lib directory, run grails compile --refresh-dependencies to get it added to the classpath. Newer versions of Grails don't automatically add lib directory jars to the classpath.

Upvotes: 11

Related Questions