使用sqlcontainer contentContainer的自定义非JCR magnolia内容应用程序,无法将ContentConnector或EventBus注入操作定义

时间:2017-05-20 00:09:24

标签: java-ee magnolia

我正在为Magnolia 5.5.4开发一个非JCR自定义内容应用程序,我创建了一个这样的容器:

public class ArticlesContainer extends SQLContainer {

    public ArticlesContainer(QueryDelegate delegate) throws SQLException {
        super(delegate);
        // TODO Auto-generated constructor stub
    }
}

和treePresenter,我在这里初始化容器:

public Container initializeContainer() {
        JDBCConnectionPool pool;
        ArticlesContainer container = null;
        try {
            pool = new SimpleJDBCConnectionPool("com.mysql.jdbc.Driver", "jdbc:mysql://localhost:3306/pfeapp", "admindxbIwZL", "HduX7BJJaBAD");
            QueryDelegate tq = new TableQuery("articles", pool);
            container =  new ArticlesContainer(tq);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return container;
    }
直到现在一切都很好,它完美无缺。 问题是,当我尝试创建一个动作时,例如,我添加了这样的动作AddArticleAction:

public class AddArticleAction<T extends AddArticleActionDefinition> extends AbstractAction<T>{

    private ContentConnector contentConnector;

    private EventBus eventBus;

    @Inject
    public AddArticleAction(T definition, @Named(AdmincentralEventBus.NAME)EventBus eventBus) {
        super(definition);
        this.eventBus = eventBus;
        // TODO Auto-generated constructor stub
    }

    @Override
    public void execute() throws ActionExecutionException {
        // TODO Auto-generated method stub

    }

}

当我点击浏览器操作栏中的添加文章链接时,我得到以下异常:

  

2017-05-20 00:28:22,321错误fo.magnolia.ui.contentapp.browser.BrowserPresenter:发生错误   执行动作时[addArticle]   info.magnolia.ui.api.action.ActionExecutionException:动作执行   行动失败:addArticle at   info.magnolia.ui.api.action.AbstractActionExecutor.execute(AbstractActionExecutor.java:64)     在   info.magnolia.ui.contentapp.browser.BrowserPresenter.executeAction(BrowserPresenter.java:347)     在   info.magnolia.ui.contentapp.browser.BrowserPresenter.onActionbarItemClicked(BrowserPresenter.java:306)     在   info.magnolia.ui.actionbar.ActionbarPresenter.onActionbarItemClicked(ActionbarPresenter.java:205)     在   info.magnolia.ui.actionbar.ActionbarViewImpl $ 1.actionTrigger(ActionbarViewImpl.java:67)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at   sun.reflect.NativeMethodAccessorImpl.invoke(未知来源)at   sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源)at   java.lang.reflect.Method.invoke(未知来源)at   com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508)     在com.vaadin.event.EventRouter.fireEvent(EventRouter.java:198)at   com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)at   com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:1008)     在   info.magnolia.ui.vaadin.actionbar.Actionbar.access $ 000(Actionbar.java:59)     在   info.magnolia.ui.vaadin.actionbar.Actionbar $ 1.onActionTriggered(Actionbar.java:72)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at   sun.reflect.NativeMethodAccessorImpl.invoke(未知来源)at   sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源)at   java.lang.reflect.Method.invoke(未知来源)at   com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:158)     在   com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:118)     在   com.vaadin.server.communication.ServerRpcHandler.handleInvocation(ServerRpcHandler.java:437)     在   com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:408)     在   com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:273)     在   com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:90)     在   com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)     在   com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1414)     在com.vaadin.server.VaadinServlet.service(VaadinServlet.java:365)     在   info.magnolia.ui.admincentral.AdmincentralVaadinServlet.service(AdmincentralVaadinServlet.java:131)     在javax.servlet.http.HttpServlet.service(HttpServlet.java:742)at   info.magnolia.cms.filters.ServletDispatchingFilter.doFilter(ServletDispatchingFilter.java:148)     在   info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:85)     在   info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79)     在   info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:81)     在   info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:81)     在   info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:81)     在   info.magnolia.cms.filters.CompositeFilter.doFilter(CompositeFilter.java:65)     在   info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:85)     在   info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79)     在   info.magnolia.cms.filters.VirtualUriFilter.doFilter(VirtualUriFilter.java:69)     在   info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:85)     在   info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79)     在   info.magnolia.module.cache.executor.Bypass.processCacheRequest(Bypass.java:58)     在   info.magnolia.module.cache.executor.CompositeExecutor.processCacheRequest(CompositeExecutor.java:67)     在   info.magnolia.module.cache.filter.CacheFilter.doFilter(CacheFilter.java:220)     在   info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:85)     在   info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79)     在   info.magnolia.cms.i18n.I18nContentSupportFilter.doFilter(I18nContentSupportFilter.java:74)     在   info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:85)     在   info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79)     在   info.magnolia.cms.filters.RangeSupportFilter.doFilter(RangeSupportFilter.java:77)     在   info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:85)     在   info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79)     在   info.magnolia.cms.security.BaseSecurityFilter.doFilter(BaseSecurityFilter.java:57)     在   info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:85)     在   info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79)     在   info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:81)     在   info.magnolia.cms.security.SecurityCallbackFilter.doFilter(SecurityCallbackFilter.java:84)     在   info.magnolia.cms.filters.OncePerRequestAbstractMgnlFilter.doFilter(OncePerRequestAbstractMgnlFilter.java:59)     在   info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79)     在   info.magnolia.cms.security.LogoutFilter.doFilter(LogoutFilter.java:94)     在   info.magnolia.cms.filters.OncePerRequestAbstractMgnlFilter.doFilter(OncePerRequestAbstractMgnlFilter.java:59)     在   info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79)     在   info.magnolia.module.site.filters.SiteMergeFilter.doFilter(SiteMergeFilter.java:119)     在   info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:85)     在   info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79)     在   info.magnolia.cms.filters.MultiChannelFilter.doFilter(MultiChannelFilter.java:83)     在   info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:85)     在   info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79)     在   info.magnolia.module.cache.filter.GZipFilter.doFilter(GZipFilter.java:73)     在   info.magnolia.cms.filters.OncePerRequestAbstractMgnlFilter.doFilter(OncePerRequestAbstractMgnlFilter.java:59)     在   info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79)     在   info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:81)     在   info.magnolia.cms.security.auth.login.LoginFilter.doFilter(LoginFilter.java:127)     在   info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:85)     在   info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79)     在   info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:81)     在   info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:81)     在   info.magnolia.cms.filters.ContentTypeFilter.doFilter(ContentTypeFilter.java:155)     在   info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:85)     在   info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79)     在   info.magnolia.cms.filters.ContextFilter.doFilter(ContextFilter.java:128)     在   info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:85)     在   info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:79)     在   info.magnolia.cms.filters.CompositeFilter.doFilter(CompositeFilter.java:65)     在   info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:85)     在   info.magnolia.cms.filters.SafeDestroyMgnlFilterWrapper.doFilter(SafeDestroyMgnlFilterWrapper.java:107)     在   info.magnolia.cms.filters.MgnlFilterDispatcher.doDispatch(MgnlFilterDispatcher.java:67)     在   info.magnolia.cms.filters.MgnlMainFilter.doFilter(MgnlMainFilter.java:108)     在   info.magnolia.cms.filters.MgnlMainFilter.doFilter(MgnlMainFilter.java:94)     在   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)     在   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)     在   org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)     在   org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)     在   org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)     在   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)     在   org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)     在   org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)     在   org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)     在   org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:498)     在   org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)     在   org.apache.coyote.AbstractProtocol $ ConnectionHandler.process(AbstractProtocol.java:796)     在   org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.java:1368)     在   org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)     at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)     at java.util.concurrent.ThreadPoolExecutor $ Worker.run(Unknown Source)     在   org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61)     在java.lang.Thread.run(未知来源)引起:   java.lang.NullPointerException at   info.magnolia.objectfactory.CandidateParameterResolver.resolveParameter(CandidateParameterResolver.java:78)     在   info.magnolia.objectfactory.ObjectManufacturer.resolveParameter(ObjectManufacturer.java:166)     在   info.magnolia.objectfactory.ObjectManufacturer.resolveParameters(ObjectManufacturer.java:143)     在   info.magnolia.objectfactory.ObjectManufacturer.newInstance(ObjectManufacturer.java:86)     在   info.magnolia.objectfactory.guice.GuiceComponentProvider.newInstanceWithParameterResolvers(GuiceComponentProvider.java:121)     在   info.magnolia.objectfactory.guice.GuiceComponentProvider.newInstance(GuiceComponentProvider.java:107)     在   info.magnolia.ui.api.action.AbstractActionExecutor.createAction(AbstractActionExecutor.java:90)     在   info.magnolia.ui.api.action.AbstractActionExecutor.execute(AbstractActionExecutor.java:61)     ... 107更多

我真的不明白问题所在。

1 个答案:

答案 0 :(得分:1)

您在implementationClass中设置为AddArticleActionDefinition的内容是什么?它需要指向AddArticleAction。我怀疑它没有,因此Caused by: java.lang.NullPointerException例外。执行者无法调用您的操作,因为它未设置。