Starting Wicket web application with OSGi HTTP Service

后端 未结 1 824
盖世英雄少女心
盖世英雄少女心 2020-12-19 20:37

I\'m trying to start a Wicket Application using Felix implementation of OSGi HTTP service, for that I just register the service using WicketServlet with a

相关标签:
1条回答
  • 2020-12-19 21:07

    The problem here is that Wicket seems to load the applicationClass badly. I have not looked at the code that does this, but I suspect it's using current thread's context classloader.

    I did the following to overcome this:

    1. Create my own WicketFilter (called MyWicketFilter) and override getClassLoader. This returns this.getClass().getClassLoader().
    2. Register the MyWicketFilter as a Filter service to be picked up by the whiteboard http service.

    Code for activator start:

    Hashtable<String, String> props = new Hashtable<String, String>();
    props.put("pattern", "/.*");
    props.put("init.applicationClassName", MyApplication.class.getName());
    
    final MyWicketFilter service = new MyWicketFilter();
    context.registerService(Filter.class.getName(), service, props);
    

    Code for MyWicketFilter:

    public final class MyWicketFilter
        extends WicketFilter
    {
        @Override
        protected ClassLoader getClassLoader()
        {
            return this.getClass().getClassLoader();
        }
    }
    

    You can also use WicketServlet, but this involves overriding newWicketFilter and return MyWicketFilter from here.

    0 讨论(0)
提交回复
热议问题