intellij9, spring, hibernate dao unit test error

I get this error

java.lang.NoSuchMethodError: org.springframework.transaction.interceptor.TransactionAttribute.getQualifier

when I try to run this unit test in intellij

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"/scrumtious.xml"})
@TransactionConfiguration(transactionManager="tx")
public class DefectDaoTest extends AbstractTransactionalJUnit4SpringContextTests {
    private DefectDao defectDao;
    private SessionFactory sessionFactory;

    @Test
    public void testit() throws Exception {
        assertTrue(true);
    }

    @Autowired
    public void setDefectDao(DefectDao defectDao) {
        this.defectDao = defectDao;
    }

    @Autowired
    public void setSessionFactory(SessionFactory factory) {
        this.sessionFactory = factory;
    }

}

My context file is

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

  <bean id="dataSource" destroy-method="close">
    <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
    <property name="url" value="jdbc:hsqldb:mem:test"/>
    <property name="username" value="sa"/>
    <property name="password" value=""/>
  </bean>


  <bean id="sessionFactory" >
    <property name="dataSource" ref="dataSource"/>
    <property name="annotatedClasses">
      <list>
        <value>com.scrumtious.repository.Defect</value>
        <value>com.scrumtious.repository.Epic</value>
        <value>com.scrumtious.repository.Project</value>
        <value>com.scrumtious.repository.ProjectMember</value>
        <value>com.scrumtious.repository.Release</value>
        <value>com.scrumtious.repository.Role</value>
        <value>com.scrumtious.repository.Sprint</value>
        <value>com.scrumtious.repository.Status</value>
        <value>com.scrumtious.repository.Story</value>
        <value>com.scrumtious.repository.Task</value>
        <value>com.scrumtious.repository.Test</value>
      </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.hbm2ddl.auto">create</prop>
        </props>
    </property>
  </bean>


    <bean id="tx" >
      <property name="sessionFactory">
        <ref bean="sessionFactory"/>
      </property>
    </bean>

    <bean id="defectDao" >
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
</beans>

Yet if I run a maven install either from within intellij or from the command line the test passes.

I have googled and there is very little about this error

Does anyone have any idea what I am missing?

2 comments
Comment actions Permalink

Hi David,

That looks like classpath problem. I see that there is no TransactionAttribute.getQualifier() method at spring 2.5 and it looks like it's introduced at spring 3. So, the most probable reason is that there is a mix of spring 2.5 and spring 3 jars at your environment.

Denis

0
Comment actions Permalink

Hi Denis,

You were right. Thanks

David

0

Please sign in to leave a comment.