You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
VaadinService classloader is incorrectly set in the CTOR #4367
There is a method setDefaultClassLoader which is called in the VaadinServiceCTOR.
(By the way this is horrible that we have protected method which is intended to be overwritten in subclasses which is called in the CTOR but that's another issue).
This method sets the classloader for the VaadinService to the Thread.currentThread().getContextClassLoader().
Apparently this is intentional code which is done to be able to acquire appropriate class loader to load application's classes (e.g. UI) (from javadocs).
Not sure whether this is done for OSGi case or not but exactly for OSGi it doesn't work.
It might be that it depends on how OSGi declares and uses Vaadin HTTP servlet.
I have an Activator class which register the servlet via HTTP service (see code below).
I have to do it as it's in the code (with one more call for setClassLoader) otherwise it fails with inability to load UI class.
We should take care about this way of activating servlet.
public class Activator implements BundleActivator {
@Override
public void start(BundleContext ctx) throws Exception {
Hashtable<String, String> props = new Hashtable<>();
props.put("osgi.http.whiteboard.servlet.pattern", "/");
VaadinServlet servlet = new VaadinServlet() {
@Override
public void init(ServletConfig servletConfig)
throws ServletException {
super.init(servletConfig);
getService().setClassLoader(getClass().getClassLoader());
}
};
ctx.registerService(Servlet.class.getName(), servlet, props);
}
@Override
public void stop(BundleContext context) throws Exception {
}
}
Activity
fix: use ServletContext classloader as a default classloader for service
fix: use ServletContext classloader as a default classloader for serv…
fix: use ServletContext classloader as a default classloader for serv…
fix: use ServletContext classloader as a default classloader for serv…
fix: use ServletContext classloader as a default classloader for serv…
vaadin-bot commentedon Jun 28, 2021
This ticket/PR has been released with platform 21.0.0.alpha8. For prerelease versions, it will be included in its final version.
fix: use ServletContext classloader as a default classloader for serv… (
vaadin-bot commentedon Jul 5, 2021
This ticket/PR has been released with platform 20.0.4. For prerelease versions, it will be included in its final version.
vaadin-bot commentedon Aug 9, 2021
This ticket/PR has been released with platform 14.7.0.alpha3 and is also targeting the upcoming stable 14.7.0 version.