GWT: CSS file defined in module definition file (gwt.xml) doesn't work? - gwt

From GWT tutorial (http://www.gwtproject.org/doc/latest/DevGuideUiCss.html), we know there are multiple approaches for associating CSS files with your module. Therein, one way is using the <stylesheet> element in the module XML file.
When I used the way to do it, I got the warning message below. It seems the way doesn't work.
Here's the contents of module1.gwt.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.7.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.7.0/distro-source/core/src/gwt-module.dtd">
<module rename-to="entry1">
<inherits name="com.google.gwt.user.User" />
<inherits name='com.google.gwt.user.theme.clean.Clean'/>
<source path="client" />
<entry-point class="com.jst.gwt2.client.Entry1"></entry-point>
<stylesheet src="../entry1.css" />
<source path='client' />
<source path='rpc' />
</module>
Here's the warning message:
GET /entry1.css
[WARN] ignored get request: /entry1.css
[WARN] not handled: /entry1.css

quoting #Thomas Broyer:
to get the full explanation click here
You'll have to change either
the path to your CSS (e.g. /entry1.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="entry1.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)

Related

GWT error even on official tutorials: Check that your module inherits 'com.google.gwt.core.Core' either directly or indirectly

I am learning GWT and was trying to run this tutorial by Vogella and also the official GWT tutorial.
Using the Eclipse GWT plugin 3.0 on Windows 10 and JDK 11
I marked the Maven Project checkbox.
When I right-click and Run As
Turning off precompile in incremental mode.
Super Dev Mode starting up
workDir: C:\Users\My\AppData\Local\Temp\gwt-codeserver-8137229043727681777.tmp
2021-04-29 12:03:13.494:INFO::main: Logging initialized #718ms
Loading Java files in de.vogella.gwt.helloworld.De_vogella_gwt_helloworld.
[ERROR] Hint: Check that your module inherits 'com.google.gwt.core.Core' either directly or indirectly (most often by inheriting module 'com.google.gwt.user.User')
I see that it is inheriting User
<?xml version="1.0" encoding="UTF-8"?>
<!--
When updating your version of GWT, you should also update this DTD reference,
so that your app can take advantage of the latest GWT module capabilities.
-->
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.8.1//EN"
"http://www.gwtproject.org/doctype/2.8.1/gwt-module.dtd">
<module rename-to='de_vogella_gwt_helloworld'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.clean.Clean'/>
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<!-- Specify the app entry point class. -->
<entry-point class='de.vogella.gwt.helloworld.client.De_vogella_gwt_helloworld'/>
<!-- Specify the paths for translatable code -->
<source path='client'/>
<source path='shared'/>
<!-- allow Super Dev Mode -->
<add-linker name="xsiframe"/>
</module>
This SO question was not relevant to my issue.
Almost certainly you are either missing gwt-user.jar from your classpath, or somehow the gwt-user.jar version doesn't match the gwt-dev.jar, which will cause problems. Every module automatically inherits com.google.gwt.core.Core (despite the error message), and as your .gwt.xml shows, you already have User added.
--
Additionally, from your linked SO post, do check the comments - there are some better, more modern tutorials listed.

Is it possible to use the GWT Elemental collections in a non-elemental app?

Is it possible to use the Elemental collections (elemental.util.Collections, elemental.util.ArrayOfInt, elemental.util.MapFromStringTo, etc) in a non-elemental GWT app. I'm using these modules already:
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />
<!-- Inherit the RequestBuilder stuff. -->
<inherits name="com.google.gwt.http.HTTP" />
<!-- Inherit GQuery -->
<inherits name='com.google.gwt.query.Query' />
But I'd like to start using the lightweight Elemental collections rather than Java ArrayList and HashMap. Is that possible? Would it be fairly easy to port from Elemental into it's own module for this purpose? Thanks for you help.
Sure, all you have to do is include the following declaration in your module descriptor (*.gwt.xml):
<inherits name="elemental.Elemental"/>
See the elemental example on the GWT trunk.
I could not get the GWT Elemental projects silvercomet or simple to execute in FireFox.
However a below simple elemental test code executes in FireFox and Chrome along with gwt user and http modules.
Module File.
<module rename-to="HelloElemental">
<inherits name="elemental.Elemental" />
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />
<!-- Inherit the RequestBuilder stuff. -->
<inherits name="com.google.gwt.http.HTTP" />
<add-linker name="xsiframe" />
<set-configuration-property name="devModeRedirectEnabled" value="true" />
<entry-point class="com.google.silvercomet.client.Main" />
</module>
Entry Point Class -
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Window;
import elemental.util.ArrayOf;
import elemental.util.Collections;
public class Main implements EntryPoint
{
public void onModuleLoad()
{
ArrayOf<String> items = Collections.arrayOf();
items.insert( 0, "First" );
Window.alert( items.get( 0 ) );
}
}

not able to use smart GWT

trying to use smart GWT
Using smart gwt 2.5 dowloded from link below
smartgwt 2.5
Firefox 6.0
I made a small web application project(without smart GWT) which is working fine.
Now in the *same project i added smartGwt 2.5
and added <inherits name="com.smartgwt.SmartGwt"/>
in myprojet.gwt.xml file.
but now when i am running the project it gives me following error:
[ERROR] [myprojet] - Unable to load module entry point class
com.smartgwt.client.SmartGwtEntryPoint (see associated exception for details)
com.google.gwt.core.client.JavaScriptException: (TypeError): $wnd.isc is undefined
at com.google.gwt.dev.shell.BrowserChannelServer.invo keJavascript(BrowserChannelServer.java:248)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke (ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative( ModuleSpace.java:561)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeV oid(ModuleSpace.java:289)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNati veVoid(JavaScriptHost.java:107)
at com.smartgwt.client.SmartGwtEntryPoint.init(SmartG wtEntryPoint.java)
at com.smartgwt.client.SmartGwtEntryPoint.onModuleLoa d(SmartGwtEntryPoint.java:239)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(Module Space.java:396)
at com.google.gwt.dev.shell.OophmSessionHandler.loadM odule(OophmSessionHandler.java:200)
at com.google.gwt.dev.shell.BrowserChannelServer.proc essConnection(BrowserChannelServer.java:525)
at com.google.gwt.dev.shell.BrowserChannelServer.run( BrowserChannelServer.java:363)
at java.lang.Thread.run(Thread.java:662)
when i remove the <inherits name="com.smartgwt.SmartGwt"/>
from myprojet.gwt.xml file the project works fine
XML
<inherits name='com.google.gwt.user.User' />
<inherits name='com.google.gwt.user.theme.clean.Clean' />
<!-- Other module inherits -->
<inherits name="com.smartgwt.SmartGwt"/>
<!-- Specify the app entry point class. -->
<entry-point class='com.example.client.MyProjet' />
<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />
Your gwt.xml seems correct.
GWT Compile and cleaning brwoser cache should work.

gwt app deployment to tomcat doesn't load compiled javascript

I use Eclipse GWT Plug-in to build a GWT app. Later on, I'll have to deploy this as a Tomcat webapp. I have read many pages on how to do it and it looks dead simple but it doesn't work here.
If I create a new Web application using the plug-in and that I copy the war directory content to de tomcat_install/webapps folder it works right out the box, I get the application and all the things get loaded correctly.
If I do the same with the application I'm working on for a couple of weeks now, I get nothing, there is just the plain html file I use as welcome page that loads. If I inspect the page I can see it has correctly loaded the .nocache.js but no controls whatsoever show up on my page.
Everything works in development, my servlet are correctly mapped.
Here is my app.gwt.xml :
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='VirtualLabPortal'>
<inherits name="com.google.gwt.user.User" />
<inherits name='com.google.gwt.user.theme.standard.Standard'/>
<inherits name="com.google.gwt.i18n.I18N"/>
<set-property name="gwt.logging.enabled" value="FALSE"/>
<define-property name="webkitVariant" values="safari, chrome" />
<collapse-all-properties />
<extend-property name="locale" values="en"/>
<extend-property name="locale" values="fr" />
<set-property-fallback name="locale" value="fr"/>
<entry-point
class="com.banctecmtl.ca.vlp.view.webview.client.VirtualLabPortal" />
<source path='view/webview/client' />
<source path='shared' />
<source path='model' />
</module>
My web,xml, where my two servlet are mapped looks like this :
<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<servlet>
<servlet-name>VlpControllerService</servlet-name>
<servlet-class>com.banctecmtl.ca.vlp.view.webview.server.VlpControllerServiceImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>UserAccessService</servlet-name>
<servlet-class>com.banctecmtl.ca.vlp.view.webview.server.UserAccessServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>VlpControllerService</servlet-name>
<url-pattern>/VirtualLabPortal/VlpController</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>UserAccessService</servlet-name>
<url-pattern>/VirtualLabPortal/UserAccess</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>VirtualLabPortal.html</welcome-file>
</welcome-file-list>
</web-app>
Note that in my services interfaces I use #RemoteServiceRelativePath("VlpController") and #RemoteServiceRelativePath("UserAccess") to ensure a correct mapping.
This is the content of my entrypoint, that I made plain simple just to see if I could get it to work on deployment :
public class VirtualLabPortal implements EntryPoint {
/**
* Entry point method.
*/
public void onModuleLoad() {
RootPanel.get().add(new Label("This"));
}
}
Since the body of my html page is empty, a white page shows up, the javascript should write the test label on that page, but nothing happens. As I said, my VirtualLabPortal.nocache.js is loaded in the html page.
Is there something I'm completely missing here?
EDIT :
I think i just got it, I removed two properties my partner added to the gwt.xml file to reduce the number of permutations and it seems to be fixed so far:
<set-property name="gwt.logging.enabled" value="FALSE"/>
<define-property name="webkitVariant" values="safari, chrome" />
<collapse-all-properties />
Do you compile your project via :
project right clic > google > gwt compile
and then
project right clic > export > WAR file
this is the way I proceed, it works !
check this one:
Deploying GWT app from GAE to Tomcat
After long hours of searching and testing, I understtod how GWT bootstrapping process was working. I looked over my module.gwt.xml file and I found the following line added by one of my partners to reduce the number of permutations :
<collapse-all-properties />
Removing this line brought us back to 18 permutations and deploying the WAR folder to my tomcat webapps directory did the job. Compiling only once was not generating the file used required by my locale. Maybe if my browser language would have been in English it would have worked out the first time.
Well now it works as all the required files are correctly compiled.

GWT - Unable to find type 'com.myapp.launcher.client.LauncherInitializer' multi-module architecture

I have a project with the following structure:
com.myapp.gwt:
Basic.gwt.xml
Launcher.gwt.xml - inherits Basic.gwt.xml
Module1.gwt.xml - inherits Basic.gwt.xml
com.myapp.gwt.ui.basic.client:
AppActivityMapper.java
AppHistoryManager.java
AppPlaceHistoryMapper.java
BasicInitializer.java - this is a daddy class for all entry points
MainClientFactory.java
MainClientFactoryImpl.java
com.myapp.gwt.ui.launcher.client: - all the stuff for the launcher module is here
LauncherInitializer.java (extends BasicInitializer, launcher module's EntryPoint)
com.myapp.gwt.ui.launcher.client.places:
Places and activities for the launcher module
com.myapp.gwt.ui.module1.client: - all the stuff for the module1 module is here
Module1Initializer.java (extends BasicInitializer, module1 module's EntryPoint)
com.myapp.gwt.ui.module1.client.places:
Places and activities for the module1 module
com.myapp.gwt.shared:
Stuff shared between the client and the server (interfaces, dtos)
com.myapp.gwt.server:
Code that works only on the server
what i have in my Basic.gwt.xml is this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.1.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.3.0/distro-source/core/src/gwt-module.dtd">
<module rename-to='myapp'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.clean.Clean' />
<inherits name="com.google.gwt.place.Place" />
<inherits name="com.google.gwt.activity.Activity" />
<inherits name="com.google.gwt.editor.Editor" />
<!-- Specify the paths for translatable code -->
<source path='ui.basic.client' />
<source path='shared' />
<replace-with class="com.myapp.gwt.ui.basic.client.ClientFactoryImpl">
<when-type-is class="com.myapp.gwt.ui.basic.client.ClientFactory" />
</replace-with>
<set-configuration-property name="UiBinder.useSafeHtmlTemplates" value="true" />
</module>
what i have in my Launcher.gwt.xml is this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.1.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.3.0/distro-source/core/src/gwt-module.dtd">
<module rename-to='launcher'>
<!-- Other module inherits -->
<inherits name="com.myapp.gwt.Basic" />
<!-- Specify the paths for translatable code -->
<source path="ui.launcher.client"></source>
<!-- Specify the app entry point class. -->
<entry-point class='com.myapp.gwt.ui.launcher.client.LauncherInitializer' />
</module>
None of my classes residing inside the com.myapp.gwt.ui.basic.client package have reference to any of the classes inside the other module packages. The other module packages on the other hand have lots of references to the basic module and some of the classes even extend the classes inside the basic package.
The problem is that i'm getting this error during compiling to javascript launcher module:
[TRACE] [launcher] - Finding entry point classes
[ERROR] [launcher] - Unable to find type 'com.myapp.gwt.ui.launcher.client.LauncherInitializer'
[ERROR] [launcher] - Hint: Previous compiler errors may have made this type unavailable
[ERROR] [launcher] - Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly
[ERROR] [launcher] - Failed to load module 'launcher' from user agent 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0' at localhost:61253
Also please tell me if you see something worth changing in the stuff i've done.
Just a quick guess: did you try : <source path='ui/basic/client' />