title: How do I get JUnit4 annotations to work in Spring2.5?
body: <p>I've been trying to create a JUnit test for my DAO that uses Hibernate and is linked to the database via Spring in my applicationContext.xml file.</p>
  
  <p>The error only occurs when adding:</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  </code></pre>
  
  <p>Otherwise I get a null pointer exception to the partDao, which is expected because it isn't linking.</p>
  
  <p>Normally I'd just say scrap it and continue developing without JUnit tests, but I would prefer to start using it in my projects.</p>
  
  <p>Here is the error:</p>
  
  <pre><code>Testsuite: SpecBuilder.webapp.dao.PartDaoTest
  Exception in thread "main" java.lang.NoSuchMethodError: org.junit.runner.notification.RunNotifier.testAborted(Lorg/junit/runner/Description;Ljava/lang/Throwable;)V
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:146)
      at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:59)
      at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:52)
      at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)
      at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44)
      at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:50)
      at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:39)
      at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:515)
      at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:1031)
      at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:888)
  Test SpecBuilder.webapp.dao.PartDaoTest FAILED (crashed)
  /home/zclark/Projects/SpecBuilder/nbproject/build-impl.xml:798: Some tests failed; see details above.
  BUILD FAILED (total time: 2 seconds)
  </code></pre>
  
  <p>Here is my test class:</p>
  
  <pre><code>package SpecBuilder.webapp.dao;
  
  import org.junit.Test;
  import static org.junit.Assert.*;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.junit.runner.RunWith;
  import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
  import org.springframework.test.context.ContextConfiguration;
  
  @RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration(locations="{applicationContext.xml}")
  public class PartDaoTest {
  
      @Autowired
      PartDao partDao;
  
      public PartDaoTest() {}
  
      @Test
      public void autowireTest() {
          assertNotNull(partDao);
      }
  }
  </code></pre>
  
  <p>And here is my applicationContext:</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"
     xmlns:aop="http://www.springframework.org/schema/aop"
     xmlns:tx="http://www.springframework.org/schema/tx"
     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"&gt;
  
      &lt;bean id="propertyConfigurer"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
        p:location="/WEB-INF/specbuilder.properties"/&gt;
  
      &lt;bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource"
        p:driverClassName="${jdbc.driverClassName}"
        p:url="${jdbc.url}"
        p:username="${jdbc.username}"
        p:password="${jdbc.password}" /&gt;
  
      &lt;bean id="partDao" class="SpecBuilder.webapp.dao.PartDao"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory"/&gt;
      &lt;/bean&gt;
  
      &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource"/&gt;
          &lt;property name="annotatedClasses"&gt;
              &lt;list&gt;
                  &lt;value&gt;SpecBuilder.webapp.model.Part&lt;/value&gt;
              &lt;/list&gt;
          &lt;/property&gt;
          &lt;property name="hibernateProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="hibernate.dialect"&gt;${hibernate.dialect}&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>Any ideas?</p>