Hi, am using MyEclipse. The tutorial is on Hibernate & Spring ...

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
	at org.springframework.beans.factory.support.AbstractBeanFactory.<init>(AbstractBeanFactory.java:94)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.<init>(AbstractAutowireCapableBeanFactory.java:109)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.<init>(AbstractAutowireCapableBeanFactory.java:118)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.<init>(DefaultListableBeanFactory.java:87)
	at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:72)
	at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:61)
	at com.myeclipse.hibernatespring.BusinessLogic.main(BusinessLogic.java:23)

I do have the commons-loggin.jar added to the Java Build Path ...

My class ...

package com.myeclipse.hibernatespring;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;

public class BusinessLogic 
{
	public static void main(String[] args) 
	{
		/* 1. Create new user  */
		Integer id = new Integer(1);
		User user = new User();
		
		user.setUserId(id);
		user.setUsername("snx20");
		user.setPassword("102077");
		user.setFirstName("Sonx");
		user.setLastName("Nkukwi");
		user.setDateCreated(Integer.valueOf((int) System.currentTimeMillis()));	
	
		/* 2. Load the Spring bean configuration and create a bean factory */
		BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource ("applicationContext.xml"));
		
		/* 3. Create instance of PersistanceLayer */
		PersistenceLayer persistenceLayer = (PersistenceLayer) beanFactory.getBean("persistenceLayer");
		
		/* 4. Save the new user to the database */
		persistenceLayer.addUser(user);
		
		/* 5. Confirm that your user was added */ 
		 User userLoadedFromDB = persistenceLayer.findUserById(id);
		 
		 System.out.print("User Loaded from DB [username="
				 	+ userLoadedFromDB.getUsername() + ", password="
				 	+ userLoadedFromDB.getPassword() + ", firstName="
				 	+ userLoadedFromDB.getFirstName() + ", lastName="
				 	+ userLoadedFromDB.getLastName() + "]"); 	
		 
		 /* 6. Update the user */
		 userLoadedFromDB.setFirstName("Lungile");
		 persistenceLayer.updateUser(userLoadedFromDB);
		 
		 /* Confirm that the update worked */
		 User userLoadedFromDBAgain = persistenceLayer.findUserById(id);
		 System.out.print("User Loaded from DB Again [fistName="
				 	+ userLoadedFromDBAgain.getFirstName() + "]");
	
		 /* 8. Delete the user */
		persistenceLayer.deleteUser(user); 
	}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.