stylesheet ignored/not handled in SDM 2.7.0-rc1

219 views
Skip to first unread message

Christian X

unread,
Nov 5, 2014, 3:19:54 AM11/5/14
to google-web-tool...@googlegroups.com
Hello,
I wanted to test the new SDM in 2.7.0-rc1.
A stylesheet that I reference im my model file is not loaded, in console I get the output:

[INFO] GET /overwrite.css
[INFO]    [WARN] ignored get request: /overwrite.css
[INFO]    [WARN] not handled: /overwrite.css

With gwt 2.6.1 I could use normal dev mode and everything was fine. If I use GWT 2.7.0-rc1 and compile my application to a war file it also works fine. Without this stylesheet I can't use devmode because everything looks to different from the compiled war file.

I use tomcat to deploy the war file and I have <noServer>true</noServer> set im my pom.xml, see configuration below.

I start devmode with:
mvn gwt:run

I use gwtbootstrap and in my overwrite.css I have a few css rules (corporate identity) to overwrite the gwtbootstrap css.

from my model file GUI.gwt.xml:

    <!-- Bootstrap -->
    <inherits name='com.github.gwtbootstrap.
Bootstrap'/>
    <inherits name='com.github.gwtbootstrap.datepicker.Datepicker'/>
    <inherits name='com.github.gwtbootstrap.datetimepicker.Datetimepicker'/>
    <set-property name="bootstrap.responsiveDesign" value="true"/>

    <!-- overwrite Bootstrap -->
    <stylesheet src="../overwrite.css"/>


the overwrite.css is placed in GUI/src/main/webapp  this is the same folder where my GUI.html file is.

configuration from my pom.xml:
...
    <properties>
        <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
    </properties>
...

<!-- GWT Maven Plugin -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>${gwtVersion}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>i18n</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <hostedWebapp>${webappDirectory}</hostedWebapp>
                    <runTarget>GUI/GUI.html</runTarget>
                    <noServer>true</noServer>
                    <port>8080</port>
                    <debugPort>8008</debugPort>
                    <localWorkers>8</localWorkers>

                    <i18nMessagesBundle>de.company.department.project.client.util.i18n.Translation</i18nMessagesBundle>

                    <extraJvmArgs>
                        -Xmx1024M -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:MaxPermSize=256M
                    </extraJvmArgs>

                    <disableClassMetadata>true</disableClassMetadata>
                    <disableCastChecking>true</disableCastChecking>

                    <closureCompiler>true</closureCompiler>
                    <draftCompile>false</draftCompile>
                    <optimizationLevel>9</optimizationLevel>
                </configuration>
            </plugin>

Thomas Broyer

unread,
Nov 6, 2014, 5:00:25 AM11/6/14
to google-web-tool...@googlegroups.com
As I understand it, when the *.nocache.js injects the stylesheets, relative paths are resolved against the SDM host (you see the message in the console, so I suppose it comes from the CodeServer/SDM) rather than the "web server" host (DevMode).
Could you check the exact URLs in your browser's dev tools? Specifically the port (9876 vs. 8888 with default settings)

Christian X

unread,
Nov 7, 2014, 7:41:03 AM11/7/14
to google-web-tool...@googlegroups.com
the file is requested from
http://127.0.0.1:9876/overwrite.css

Thomas Broyer

unread,
Nov 7, 2014, 8:50:55 AM11/7/14
to google-web-tool...@googlegroups.com

On Friday, November 7, 2014 1:41:03 PM UTC+1, Christian X wrote:
the file is requested from
http://127.0.0.1:9876/overwrite.css

Ah, yes, from https://gwt.googlesource.com/gwt/+/2.7.0-rc1/dev/core/src/com/google/gwt/core/ext/linker/impl/loadExternalStylesheets.js and https://gwt.googlesource.com/gwt/+/2.7.0-rc1/dev/core/src/com/google/gwt/core/ext/linker/impl/computeUrlForResource.js, your path being relative is resolved against GWT.getModuleBaseForStaticFiles() (i.e. SDM), because in many cases you'd want to reference a file that's in your module's "public path" so you want it resolved against your current sources to see your changes without having to restart DevMode/SDM.

You'll have to change either
  • the path to your CSS (e.g. /overview.css, but that won't necessarily work once deployed in production)
  • the location of your CSS (e.g. put it in your module's public path and reference it as <stylesheet src="overview.css"/>)
  • the way you load it (e.g. inject it from your onModuleLoad, either as a StyleElement added to the Document; or possibly as a TextResource that you inject using StyleInjector –and use one less request to the server)
Reply all
Reply to author
Forward
0 new messages