No bean found during integration testing
Asked by Christopher Klinge:

Hi,

I'm working on a new plugin and I'd like to use both unit and integration testing from the start. Getting the basics right worked just fine, but I am now trying to test a custom content type and the integration tests fail due to not being able to find a bean. The plugin loads perfectly fine otherwise and I have no idea as to why it refuses to run the tests.

This is the error I get upon running *atlas-integration-test*on my plugin:

```
[INFO] [talledLocalContainer] org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'de.cyclonit.confluence.plugin.content.ContentType': Unsatisfied dependency expressed through constructor argument with index 0 of type [com.atlassian.confluence.core.ContentPermissionManager]: No qualifying bean of type [com.atlassian.confluence.core.ContentPermissionManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory
.NoSuchBeanDefinitionException: No qualifying bean of type [com.atlassian.confluence.core.ContentPermissionManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
[INFO] [talledLocalContainer]?? at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
[INFO] [talledLocalContainer]?? at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:185)
[INFO] [talledLocalContainer]?? at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1143)
[INFO] [talledLocalContainer]?? at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1046)
[INFO] [talledLocalContainer]?? at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
[INFO] [talledLocalContainer]?? at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
[INFO] [talledLocalContainer]?? at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:342)
[INFO] [talledLocalContainer]?? at sun.reflect.GeneratedMethodAccessor171.invoke(Unknown Source)
[INFO] [talledLocalContainer]?? at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO] [talledLocalContainer]?? at java.lang.reflect.Method.invoke(Method.java:497)
[INFO] [talledLocalContainer]?? at com.atlassian.plugin.osgi.spring.DefaultSpringContainerAccessor.createBean(DefaultSpringContainerAccessor.java:97)
[INFO] [talledLocalContainer]?? at com.atlassian.confluence.plugin.ConfluencePluginUtils.instantiatePluginModule(ConfluencePluginUtils.java:150)
[INFO] [talledLocalContainer]?? at com.atlassian.confluence.content.ContentTypeModuleDescriptor.createModule(ContentTypeModuleDescriptor.java:61)
[INFO] [talledLocalContainer]?? at com.atlassian.confluence.content.ContentTypeModuleDescriptor.createModule(ContentTypeModuleDescriptor.java:21)
[INFO] [talledLocalContainer]?? at com.atlassian.confluence.plugin.module.PluginModuleHolder.createModule(PluginModuleHolder.java:70)
[INFO] [talledLocalContainer]?? at com.atlassian.confluence.plugin.module.PluginModuleHolder.getModule(PluginModuleHolder.java:93)
[...] 
```

All resources regarding integration testing in Confluence I could find are entirely out of date and haven't been of any help thus far.


Answers:
author: Mark Bereznitsky
body: You could be missing an @ComponentImport annotation in your constructor, like this:

```
@ComponentImport ContentPermissionManager contentPermissionManager
```

If it doesn't do the trick, you might have to show us the Java code around your bean constructor.  

Hope this was useful :)


Tags: app

java

server

spring