注入服务bean对AnnotatedMountScanner挂载的Wicket页面不起作用?

时间:2016-10-25 14:22:16

标签: spring-boot wicket

当在SpringBoot中配置Wicket时,我有一个简单的Wicket 7.4.0项目。我有@Service spring bean想要注入Wicket页面。现在,当通过mountPage(..)命令挂载Wicket页面时@Inject注释适用于wicket页面。但@Inject不适用于由AnnotatedMountScanner()安装的wicket页面。这里有什么想法吗?请参阅下面的代码段。

@Override
  public void init() {
    super.init();

    getComponentInstantiationListeners().add(
        new SpringComponentInjector(this, applicationContext));

    new AnnotatedMountScanner().scanPackage("com").mount(this);
    mountPage("/x", PageAbout.class);

    getMarkupSettings().setDefaultMarkupEncoding("utf-8");

  }

编辑#1 - 完全追溯我正在

Unexpected RuntimeException

Last cause: Concrete bean could not be received from the application context for class: com.dubture.TestService.
WicketMessage: Can't instantiate page using constructor 'public com.dubture.PageAbout(org.apache.wicket.request.mapper.parameter.PageParameters)' and argument ''. An exception has been thrown during construction!

Stacktrace

Root cause:

java.lang.IllegalStateException: Concrete bean could not be received from the application context for class: com.dubture.TestService.
     at org.apache.wicket.spring.SpringBeanLocator.lookupSpringBean(SpringBeanLocator.java:275)
     at org.apache.wicket.spring.SpringBeanLocator.locateProxyTarget(SpringBeanLocator.java:198)
     at org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.getFieldValue(AnnotProxyFieldValueFactory.java:150)
     at org.apache.wicket.injection.Injector.inject(Injector.java:111)
     at org.apache.wicket.spring.injection.annot.SpringComponentInjector.inject(SpringComponentInjector.java:124)
     at org.apache.wicket.spring.injection.annot.SpringComponentInjector.onInstantiation(SpringComponentInjector.java:130)
     at org.apache.wicket.application.ComponentInstantiationListenerCollection$1.notify(ComponentInstantiationListenerCollection.java:38)
     at org.apache.wicket.application.ComponentInstantiationListenerCollection$1.notify(ComponentInstantiationListenerCollection.java:34)
     at org.apache.wicket.util.listener.ListenerCollection.notify(ListenerCollection.java:80)
     at org.apache.wicket.application.ComponentInstantiationListenerCollection.onInstantiation(ComponentInstantiationListenerCollection.java:33)
     at org.apache.wicket.Component.<init>(Component.java:687)
     at org.apache.wicket.MarkupContainer.<init>(MarkupContainer.java:180)
     at org.apache.wicket.Page.<init>(Page.java:170)
     at org.apache.wicket.Page.<init>(Page.java:159)
     at org.apache.wicket.markup.html.WebPage.<init>(WebPage.java:105)
     at com.dubture.PageAbout.<init>(PageAbout.java:33)
     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
     at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:171)
     at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:76)
     at org.apache.wicket.DefaultMapperContext.newPageInstance(DefaultMapperContext.java:102)
     at org.apache.wicket.core.request.handler.PageProvider.resolvePageInstance(PageProvider.java:271)
     at org.apache.wicket.core.request.handler.PageProvider.getPageInstance(PageProvider.java:169)
     at org.apache.wicket.request.handler.render.PageRenderer.getPage(PageRenderer.java:78)
     at org.apache.wicket.request.handler.render.WebPageRenderer.isPageStateless(WebPageRenderer.java:287)
     at org.apache.wicket.request.handler.render.WebPageRenderer.shouldRenderPageAndWriteResponse(WebPageRenderer.java:329)
     at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:193)
     at org.apache.wicket.core.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:175)
     at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:895)
     at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
     at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:265)
     at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:222)
     at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:293)
     at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:261)
     at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:203)
     at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:284)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
     at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784)
     at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
     at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802)
     at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410)
     at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
     at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
     at java.lang.Thread.run(Thread.java:745)

Complete stack:

org.apache.wicket.WicketRuntimeException: Can't instantiate page using constructor 'public com.dubture.PageAbout(org.apache.wicket.request.mapper.parameter.PageParameters)' and argument ''. An exception has been thrown during construction!
     at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:194)
     at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:76)
     at org.apache.wicket.DefaultMapperContext.newPageInstance(DefaultMapperContext.java:102)
     at org.apache.wicket.core.request.handler.PageProvider.resolvePageInstance(PageProvider.java:271)
     at org.apache.wicket.core.request.handler.PageProvider.getPageInstance(PageProvider.java:169)
     at org.apache.wicket.request.handler.render.PageRenderer.getPage(PageRenderer.java:78)
     at org.apache.wicket.request.handler.render.WebPageRenderer.isPageStateless(WebPageRenderer.java:287)
     at org.apache.wicket.request.handler.render.WebPageRenderer.shouldRenderPageAndWriteResponse(WebPageRenderer.java:329)
     at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:193)
     at org.apache.wicket.core.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:175)
     at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:895)
     at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
     at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:265)
     at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:222)
     at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:293)
     at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:261)

java.lang.reflect.InvocationTargetException
     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
     at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:171)
     at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:76)
     at org.apache.wicket.DefaultMapperContext.newPageInstance(DefaultMapperContext.java:102)
     at org.apache.wicket.core.request.handler.PageProvider.resolvePageInstance(PageProvider.java:271)
     at org.apache.wicket.core.request.handler.PageProvider.getPageInstance(PageProvider.java:169)
     at org.apache.wicket.request.handler.render.PageRenderer.getPage(PageRenderer.java:78)
     at org.apache.wicket.request.handler.render.WebPageRenderer.isPageStateless(WebPageRenderer.java:287)
     at org.apache.wicket.request.handler.render.WebPageRenderer.shouldRenderPageAndWriteResponse(WebPageRenderer.java:329)
     at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:193)
     at org.apache.wicket.core.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:175)
     at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:895)
     at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
     at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:265)
     at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:222)
     at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:293)
     at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:261)

0 个答案:

没有答案