使用Felix / Whiteboard托管VaadinServlet

时间:2016-09-16 15:54:51

标签: osgi vaadin vaadin7 apache-felix whiteboard

正如标题所述,我试图使用Whiteboard来托管我的VaadinServlet。在尝试使用其他嵌入式servlet容器(例如Jetty和Grizzly)失败后,我遇到了这个解决方案here,由Bndtools人本人Peter编写。我自己尝试过这个,但是我收到了一个我无法解决的错误:

months:
    '01': 'A'
    '02': 'B'
    '03': 'C'
    '04': 'D'
    '05': 'E'
    '06': 'F'
    '07': 'G'
    '08': 'H'
    '09': 'I'
    '10': 'J'
    '11': 'K'
    '12': 'L'

我添加了空构造函数只是为了它的地狱,看看他们是否改变了什么,但是没有。

ClientUI和ClientServlet类:

[test.client.ui.ClientUI$ClientServlet(4)] Error during instantiation of the implementation object
java.lang.InstantiationException: test.client.ui.ClientUI$ClientServlet: test.client.ui.ClientUI$ClientServlet.<init>()
Caused by: org.apache.felix.log.LogException: java.lang.InstantiationException: test.client.ui.ClientUI$ClientServlet
    at java.lang.Class.newInstance(Class.java:427)
    at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:253)
    at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:127)
    at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:871)
    at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:838)
    at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:850)
    at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:419)
    at org.apache.felix.scr.impl.config.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:376)
    at org.apache.felix.scr.impl.BundleComponentActivator.initialize(BundleComponentActivator.java:172)
    at org.apache.felix.scr.impl.BundleComponentActivator.<init>(BundleComponentActivator.java:120)
    at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:258)
    at org.apache.felix.scr.impl.Activator.access$000(Activator.java:45)
    at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:185)
    at org.apache.felix.utils.extender.AbstractExtender.createExtension(AbstractExtender.java:259)
    at org.apache.felix.utils.extender.AbstractExtender.modifiedBundle(AbstractExtender.java:232)
    ... 17 more
Caused by: java.lang.NoSuchMethodException: test.client.ui.ClientUI$ClientServlet.<init>()
    at java.lang.Class.getConstructor0(Class.java:3082)
    at java.lang.Class.newInstance(Class.java:412)
    at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:253)
    at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:127)
    at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:871)
    at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:838)
    at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:850)
    at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:419)
    at org.apache.felix.scr.impl.config.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:376)
    at org.apache.felix.scr.impl.BundleComponentActivator.initialize(BundleComponentActivator.java:172)
    at org.apache.felix.scr.impl.BundleComponentActivator.<init>(BundleComponentActivator.java:120)
    at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:258)
    at org.apache.felix.scr.impl.Activator.access$000(Activator.java:45)
    at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:185)
    at org.apache.felix.utils.extender.AbstractExtender.createExtension(AbstractExtender.java:259)
    ... 18 more

如何停止此错误并启动并运行servlet?

编辑:新错误!下面评论过的Steffen指出,我可能需要将servlet类移动到顶级类,我很可能需要这样做,但现在我得到了这个:

public class ClientUI extends UI
{
    public ClientUI()
    {
        //Empty constructor.
    }

    @Override
    public void init(VaadinRequest request) 
    {
        //Typical UI initialization.
    }
}

@VaadinServletConfiguration(productionMode = false, ui = ClientUI.class)
@Component(provide = Servlet.class, properties = {"alias=/test"}, immediate = true)
public class ClientServlet extends VaadinServlet 
{
    // Empty class. This class uses the annotations for servlet configuration instead of a web.xml.

    public ClientServlet()
    {
        // Empty constructor.
    }
}

此外,这个问题最终可能会被删除。我正在看this Vaadin/OSGi EnRoute example做我需要的东西,我已经确认它有效。我可能只是为应用程序使用示例提供程序和API或创建类似的东西。我现在就提出这个问题,只是为了提供互联网的知识,看看是否有人可以回答!

0 个答案:

没有答案