简体   繁体   English

Vaadin / OSGi:找不到ScssStylesheet类

[英]Vaadin/OSGi : ScssStylesheet class not found

I use vaadin and OSGi to create a modular application. 我使用vaadin和OSGi来创建模块化应用程序。 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: 当我尝试访问http://localhost:8080/myapp/VAADIN/themes/myTheme/styles.css我遇到以下异常:

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)[/code]

com.vaadin.sass.internal.ScssStylesheet class is offered by vaadin-theme-compiler-7.xxjar but the server doesn't import this package. com.vaadin.sass.internal.ScssStylesheet类由vaadin-theme-compiler-7.xxjar提供,但服务器不导入此包。 Then, I "hacked" the vaadin server bundle by adding DynamicImport-Package: * in vaadin server's MANIFEST. 然后,我通过在vaadin服务器的MANIFEST中添加DynamicImport-Package: *来“破解”vaadin服务器软件包。 The previous exception does not appear but I got the same for org.w3c.css.sac.CSSException . 之前的异常没有出现,但我对org.w3c.css.sac.CSSException也有同样的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). 请注意,通过在tomcat上部署应用程序.war文件,我没有错误,应用程序看起来像我预期的那样(因为所有库都添加在WEB-INF / lib下,tomcat将它们添加到类加载器上)。 So, the problem is pure OSGi. 所以,问题是纯OSGi。

based on the Vaadin 7.1.3 bundles, the following changes need to be made: 基于Vaadin 7.1.3软件包,需要进行以下更改:

  • import com.vaadin.theme-compiler in com.vaadin.server 在com.vaadin.server中导入com.vaadin.theme-compiler
  • import org.w3c.css.sac in com.vaadin.shared.deps and com.vaadin.theme-compiler 在com.vaadin.shared.deps和com.vaadin.theme-compiler中导入org.w3c.css.sac
  • provide a ScssStylesheetResolver via ScssStylesheet.setStylesheetResolvers which loads from bundle resources, not (only) filesystem / classloader as the default implementation. 通过ScssStylesheet.setStylesheetResolvers提供ScssStylesheetResolver,它从bundle资源加载,而不是(仅)filesystem / classloader作为默认实现。
  • if you import parts of the original themes in your theme, consider creating it as a fragment to com.vaadin.themes, which in turn can then be used as a base for the ScssStylesheetResolver 如果您在主题中导入部分原始主题,请考虑将其创建为com.vaadin.themes的片段,然后可以将其用作ScssStylesheetResolver的基础

This sounds like a packaging bug in Vaadin which should be reported to the authors. 这听起来像Vaadin中的包装错误,应该向作者报告。 If the core Vaadin bundle needs to access classes from the package com.vaadin.sass.internal then it should include that in its Import-Package header. 如果核心Vaadin包需要从com.vaadin.sass.internal包中访问类,那么它应该在其Import-Package头中包含它。

With respect to org.w3c.css.sac , you don't specify which bundle throws an error but it sounds like the same kind of problem. 对于org.w3c.css.sac ,您没有指定哪个包引发错误,但它听起来像是同一类问题。 Whichever bundle uses that package should import it via Import-Package. 无论哪个包使用该包,都应通过Import-Package导入它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM