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
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:
WicketFilter
(called MyWicketFilter
) and override getClassLoader
. This returns this.getClass().getClassLoader()
.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.