title: CannotLoadBeanClassException when try to get a bean from applicationContext.xml
body: <p>i have just started a course about Spring framework and i am struggling getting over this exceiption: </p>
  
  <pre><code>Exception in thread "main" org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [TrackCoach] for bean with name 'myCoach' defined in class path resource [applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: TrackCoach
  at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1476)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:682)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:649)
  at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1604)
  at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1080)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:859)
  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
  at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:144)
  at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:85)
  at com.love2code.springdemo.HelloSpringApp.main(HelloSpringApp.java:9)
  </code></pre>
  
  <p>This is my main class:</p>
  
  <pre><code>package com.love2code.springdemo;
  import org.springframework.context.support.ClassPathXmlApplicationContext;
  public class HelloSpringApp {
  public static void main(String[] args) {
      //load the spring configuration file
      ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
  
      //retrieve bean from spring container
      Coach theCoach = context.getBean("myCoach", Coach.class);
  
      //call methods on the bean
      System.out.println(theCoach.getDailyWorkout());
  
      //close the context
      context.close();
  }
  }
  </code></pre>
  
  <p>My TrackCoach class:</p>
  
  <pre><code>package com.love2code.springdemo;
  public class TrackCoach implements Coach {
  
  @Override
  public String getDailyWorkout() {       
      return "Smoke 2 bl's";
  }
  }
  </code></pre>
  
  <p>And applicationContext.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns:context="http://www.springframework.org/schema/context"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans.xsd
  http://www.springframework.org/schema/context
  http://www.springframework.org/schema/context/spring-context.xsd"&gt;
  
  
  &lt;!-- Define your beans here --&gt;  
  &lt;bean id="myCoach"  class="com.luv2code.springdemo.TrackCoach"&gt;         
  &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>Could someone help me out with this please?</p>