Search code examples
javawicketguiceatmosphere

Wicket + Atmosphere + Guice


I'm trying to configure Atmosphere and that is what I get when I post event to EventBus

java.lang.IllegalStateException: MeteorServlet not defined in web.xml
at org.atmosphere.cpr.Meteor.build(Meteor.java:170) ~[atmosphere-runtime-1.0.8.jar:1.0.8]
at org.atmosphere.cpr.Meteor.build(Meteor.java:151) ~[atmosphere-runtime-1.0.8.jar:1.0.8]
at org.atmosphere.cpr.Meteor.build(Meteor.java:137) ~[atmosphere-runtime-1.0.8.jar:1.0.8]
at org.atmosphere.cpr.Meteor.build(Meteor.java:124) ~[atmosphere-runtime-1.0.8.jar:1.0.8]
at org.apache.wicket.atmosphere.AtmosphereBehavior.onResourceRequested(AtmosphereBehavior.java:107) ~[wicket-atmosphere-0.7.jar:0.7]
... 56 common frames omitted

I use Wicket, this is AjaxButton onSubmit implementation:

public void onSubmit(AjaxRequestTarget target, Form<?> form) {
      EventBus.get().post(message.getModelObject());
}

I'm configuring Atmosphere using Guice. In my ServletModule implementation:

Map<String, String> params = new HashMap<String, String>();
            params.put("applicationClassName", "org.mycompany.MyWebApplication");
            params.put(ApplicationConfig.PROPERTY_SERVLET_MAPPING, "/session/**");
            params.put(ApplicationConfig.PROPERTY_SESSION_SUPPORT, "true");
            params.put(ApplicationConfig.WEBSOCKET_PROTOCOL, "org.atmosphere.websocket.protocol.EchoProtocol");
            params.put(ApplicationConfig.BROADCAST_FILTER_CLASSES, "org.apache.wicket.atmosphere.TrackMessageSizeFilter");
            filter("/session/**").through(AtmosphereFilter.class, params);

This is my atmosphere.xml:

<atmosphere-handler context-root="/session/**"
    class-name="org.atmosphere.handler.ReflectorServletProcessor">
</atmosphere-handler>

I want to configure filters programmatically, can I do it with atmosphere filters? If yes, what am I doing wrong?


Solution

  • The problem is solved. Using MeteorServlet instead of AtmosphereFilter then an atmosphere.xml isn't needed and you should pass WicketFilter init params to the MeteorServlet.