title: Concrete bean could not be received from the application context with PF4J, PF4J-Spring and Wicket
body: <p>I'm making a spring boot application using Wicket and PF4J. I want to use spring services in my plugins. These services are not using services outside the plugin class loader. In my plugin, I can have wicket panels. The panel class can use the Spring service.</p>
  <p>Here the class of the plugin:</p>
  <pre><code>public class MyPlugin extends SpringPlugin implements MyPluginConfiguration {
  
      public MyPlugin(PluginWrapper wrapper) {
          super(wrapper);
      }
  
      @Override
      protected ApplicationContext createApplicationContext() {
          final AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
          applicationContext.setClassLoader(getWrapper().getPluginClassLoader());
          applicationContext.register(SpringConfiguration.class);
          applicationContext.refresh();
          return applicationContext;
      }
  
      @Override
      public Panel getConfigurationPanel(String wicketId) {
          return new ConfigurationPanel(wicketId);
      }
  
  }
  </code></pre>
  <p>Its interface:</p>
  <pre><code>public interface MyPluginConfiguration {
  
      Panel getConfigurationPanel(String wicketId);
  }
  </code></pre>
  <p>The SpringConfiguration class:</p>
  <pre><code>@Configuration
  public class SpringConfiguration {
  
      @Bean
      public LabelService getLabelService() {
          return new LabelService();
      }
  }
  </code></pre>
  <p>The configuration panel:</p>
  <pre><code>public class ConfigurationPanel extends Panel {
  
      @SpringBean
      private LabelService labelService;
  
      public ConfigurationPanel(String id) {
          super(id);
  
          add(new Label(&quot;text&quot;, labelService.getLabel()));
      }
  
  }
  </code></pre>
  <p>And the service:</p>
  <pre><code>@Service
  public class LabelService {
  
      public String getLabel() {
          return &quot;Hello World from the plugin.&quot;;
      }
  }
  </code></pre>
  <p>To display the configuration, i'm using this page in my application:</p>
  <pre><code>public class PluginTestPage extends WebPage {
  
      @SpringBean
      private PluginManager pluginManager;
  
      public PluginTestPage() {
          final PluginWrapper pluginWrapper = pluginManager.getPlugin(&quot;example&quot;);
          if (pluginWrapper.getPlugin() instanceof MyPluginConfiguration) {
              final MyPluginConfiguration pluginConfiguration = (MyPluginConfiguration) pluginWrapper.getPlugin();
              add(pluginConfiguration.getConfigurationPanel(&quot;configuration-panel&quot;));
          } else {
              add(new Label(&quot;configuration-panel&quot;, &quot;Can't get the configuration panel&quot;));
          }
      }
  
  }
  </code></pre>
  <p>When I'm asking the PluginTestPage, I have this error:</p>
  <pre><code>org.apache.wicket.WicketRuntimeException: Can't instantiate page using constructor 'public com.example.pages.PluginTestPage()'. An exception has been thrown during construction!
      at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:194) ~[wicket-core-9.0.0.jar:9.0.0]
      at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:67) ~[wicket-core-9.0.0.jar:9.0.0]
      at org.apache.wicket.DefaultMapperContext.newPageInstance(DefaultMapperContext.java:90) ~[wicket-core-9.0.0.jar:9.0.0]
      at org.apache.wicket.core.request.handler.PageProvider$Provision.getPage(PageProvider.java:369) ~[wicket-core-9.0.0.jar:9.0.0]
      at org.apache.wicket.core.request.handler.PageProvider.getPageInstance(PageProvider.java:170) ~[wicket-core-9.0.0.jar:9.0.0]
      at org.apache.wicket.request.handler.render.PageRenderer.getPage(PageRenderer.java:78) ~[wicket-core-9.0.0.jar:9.0.0]
      at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:231) ~[wicket-core-9.0.0.jar:9.0.0]
      at org.apache.wicket.core.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:202) ~[wicket-core-9.0.0.jar:9.0.0]
      at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:917) ~[wicket-core-9.0.0.jar:9.0.0]
      at org.apache.wicket.request.RequestHandlerExecutor.execute(RequestHandlerExecutor.java:63) ~[wicket-request-9.0.0.jar:9.0.0]
      at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:283) ~[wicket-core-9.0.0.jar:9.0.0]
      at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:254) ~[wicket-core-9.0.0.jar:9.0.0]
      at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:222) ~[wicket-core-9.0.0.jar:9.0.0]
      at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:276) ~[wicket-core-9.0.0.jar:9.0.0]
      at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:207) ~[wicket-core-9.0.0.jar:9.0.0]
      at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:300) ~[wicket-core-9.0.0.jar:9.0.0]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
      at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
      at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
      at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1589) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
      at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
      at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
  Caused by: java.lang.reflect.InvocationTargetException: null
      at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:na]
      at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:na]
      at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:na]
      at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) ~[na:na]
      at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:175) ~[wicket-core-9.0.0.jar:9.0.0]
      ... 33 common frames omitted
  Caused by: java.lang.IllegalStateException: Concrete bean could not be received from the application context for class: com.example.pf4j_wicket_spring.services.LabelService.
      at org.apache.wicket.spring.SpringBeanLocator.lookupSpringBean(SpringBeanLocator.java:277) ~[wicket-spring-9.0.0.jar:9.0.0]
      at org.apache.wicket.spring.SpringBeanLocator.locateProxyTarget(SpringBeanLocator.java:198) ~[wicket-spring-9.0.0.jar:9.0.0]
      at org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.getFieldValue(AnnotProxyFieldValueFactory.java:150) ~[wicket-spring-9.0.0.jar:9.0.0]
      at org.apache.wicket.injection.Injector.inject(Injector.java:111) ~[wicket-ioc-9.0.0.jar:9.0.0]
      at org.apache.wicket.spring.injection.annot.SpringComponentInjector.inject(SpringComponentInjector.java:124) ~[wicket-spring-9.0.0.jar:9.0.0]
      at org.apache.wicket.spring.injection.annot.SpringComponentInjector.onInstantiation(SpringComponentInjector.java:130) ~[wicket-spring-9.0.0.jar:9.0.0]
      at org.apache.wicket.application.ComponentInstantiationListenerCollection$1.notify(ComponentInstantiationListenerCollection.java:38) ~[wicket-core-9.0.0.jar:9.0.0]
      at org.apache.wicket.application.ComponentInstantiationListenerCollection$1.notify(ComponentInstantiationListenerCollection.java:34) ~[wicket-core-9.0.0.jar:9.0.0]
      at org.apache.wicket.util.listener.ListenerCollection.notify(ListenerCollection.java:80) ~[wicket-util-9.0.0.jar:9.0.0]
      at org.apache.wicket.application.ComponentInstantiationListenerCollection.onInstantiation(ComponentInstantiationListenerCollection.java:33) ~[wicket-core-9.0.0.jar:9.0.0]
      at org.apache.wicket.Component.&lt;init&gt;(Component.java:682) ~[wicket-core-9.0.0.jar:9.0.0]
      at org.apache.wicket.MarkupContainer.&lt;init&gt;(MarkupContainer.java:185) ~[wicket-core-9.0.0.jar:9.0.0]
      at org.apache.wicket.markup.html.WebMarkupContainer.&lt;init&gt;(WebMarkupContainer.java:53) ~[wicket-core-9.0.0.jar:9.0.0]
      at org.apache.wicket.markup.html.WebMarkupContainer.&lt;init&gt;(WebMarkupContainer.java:45) ~[wicket-core-9.0.0.jar:9.0.0]
      at org.apache.wicket.markup.html.panel.Panel.&lt;init&gt;(Panel.java:67) ~[wicket-core-9.0.0.jar:9.0.0]
      at com.example.pf4j_wicket_spring.panels.ConfigurationPanel.&lt;init&gt;(ConfigurationPanel.java:25) ~[na:na]
      at com.example.pf4j_wicket_spring.MyPlugin.getConfigurationPanel(MyPlugin.java:40) ~[na:na]
      at com.example.pages.PluginTestPage.&lt;init&gt;(PluginTestPage.java:30) ~[classes/:na]
      ... 38 common frames omitted
  </code></pre>
  <p>What is the origin of the problem ? Is it a mistake with my settings or a bug with pf4j-spring ?</p>
  <p>Regards,
  Stef</p>