GWT.getModuleBaseURL() in 1.1 with -noserver option

337 views
Skip to first unread message

Gunnar Wagenknecht

unread,
Aug 15, 2006, 1:35:37 PM8/15/06
to Google Web Toolkit
Hi!

GWT 1.1. removed the need for a gwt-hosted.html file. In my projects
GWT.getModuleBaseURL() now returns an empty string when used in hosted
mode with the -noserver option. The compiled code works fine in the
browser it just doesn't work in the development shell started with the
"-noserver" option.

Is this a known issue or is there a configuration workaround?

Cu, Gunnar

hovan

unread,
Aug 15, 2006, 2:18:48 PM8/15/06
to Google Web Toolkit
Gunnar,

It's not a bug at all. It took me almost 1 hour to figure things out.
To run in -noserver mode:

1. Don't do any <servlet> mapping in .gwt.xml file or mapping without
module name

2. web.xml have to map with module name (something like
/modulename/servicename)

3. service end point must include: getModuleBaseURL() + servicename

Thanks,
hovan.

Gunnar Wagenknecht

unread,
Aug 15, 2006, 2:31:50 PM8/15/06
to Google Web Toolkit
hovan schrieb:

> It's not a bug at all. It took me almost 1 hour to figure things out.
> To run in -noserver mode:

Hoven, that's not my problem.

GWT.getModuleBaseURL() in hosted with -noserver !=
GWT.getModuleBaseURL() in compiled mode

So, the resource or service works using the compiled JavaScript but not
in the hosted browser. For example, new Image(GWT.getModuleBaseURL() +
"/myimage.png") works perfect in the compiled version but does not work
in the hosted browser (because GWT.getModuleBaseURL() in an empty
string there).

Cu, Gunnar

hovan

unread,
Aug 15, 2006, 4:06:02 PM8/15/06
to Google Web Toolkit
For the images go with module, it's better to put in public folder and
use path without module name.
so just use /myimage.png.

Gunnar Wagenknecht

unread,
Aug 15, 2006, 4:09:09 PM8/15/06
to Google Web Toolkit
They are in the public folder and they do work in compiled mode. But
anyway, anything that relays on GWT.getModuleBaseURL() is broken in
hosted mode with -noserver option for me and I'm trying to find out why
GWT.getModuleBaseURL() returns an empty string there.

hovan

unread,
Aug 15, 2006, 4:24:20 PM8/15/06
to Google Web Toolkit
It works just fine for me on, hosted with or without -noserver and in
compiled mode. Because of something like this in .nocache.html
function onLoad() {
if (!$wnd.__gwt_isHosted) return;
if (!$wnd.__gwt_isHosted()) {
selectScript();
}
else {
var mcb = $wnd.__gwt_tryGetModuleControlBlock(location.search);
if (mcb) {
$moduleName = mcb.getName();
$moduleBaseURL = mcb.getBaseURL();
mcb.compilationLoaded(window);
}
}
}
I guess.

Gunnar Wagenknecht

unread,
Aug 15, 2006, 4:28:45 PM8/15/06
to Google Web Toolkit
Yes, this worked for me before. But now with 1.1. it stopped working.
What arguments do you use when launching the development shell?

hovan

unread,
Aug 15, 2006, 4:37:44 PM8/15/06
to Google Web Toolkit
Google guys don't you the gwt-hosted.html file to load the module
anymore. Because of the cache problem i think. So no parametters send
back to server in hosted mode.
I did upgrade my apps this morning, it was a little pain, but i am ok
now:)

Gunnar Wagenknecht

unread,
Aug 15, 2006, 4:40:39 PM8/15/06
to Google Web Toolkit
I know that they don't use it anymore. That's what I wrote in my first
post (see top). :)

So, what arguments to you use for launching your development shell?

hovan

unread,
Aug 15, 2006, 4:47:33 PM8/15/06
to Google Web Toolkit
I use ant to launch the hosted mode, just forget about class path.

<target name="run-test.hosted">
<java classname="com.google.gwt.dev.GWTShell" fork="true">
<classpath refid="gwt.classpath"/>
<classpath location="${gwtx.jar}"/>
<classpath location="${src.dir}/gwtx-test"/>
<classpath location="${build.dir}/gwtx-test/classes"/>

<arg value="-noserver"/>
<arg value="-out"/>
<arg value="${build.dir}/gwtx-test/www"/>
<arg
value="http://localhost:8080/gwtx-test/com.xp.test.gwtx.XModule/XModule.html"/>
</java>
</target>

Gunnar Wagenknecht

unread,
Aug 15, 2006, 5:18:26 PM8/15/06
to Google Web Toolkit
Mhm. That's weird. I did some debugging and something is different
here. I added two alerts to the the #onLoad in the .nocache.html file.

$moduleName = mcb.getName();
$moduleBaseURL = mcb.getBaseURL();

alert('look:' + $moduleName);
alert('look:' + $moduleBaseURL);

The module name is correct. But $moduleBaseURL is empty. I think the
problem is my URL.

http://localhost:8080/com.company.product.component.webapp/client/com.company.product.component.gwt.ProductClient/ProductClient.html

Maybe GWT is confused by the context URL of my webapp. ;)

Cu, Gunnar

hovan

unread,
Aug 28, 2006, 3:38:29 PM8/28/06
to Google Web Toolkit
Gunnar,

This blank thing got fixed on 1.1.10. Now you will get
http://localhost:8888/modulename for hosted mode with or without server
option

hovan.

Reply all
Reply to author
Forward
0 new messages