Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils from BaseClassLoader

I am getting the following error, while running my following code:

java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils from BaseClassLoader

at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:448)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.dozer.util.ResourceLoader.getResource(ResourceLoader.java:53)
at org.dozer.util.DefaultClassLoader.loadResource(DefaultClassLoader.java:44)
at org.dozer.config.GlobalSettings.loadGlobalSettings(GlobalSettings.java:116)
at org.dozer.config.GlobalSettings.<init>(GlobalSettings.java:67)
at org.dozer.config.GlobalSettings.<clinit>(GlobalSettings.java:46)
at org.dozer.stats.StatisticsManagerImpl.<init>(StatisticsManagerImpl.java:39)
at org.dozer.stats.GlobalStatistics.<init>(GlobalStatistics.java:29)
at org.dozer.stats.GlobalStatistics.<clinit>(GlobalStatistics.java:24)
at org.dozer.DozerBeanMapper.<clinit>(DozerBeanMapper.java:59)

Kindly, guide me to fix the problems.

like image 834
Amit Kumar Avatar asked Jul 22 '13 07:07

Amit Kumar


4 Answers

I received the same error, I added to my pom.xml file the following lines and worked fine after maven install:

<dependencies>

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

</dependencies> 
like image 163
gogasca Avatar answered Sep 23 '22 22:09

gogasca


In case you use maven and Ubuntu 14.04:

This can be caused by the maven version included in Ubuntu 14.04, and the workaround is to download the maven tarball from http://maven.apache.org/download.cgi and use that version instead of the default version provided by the distribution.

More information: https://github.com/airbnb/chronos/issues/211

EDIT: You can also add a symlink to commons-lang.jar to avoid having to do a custom install (Source and @Shoham in the comments)

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

Verify that the paths are correct on your system before attempting. They should work for Ubuntu 14.04 OOTB, but always verify.

like image 45
mas_kur1 Avatar answered Sep 23 '22 22:09

mas_kur1


Your code seems to be using apace-commons-lang package . Do add the jar from here http://mvnrepository.com/artifact/commons-lang/commons-lang/2.6. Chek for the version you are using. Add the jar to your lib folder/classpath.

like image 24
ManMohan Vyas Avatar answered Sep 25 '22 22:09

ManMohan Vyas


Add the commons-lang jar either into WEB-INF/lib or server/lib

like image 21
Magesh Pachiyappan Avatar answered Sep 24 '22 22:09

Magesh Pachiyappan