Wicket atmosphere initialization exception

2019-06-03 17:44发布

问题:

I have the following setup: wicket: 6.1.0 wicket-atmosphere: 0.4

(via Maven)

On Application.init() I get a NullPointerException during instantiation of EventBus

    new EventBus(this);

Exception:

    java.lang.NullPointerException
at org.apache.wicket.atmosphere.EventBus.<init>(EventBus.java:105)

This is caused because the method

    public synchronized static BroadcasterFactory getDefault()

delivers null (the protected static member "factory" is not initialized).

How do I use Wicket/Atmosphere properly? Did I forget something to initialize? I'm starting Wicket as a ServletFilter.

<filter>
    <filter-name>AtmosphereTest</filter-name>
    <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
    <init-param>
        <param-name>applicationClassName</param-name>
        <param-value>com.atmosphere.wicket.Application</param-value>
    </init-param>
    <init-param>
        <param-name>configuration</param-name>
        <param-value>development</param-value>
    </init-param>
    <init-param>
        <param-name>ignorePaths</param-name>
        <param-value>/css,/js,/images,/icons</param-value>
    </init-param>
</filter>

<filter-mapping>
    <filter-name>AtmosphereTest</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

I don't have a atmosphere configuration, do I need one?

Thanks

回答1:

According to this email from the users-wicket list, you should set up the AtmosphereServlet in your web.xml and supply it with an atmosphere.xml configuration file that tells atmosphere how to load the WicketFilter instead of configuring WicketFilter directly in your web.xml.

I haven't used atmosphere, so I can't really vouch for this, but it sounds sensible.

The email referenced above has web.xml and atmosphere.xml configurations that might help you get this set up.