Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » java.lang.NoClassDefFoundError commons-logging but is in the build path
java.lang.NoClassDefFoundError commons-logging but is in the build path [message #1839007] Thu, 11 March 2021 09:40 Go to next message
Eduardo Gutierrez is currently offline Eduardo GutierrezFriend
Messages: 33
Registered: December 2017
Member
Hi i cant run a java application with this error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
    at org.especialistajee.jhd.filmoteca.dao.FilePeliculaDAO.<clinit>(FilePeliculaDAO.java:25)
    at org.especialistajee.jhd.filmoteca.dao.GestorDAO.getPeliculaDAO(GestorDAO.java:15)
    at org.especialistajee.jhd.filmoteca.Main.agregarPelicula(Main.java:61)
    at org.especialistajee.jhd.filmoteca.Main.mostrarMenu(Main.java:43)
    at org.especialistajee.jhd.filmoteca.Main.main(Main.java:25)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    ... 5 more


Im using Eclipse and i have this project setup:

enter image description here


https://i.stack.imgur.com/k0KLV.png

I have googled and seek for answers, but all seems to be solved including common-loggings in classpath. Ans seems its done...

Some code i want to test:

  package org.especialistajee.jhd.filmoteca.dao;


//import org.apache.log4j.*;
import org.especialistajee.jhd.filmoteca.Messages;
import org.especialistajee.jhd.filmoteca.to.PeliculaTO;
//import java.lang.System.Logger;
import java.util.List;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;




/**
 * Implementacion del acceso a los datos de las peliculas almacenados en un fichero
 * en el disco.
 * @author malozano
 *
 */
public class FilePeliculaDAO  {
    
    private static Log logger = LogFactory.getLog(FilePeliculaDAO.class);
    
    /**
     * Agrega una pelicula a nuestro fichero de peliculas.
     * @param p Pelicula que se agregara. Se producira un error si la pelicula
     * ya existe en el fichero, o si el parametro es <code>null</code>.
     */
    public void addPelicula(PeliculaTO p) {
    
        System.out.println("Agregando en el fichero la pelicula " + p.getTitulo() + " con id " + p.getId());
            //logger.debug("Agregando en el fichero la pelicula "+ p.getTitulo() + " con id " + p.getId());
        
            logger.error("Error  agregando : " );
        
        
    } ...more code


Any help would be apreciated
  • Attachment: k0KLV.png
    (Size: 241.63KB, Downloaded 12 times)
Re: java.lang.NoClassDefFoundError commons-logging but is in the build path [message #1839043 is a reply to message #1839007] Thu, 11 March 2021 16:53 Go to previous message
David M. Karr is currently offline David M. KarrFriend
Messages: 730
Registered: July 2009
Senior Member
Generally, using Maven (or perhaps Gradle) to manage your dependencies is more effective, as opposed to manually adding jars to the build path.

How are you running your application?
Previous Topic:Please share your experience of using Kotlin in Eclipse
Next Topic:Problem with Java ACM or JDK
Goto Forum:
  


Current Time: Tue Aug 03 22:32:38 GMT 2021

Powered by FUDForum. Page generated in 0.02071 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top