pf4j-spring icon indicating copy to clipboard operation
pf4j-spring copied to clipboard

Trying to run the Spring demo-app but got error creating bean with name 'greetings

Open muyen opened this issue 6 years ago • 8 comments

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'greetings': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.util.List org.pf4j.demo.Greetings.greetings; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.pf4j.demo.api.Greeting] found for dependency [collection of org.pf4j.demo.api.Greeting]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
	at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:84)
	at org.pf4j.demo.Boot.main(Boot.java:35)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.util.List org.pf4j.demo.Greetings.greetings; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.pf4j.demo.api.Greeting] found for dependency [collection of org.pf4j.demo.api.Greeting]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
	... 12 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.pf4j.demo.api.Greeting] found for dependency [collection of org.pf4j.demo.api.Greeting]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1103)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:915)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:858)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480)
	... 14 more

muyen avatar Sep 11 '18 23:09 muyen

I ported run-demo scripts from pf4j to pf4j-spring project. Can you run demo script from command line (run-demo.sh for linux or run-demo.bat for windows) and share the result?

decebals avatar Sep 12 '18 03:09 decebals

@muyen Any news? Did you solve the problem?

decebals avatar Nov 13 '18 09:11 decebals

yeah, it is working with run-demo.sh. However, the plugin jars are not copied from target to demo/plugins. In the run-demo.sh, it should be "cp demo/plugins/*/target/plugin.jar demo-dist/plugins/"

muyen avatar Dec 04 '18 23:12 muyen

@muyen If you can run demo without any problem, via run-demo.sh, I don't understand where is the problem.

decebals avatar Dec 11 '18 18:12 decebals

I don't see the exception when I use run-demo.sh. However, run-demo.sh loads only the org.pf4j.demo.WhazzupGreeting plugin and not the plugin1 and plugin2. The plugins jars are not copied to the target folder. It should be cp demo/plugins/*/target/plugin*.jar demo-dist/plugins/ Because the plugins name is pf4j-spring-demo-plugin1-0.6.0-SNAPSHOT.jar

muyen avatar Dec 11 '18 21:12 muyen

I concur. I found the same problem with run-demo.sh. I don't see how your pattern will work either, as the jar file names don't start with 'plugin'. I changed the script to just copy all jars, since there's only one in each directory:

cp demo/plugins/*/target/*.jar demo-dist/plugins/

and the demo then runs all three plugins.

sljinlet avatar Feb 17 '19 19:02 sljinlet

You should add an extensions.idx file into both plugin sources to run the demo in development mode without to launch run-demo.sh/bat, is it true?

fabioformosa avatar May 17 '20 10:05 fabioformosa

hi how do i fix this?

AzzouzMohamed avatar Jul 14 '20 08:07 AzzouzMohamed