本文介绍了通过使用Vaadin-CDI集成插件,将EJB注入到Vaadin 7 UI中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法成功整合官方的Vaadin-CDI-Integration-Addon,因为在完成官方整合说明之后,以下异常被抛出,以防万一重新加载已发布的U​​RL localhost:8080 / App /?restartApplication

I wasn't able to successfully integrate the official Vaadin-CDI-Integration-Addon, since after finishing the official integration instructions, the following Exception was thrown in case I reloaded the already published URL localhost:8080/App/?restartApplication.

javax.servlet.ServletException: com.vaadin.server.ServiceException:
java.lang.IllegalStateException: UI id has already been defined






以下几个解决方法是一个经过测试的工作解决方案,可以完成官方说明。


The following little workaround is a tested, working solution, which completes the official instructions.

推荐答案

您必须执行以下步骤才能将官方CDI-Integration-Addon成功整合到您的Vaadin项目中。

You have to work off the following steps to successfully integrate the official CDI-Integration-Addon into your Vaadin project.


  • 根据。

  • 从URL中删除?restartApplication 参数。这样避免了异常

  • 按照下面的清单注入EJB。

  • 请注意,如果需要,请手动重新启动应用程序!

  • Do exactly as stated in the official how-to.
  • Remove the ?restartApplication parameter from the URL. This avoids the Exception.
  • Inject the EJB as shown in the listing below.
  • Keep in mind to restart your application manually if necessary!
@CDIUI
public class ExampleCDIUI extends UI {

    @Inject
    MyLocalBeanInterface myBean;

    @Override
    public void init(VaadinRequest request) {
        Label label = new Label("Hello Vaadin user");
        setContent(label);

        // myBean should be accessible now.

    }

}

就是这样。我希望这有助于: - )

That's it. I hope this helps :-)

这篇关于通过使用Vaadin-CDI集成插件,将EJB注入到Vaadin 7 UI中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 21:02