Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring Integration Test: Incompatible Beans with the Same Name and Class
    primarykey
    data
    text
    <p>I'm working on resolving an odd issue I'm having with my project that has cropped up since we've started working on integration testing. What happens is that I use the "jetty-maven-plugin" to startup an instance of the application, once it's started the "maven-failsafe-plugin" starts to run the integration tests. This much is setup and running well.</p> <p>What I'm trying to do now is this: I'd like to get a handle on my service layer so that I can setup some fixtures for my tests to run against. Up until now, our integration tests have been pretty simple minded and I'd like to turn it up a notch and test the actual filling out of forms and so on. For this to work, I need to be able to setup some fixtures and then remove them so that these test are reproducible. We're running against a test database that we use for just this purpose.</p> <p>From what I've read, this is not unreasonable. Nonetheless, when I actually run the tests I get a very odd error message and stack trace. From what I can tell, Maven starts up the application in Jetty without issue. Then the failsafe plugin starts running the test and, once it hits the first integration test, it begins instantiating a Spring instance and context. It correctly pulls in it's properties and configuration files but when it tries to actually inject the service object, I am seeing this error:</p> <blockquote> <p>Caused by: org.springframework.beans.factory.BeanDefinitionSt oreException: Unexpected exception parsing XML document from class path resource [app-config.xml]; nested exception is org.springframework.context.annotation.Conflicting BeanDefinitionException: Annotation-specified bean name 'pesticideRoleRepositoryImpl' for bean class [dao.role.PesticideRoleRepositoryImpl] conflicts with existing, non-compatible bean definition of same name and class [dao.role.PesticideRoleRepositoryImpl]</p> </blockquote> <p>I will spare you all the stack trace, I can make it available at any time. ;-)</p> <p>I started wondering if I was going about this all wrong and so I went back and setup a test project in much the same way. The test project is far simpler and doesn't have this issue. When it runs the integration tests the service objects are injected without issue. If you are interested, you can take a look at <a href="https://github.com/cmiles74/wicket-todos" rel="nofollow">my test project on GitHub</a>.</p> <p><strong>My Question Is This...</strong></p> <p>Has anyone seen this error before? Could there be some conditions under which Spring will have this kind of problem?</p> <p>It's clear to me that with this kind of integration testing, I end up with two Spring containers that use the exact same configuration. I thought this might be the problem but the test project works the same way and doesn't have this issue. I'm also troubled by the fact that even though there are two beans with the same name and class, Spring believes that they are incompatible.</p> <p>Thank you, any help would be greatly appreciated! :-D</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload