hygieia/hygieia-build-jenkins-collector

Hygieia Jenkins-Build Collector not starting with UnsatisfiedDependencyException

jar145 opened this issue ยท 24 comments

I posted this on Stackoverflow and it hasn't really seen any traffic so I'm creating an issue as it does seem like a bug to me.

I am having a problem getting the Jenkins-build collector working. I am using the latest hygieia-core and latest hygieia-build-jenkins-collector. I can get the rally, sonar, and github collectors running fine as well as a custom collector that I have built. I am on a Mac (locally run with no containers for now) and am building and running the collector with the following commands. Again, I have gotten the other collectors working in the same way.

mvn clean install package -q

java -jar ~/Sandbox/hygieia-dashboard/collectors/build/jenkins/target/jenkins-build-collector.jar --spring.config.name=jenkins --spring.config.location=/Users/[my username]/Sandbox/hygieia-dashboard/collectors/build/jenkins/application.properties

Here is my application.properties file.

dbname=dashboarddb

# Database HostName - default is localhost
dbhost=localhost

# Database Port - default is 27017
dbport=27018

# MongoDB replicaset
dbreplicaset=false
#dbhostport=[host1:port1,host2:port2,host3:port3]

# Database Username - default is blank
dbusername=dashboarduser

# Database Password - default is blank
dbpassword=dbpassword

# Collector schedule (required)
jenkins.cron=0 0/2 * * * *

# The page size
jenkins.pageSize=1000

# The folder depth - default is 10
jenkins.folderDepth=10

# Jenkins server (required) - Can provide multiple
jenkins.servers[0]=[my jenkins url]

# If using username/token for API authentication
# (required for Cloudbees Jenkins Ops Center) For example,
jenkins.servers[1]=http://[username]:[api-token]@[my jenkins url]

# Another option: If using same username/password Jenkins auth,
# set username/apiKey to use HTTP Basic Auth (blank=no auth)
jenkins.usernames[0]=[username]
jenkins.apiKeys[0]=[api-token]

# Determines if build console log is collected - defaults to false
jenkins.saveLog=true

# Search criteria enabled via properties (max search criteria = 2)
jenkins.searchFields[0]= options.jobName
jenkins.searchFields[1]= niceName

# Timeout values
jenkins.connectTimeout=20000
jenkins.readTimeout=20000

Below is my output. I added where the error is shown when it attempts to start, but let me know if you would like the whole thing.

2019-11-13 14:35:37,756 [main] ERROR o.s.boot.SpringApplication - Application startup failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'hudsonCollectorTask' defined in URL [jar:file:/Users/anderja1/Sandbox/hygieia-dashboard/collectors/build/jenkins/target/jenkins-build-collector.jar!/com/capitalone/dashboard/collector/HudsonCollectorTask.class]: Unsatisfied dependency expressed through constructor argument with index 4 of type [com.capitalone.dashboard.repository.CollItemConfigHistoryRepository]: No qualifying bean of type [com.capitalone.dashboard.repository.CollItemConfigHistoryRepository] is defined: expected single matching bean but found 2: collItemConfigHistoryRepository,sonarProfileRepostory; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [com.capitalone.dashboard.repository.CollItemConfigHistoryRepository] is defined: expected single matching bean but found 2: collItemConfigHistoryRepository,sonarProfileRepostory
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:185) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1143) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1046) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) ~[spring-context-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) [spring-boot-1.3.0.RELEASE.jar!/:1.3.0.RELEASE]
	at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:347) [spring-boot-1.3.0.RELEASE.jar!/:1.3.0.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:295) [spring-boot-1.3.0.RELEASE.jar!/:1.3.0.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1112) [spring-boot-1.3.0.RELEASE.jar!/:1.3.0.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1101) [spring-boot-1.3.0.RELEASE.jar!/:1.3.0.RELEASE]
	at com.capitalone.dashboard.Application.main(Application.java:16) [jenkins-build-collector.jar!/:3.1.2-SNAPSHOT]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_232]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_232]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_232]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_232]
	at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53) [jenkins-build-collector.jar!/:3.1.2-SNAPSHOT]
	at java.lang.Thread.run(Thread.java:819) [na:1.8.0_232]
Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [com.capitalone.dashboard.repository.CollItemConfigHistoryRepository] is defined: expected single matching bean but found 2: collItemConfigHistoryRepository,sonarProfileRepostory
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1126) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:813) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
	... 24 common frames omitted
java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
	at java.lang.Thread.run(Thread.java:819)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'hudsonCollectorTask' defined in URL [jar:file:/Users/anderja1/Sandbox/hygieia-dashboard/collectors/build/jenkins/target/jenkins-build-collector.jar!/com/capitalone/dashboard/collector/HudsonCollectorTask.class]: Unsatisfied dependency expressed through constructor argument with index 4 of type [com.capitalone.dashboard.repository.CollItemConfigHistoryRepository]: No qualifying bean of type [com.capitalone.dashboard.repository.CollItemConfigHistoryRepository] is defined: expected single matching bean but found 2: collItemConfigHistoryRepository,sonarProfileRepostory; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [com.capitalone.dashboard.repository.CollItemConfigHistoryRepository] is defined: expected single matching bean but found 2: collItemConfigHistoryRepository,sonarProfileRepostory
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:185)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1143)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1046)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)
	at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:347)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:295)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1112)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1101)
	at com.capitalone.dashboard.Application.main(Application.java:16)
	... 6 more
Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [com.capitalone.dashboard.repository.CollItemConfigHistoryRepository] is defined: expected single matching bean but found 2: collItemConfigHistoryRepository,sonarProfileRepostory
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1126)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
	at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:813)
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
	... 24 more

Unless this collector works differently than the others, I can't see anything that I may be doing wrong, but I could very well be overlooking something. Let me know if you would like any more information regarding this. Thanks in advance!

rvema commented

@jar145 give me some time I will try to recreate this issue.

Hi @rvema, any update on this?

rvema commented

@jar145 sorry for the delay, I will look into this this morning

rvema commented

@jar145 may be there is an issue with the properties but with the below properties it seem to be working fine. I am querying my local instance of jenkins btw.

jenkins.servers[0]=http://localhost:8111/ jenkins.niceNames[0]=local jenkins.usernames[0]=myusername jenkins.apiKeys[0]=myapi key jenkins.searchFields[0]= Description jenkins.searchFields[1]= NiceName jenkins.pageSize=10 jenkins.useGroovy=true

@rvema I added from the sample the two properties that I didn't have (jenkins.niceNames[0] and jenkins.useGroovy) but I get the same error.

Looking at the error above (second line) I see that it mentions the sonarProfileRepository a couple of times. Could there be some sort of conflict with the Sonar Collector? The line I am talking about is below.

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'hudsonCollectorTask' defined in URL [jar:file:/Users/anderja1/Sandbox/hygieia-dashboard/collectors/build/jenkins/target/jenkins-build-collector.jar!/com/capitalone/dashboard/collector/HudsonCollectorTask.class]: Unsatisfied dependency expressed through constructor argument with index 4 of type [com.capitalone.dashboard.repository.CollItemConfigHistoryRepository]: No qualifying bean of type [com.capitalone.dashboard.repository.CollItemConfigHistoryRepository] is defined: expected single matching bean but found 2: collItemConfigHistoryRepository,sonarProfileRepostory; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [com.capitalone.dashboard.repository.CollItemConfigHistoryRepository] is defined: expected single matching bean but found 2: collItemConfigHistoryRepository,sonarProfileRepostory

Thanks for looking into this and let me know if you need any more info from me.

rvema commented

Can you check the version of Hygieia-core in Pom.xml

