title: spring sample application in netbeans
body: <p>This is my code. I have gotten some errors. Can anyone help me solve the problem? I get some casting errors, like cast <code>ClassPathResource</code> to <code>Resource</code> and resource object <code>r</code> to resource.</p>
  
  <pre><code>package firstspring;
  
  import javax.annotation.Resource;
  
  import org.springframework.beans.factory.BeanFactory;
  
  import org.springframework.beans.factory.xml.XmlBeanFactory;
  
  import org.springframework.core.io.ClassPathResource;
  
  import org.springframework.core.io.Resource;
  
  public class test {
  
  public static void main(String[] args){
  
  Resource r =new ClassPathResource("applicationContext.xml");
  
  
  BeanFactory bf=new XmlBeanFactory(r);
  
  Student stud=(Student)bf.getBean("first");
  
  stud.display();
  
  } 
  
  }
  </code></pre>
  
  <p>This is my XML file;</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:p="http://www.springframework.org/schema/p"
  
   xsi:schemaLocation="http://www.springframework.org/schema/beans
  
  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"&gt;
  
  &lt;bean id="first" class="Student"&gt;
  
  &lt;property name="name" value="sneha"&gt;&lt;/property&gt;    
  
  &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>