Community
Participate
Working Groups
(That's related to 451983 and 429905) We have css files that import other css files that way: @import url("colors.css"); Everything's fine when we debug the application from Eclipse. But a built executable application now doesn't have any CSS. We found out that this import silently fails and only works with @import url("platform:/plugin/ch.minova.e4.ui.bundle/css/colors.css"); An exception is caught in org.eclipse.e4.ui.css.swt.internal.theme.ThemeEngine.setTheme and cancels the whole CSS parsing. Probably exceptions should be caught in org.eclipse.e4.ui.css.core.impl.engine.AbstractCSSEngine.parseStyleSheet, so that all other CSS would be correcty parsed and only the faulty import would be skipped and the error logged. An additional improvement would avoid the problem I had: In org.eclipse.e4.ui.css.core.util.impl.resources.ResourcesLocatorManager.resolve three uriResolvers are used. The first is OSGiResourceLocator with startLocation "platform:/plugin/org.eclipse.ui.themes/css/". This should be the bundle where the parsed css file lies, probably additional to the org.eclipse default. I'm not too deep in this, so I don't dare to provide a gerrit fix. Greetings, Stefan
Stefan, would you mind adding a simple project we can use to test and fix the bug?
Created attachment 263984 [details] example project for css import In this sample project you can press a button. If you start this from eclipse neon, on click the theme changes. If you start the exported executable, on click nothing happens.
Stefan, how are you exporting the executable?
Created attachment 264066 [details] full exception when launching the applicaition with -consoleLog Reproduced with Eclipse SDK Version: Oxygen (4.7) Build id: I20160830-0800 OS: Windows 10, v.10.0, x86_64 / win32 Steps: 1. download, unzip and import the attached project in your workspace 2. launch from inside your eclipse, and you see it is working without errors 3. export using .product > Eclipse Product Export wizard 4. launch the exported with -consoleLog option. you will see the below exception. java.net.MalformedURLException at java.net.URL.<init>(Unknown Source) at java.net.URL.<init>(Unknown Source) at java.net.URL.<init>(Unknown Source) at org.eclipse.e4.ui.css.core.impl.engine.AbstractCSSEngine.parseStyleSheet(AbstractCSSEngine.java:204) at org.eclipse.e4.ui.css.swt.internal.theme.ThemeEngine.setTheme(ThemeEngine.java:428) at org.eclipse.e4.ui.css.swt.internal.theme.ThemeEngine.setTheme(ThemeEngine.java:389) at org.eclipse.e4.ui.css.swt.internal.theme.ThemeEngine.restore(ThemeEngine.java:560) truncated. see full exception attached
(In reply to Patrik Suzzi from comment #3) > Stefan, how are you exporting the executable? with the project export wizard "Eclipse product"
(In reply to Patrik Suzzi from comment #4) > 4. launch the exported with -consoleLog option. you will see the below > exception. If I launch with -consoleLog I see the same exception, but not in the created logfile. I didn't expect that. Maybe we should use the -consoleLog option more often. The exception says that there was a MalformedURLException while parsing the CSS that was caused by a NullPointerException. I would rather expect a FileNotFoundException or something like that. Now thanks for this hint. Nevertheless, would you consider one of my suggested change requests?
(In reply to Stefan Wild from comment #6) > Nevertheless, would you consider one of my suggested change requests? Yes, I'm on it now. Analyzing the details, (0) this is the URL received that fails, note the exclamation mark after .jar: jar:file:/C:/Users/myusername/Desktop/tmp-y/test_inner/eclipse/plugins/ch.minova.i18n.application_1.0.0.201609090149.jar!/css/default.css It fails as we get a NPE in the below code: // (1) importRule.getHref returns the URL above String path = getResourcesLocatorManager().resolve((importRule).getHref()); // (2) NPE here as path is null testFile = new File(new URL(path).getFile()); if (testFile.exists()) { url = new URL(path); }
New Gerrit change created: https://git.eclipse.org/r/80791
Created attachment 264076 [details] Archive containing the fixed org.eclipse.e4.ui.css.core project To see the solution working, unzip the archive, and replace the "org.eclipse.e4.ui.css.core *" folder in your exported application. Please tell if this fixes the issue.
*** Bug 430052 has been marked as a duplicate of this bug. ***
(In reply to Patrik Suzzi from comment #9) > Created attachment 264076 [details] > Archive containing the fixed org.eclipse.e4.ui.css.core project > > To see the solution working, unzip the archive, and replace the > "org.eclipse.e4.ui.css.core *" folder in your exported application. I have no such folder, but the .jar file. I replaced the content of this file with the content of org.eclipse.e4.ui.css.core_0.12.0.201609091415.zip/org.eclipse.e4.ui.css.core_0.12.0.201609091415 > Please tell if this fixes the issue. I keep getting java.net.MalformedURLException at java.net.URL.<init>(Unknown Source) at java.net.URL.<init>(Unknown Source) at java.net.URL.<init>(Unknown Source) at org.eclipse.e4.ui.css.core.impl.engine.AbstractCSSEngine.parseStyleSheet(AbstractCSSEngine.java:204) at org.eclipse.e4.ui.css.swt.internal.theme.ThemeEngine.setTheme(ThemeEngine.java:428) ... Actually I don't get it where the ! comes from. Loading of default.css is not the problem, but the import of common.css.
We have different versions. I tested on Oxygen. I'm going to merge the change and ask you to test the export and run with tomorrow's N-Build. After success, we can cherry pick to Neon.
Gerrit change https://git.eclipse.org/r/80791 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=99ee299db7b164c9bae1c986b7c5e260a9d848bd
Merged to master. You can verify the fix starting from the next nightly build.
The bug is fixed. I think we get benefits backporting this to Neon. What Do You Think?
how can I access the nightly build? http://download.eclipse.org/eclipse/updates/4.7-N-builds? btw, I would trust you when you say it's fixed.
(In reply to Stefan Wild from comment #16) > how can I access the nightly build? http://download.eclipse.org/eclipse/downloads and select the latest N-build. Today this is N20160911-0220 > btw, I would trust you when you say it's fixed. Better to test the fix. ;-)
It works with the Oxygen Nightly :-)
Thanks Stefan for the validation.
(In reply to Patrik Suzzi from comment #15) > The bug is fixed. I think we get benefits backporting this to Neon. > > What Do You Think? Approved.
New Gerrit change created: https://git.eclipse.org/r/81331
Gerrit change https://git.eclipse.org/r/81331 was merged to [R4_6_maintenance]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=939d33f9e59cdb29266be2432656d322e919d51b
The change is now in Neon (R4_6_maintenance) From the next Release, Neon will resolve .css references inside .jar files.