NoSuchMethodError with Spring MutableValues

jakob picture jakob · Apr 16, 2010 · Viewed 13.2k times · Source

I have written a test where i specify my application context location with annotations. I then autowire my dao into the test.

@ContextConfiguration(locations = {"file:service/src/main/webapp/WEB-INF/applicationContext.xml"}) 
public class MyTest extends AbstractTestNGSpringContextTests {

@Autowired                                      
protected MyDao myDao;                        

private PlatformTransactionManager transactionManager;
private TransactionTemplate transactionTemplate;      


@Test                                   
public void shouldSaveEntityToDb() { 
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {        
    protected void doInTransactionWithoutResult(TransactionStatus status) { 

    Entity entity = new Entity();

    //test
    myDao.save(entity)

    //assert                                                            
    assertNotNull(entity.getId());                                

  }                                                                       
});                                                                         


}

When i run the test i get an exception which states that the application context could not be loaded and it boils down to:

    Caused by: java.lang.NoSuchMethodError:
    org.springframework.beans.MutablePropertyValues.add(Ljava/lang/String;Ljava/lang/Object;)Lorg/springframework/beans/MutablePropertyValues;

I have no idea where to start looking, why do i get this error and how can i resolve it? Info springframework 3.0.2.RELEASE, Hibernate 3.4.0.GA, testng 5.9

Thank you!

Answer

axtavt picture axtavt · Apr 16, 2010

This method was added in Spring 3.0, so you probably have a pre-3.0 Spring version somewhere in classpath. Check your classpath.