ScssStylesheet class not found

Hi all,

I use vaadin and OSGi to create a modular application. After a long fight, I was able to deploy successfully the application. However, I can’t load the style. When I try to access to

http://localhost:8080/myapp/VAADIN/themes/myTheme/styles.css

I got the following exception:

exception

javax.servlet.ServletException: Servlet execution threw an exception
root cause

java.lang.NoClassDefFoundError: com/vaadin/sass/internal/ScssStylesheet
	com.vaadin.server.VaadinServlet.serveOnTheFlyCompiledScss(VaadinServlet.java:957)
	com.vaadin.server.VaadinServlet.serveStaticResourcesInVAADIN(VaadinServlet.java:790)
	com.vaadin.server.VaadinServlet.serveStaticResources(VaadinServlet.java:760)
	com.vaadin.server.VaadinServlet.service(VaadinServlet.java:257)
	com.vaadin.server.VaadinServlet.service(VaadinServlet.java:201)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause

java.lang.ClassNotFoundException: com.vaadin.sass.internal.ScssStylesheet
	org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
	org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
	org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
	org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
	java.lang.ClassLoader.loadClass(ClassLoader.java:356)
	com.vaadin.server.VaadinServlet.serveOnTheFlyCompiledScss(VaadinServlet.java:957)
	com.vaadin.server.VaadinServlet.serveStaticResourcesInVAADIN(VaadinServlet.java:790)
	com.vaadin.server.VaadinServlet.serveStaticResources(VaadinServlet.java:760)
	com.vaadin.server.VaadinServlet.service(VaadinServlet.java:257)
	com.vaadin.server.VaadinServlet.service(VaadinServlet.java:201)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


com.vaadin.sass.internal.ScssStylesheet
class is offered by vaadin-theme-compiler-7.x.x.jar but the server doesn’t import this package. Then, I “hacked” the vaadin server bundle by adding
“DynamicImport-Package: *”
in vaadin server’s MANIFEST. The previous exception does not appear but I got the same for "
org.w3c.css.sac.CSSException
".

Note that by deploying the application .war file on tomcat, I had no error and the app looks like I expected (because all libraries are added under WEB-INF/lib and tomcat add them on the class loader). So, the problem is pure OSGi.

This is
issue #10307
. The theme compiler does have a few direct and indirect external dependencies, which are not proper OSGi modules as far as I know.

I would recommend pre-compiling the theme in OSGi environments.

If each module needs to bring its own contributions to the theme, they can be compiled separately. In that case, most modules should not import the standard themes but only provide their own specific rules and some core module should bring in reindeer or some other standard theme.

I considered this solution too. Thanks.