I looked and saw that you guys had updated both the core and the jenkins build collector since I had posted this. I updated both of them and still get the same error. The core version I am using is 3.1.19-SNAPSHOT.

I commented out the code in the SonarProfileRepostory file (the SonarProfileRepostory extends CollItemConfigHistoryRepository method that was mentioned in the exception) and the collector starts just fine, but now I don't seem to be able to select it in the UI. There isn't even an option for it in the widget selection when creating a dashboard.

Edit: The file that I commented out is located at src/main/java/com/capitalone/dashboard/repository/SonarProfileRepostory.java

@rvema Nevermind on not seeing the widget option in the UI. I fixed that by taking the code from the main repo and adding it in. My fault for not noticing that before, I'm not sure why I took it out.

I have verified that the collector seems to be working though. All I had to do was comment out the code in the SonarProfileRepostory file. The Sonar collector seems to be working fine too. I'm not sure how you want to proceed with that being my fix though. Let me know if you need anything from me to look further into it and I'd be happy to do what I can to help.

rvema commented

Let me check the above and get back to you

@jar145 I am seeing similar error as yours. Also I am not seeing this file at the location you mentioned "src/main/java/com/capitalone/dashboard/repository/SonarProfileRepostory.java".

2020-08-20 14:12:46,927 [main] ERROR o.s.boot.SpringApplication - Application startup failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'hudsonCollectorTask' defined in URL [jar:file:/C:/hygieia/hygieia-build-jenkins-collector/target/jenkins-build-collector.jar!/com/capitalone/dashboard/collector/HudsonCollectorTask.class]: Unsatisfied dependency expressed through constructor argument with index 4 of type [com.capitalone.dashboard.repository.CollItemConfigHistoryRepository]: No qualifying bean of type [com.capitalone.dashboard.repository.CollItemConfigHistoryRepository] is defined: expected single matching bean but found 2: sonarProfileRepostory,collItemConfigHistoryRepository; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [com.capitalone.dashboard.repository.CollItemConfigHistoryRepository] is defined: expected single matching bean but found 2: sonarProfileRepostory,collItemConfigHistoryRepository
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
        at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:185) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1143) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1046) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) 

Facing the same issue. Is the fix done ?

i have commented out the file in src/main/java/com/capitalone/dashboard/repository/SonarProfileRepostory.java, But i am still facing the issue is there any more changes need to be done

i have commented out the file in src/main/java/com/capitalone/dashboard/repository/SonarProfileRepostory.java, But i am still facing the issue is there any more changes need to be done

+1

@syedsfayaz, @ShachiRai1, @balakrishnapushparajan, @Tojanj
Sorry for the delayed response. I think I should have clarified my workaround. You need to comment out the code src/main/java/com/capitalone/dashboard/repository/SonarProfileRepostory.java in the core package, not in the collector itself.

@jar145 I'm also experiencing this issue. Where is the core package that I need to edit?

@markmcnaughton https://github.com/Hygieia/hygieia-core

@rvema let me know if I should make a pull request. It seems the same code that exists in the core is also in the collector itself, which might be causing the conflict.

rvema commented

Please create a PR if you have a solution? If you modify the version if hygieia-core in Pom.xml that should fix it

Actually it looks like the most recent core version isn't compatible with this collector (or the sonar one). So if I were to make a fix and update the pom to the most recent core version, it will still break. I will continue to look into it though.

rvema commented

@jar145 there are some minor Restclient related changes. Its pretty simple to fix and you can see https://github.com/Hygieia/hygieia-scm-github-graphql-collector/pull/47/files as reference similar changes need to be made.

Thanks, @rvema, that helped a lot! I made the fix on my local. I will make a PR on the core package and once that is approved I will do the same, with the incremented core version, for this and the Sonar collectors.

Thanks all, its getting a bit further now

@markmcnaughton looks like someone beat me to making the changes with the new core package. This should be working normally now.

rvema commented

@jar145 kudos to @aochsner for fixing this