java - Resolving NoClassDefFoundError -


this question has answer here:

i trying learn spring. typed project on running it gives me error

exception in thread "main" java.lang.noclassdeffounderror: org/apache/commons/logging/logfactory @ org.springframework.context.support.abstractapplicationcontext.<init>(abstractapplicationcontext.java:145) @ org.springframework.context.support.abstractrefreshableapplicationcontext.<init>(abstractrefreshableapplicationcontext.java:84) @ org.springframework.context.support.abstractrefreshableconfigapplicationcontext.<init>(abstractrefreshableconfigapplicationcontext.java:59) @ org.springframework.context.support.abstractxmlapplicationcontext.<init>(abstractxmlapplicationcontext.java:58) @ org.springframework.context.support.classpathxmlapplicationcontext.<init>(classpathxmlapplicationcontext.java:136) @ org.springframework.context.support.classpathxmlapplicationcontext.<init>(classpathxmlapplicationcontext.java:83) @ maven.spring.trial.app.main(app.java:12) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:498) @ com.intellij.rt.execution.application.appmain.main(appmain.java:144)  caused by: java.lang.classnotfoundexception: org.apache.commons.logging.logfactory @ java.net.urlclassloader.findclass(urlclassloader.java:381) @ java.lang.classloader.loadclass(classloader.java:424) @ sun.misc.launcher$appclassloader.loadclass(launcher.java:331) @ java.lang.classloader.loadclass(classloader.java:357) ... 12 more 

i have tried many solutions given on already, adding commons-logging, via maven, downloading jar , adding external libraries.

this screenshot of tree structure-

enter image description here

my pom.xml:

<project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"      xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion>  <groupid>com.mkyong.common</groupid> <artifactid>springexamples</artifactid> <version>1.0-snapshot</version> <packaging>jar</packaging>  <name>springexamples</name> <url>http://maven.apache.org</url>  <properties>     <project.build.sourceencoding>utf-8</project.build.sourceencoding> </properties>  <dependencies>     <dependency>         <groupid>junit</groupid>         <artifactid>junit</artifactid>         <version>3.8.1</version>         <scope>test</scope>     </dependency>      <dependency>         <groupid>org.projectlombok</groupid>         <artifactid>lombok</artifactid>         <version>1.16.10</version>         <scope>provided</scope>     </dependency>      <dependency>         <groupid>commons-logging</groupid>         <artifactid>commons-logging</artifactid>         <version>1.2</version>         <scope>compile</scope>     </dependency>      <dependency>         <groupid>org.springframework</groupid>         <artifactid>spring</artifactid>         <version>2.5.6</version>     </dependency>  </dependencies> 

i running project app.java

can me this?? in advance.

if run application on servlet container or application servlet provides commons-logging library should change scope compile provided. looks this

<dependency>     <groupid>commons-logging</groupid>     <artifactid>commons-logging</artifactid>     <version>1.2</version>     <scope>provided</scope> </dependency> 

whereas should change such as:

<dependency>     <groupid>commons-logging</groupid>     <artifactid>commons-logging</artifactid>     <version>1.2</version> </dependency> 

when build application on maven, library packaged other library in war file. problem resolved

hope help!


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -