Vinicius
First part I'd check is whether you really mean this:
httpService.registerResource("/OSLApplication.html","/OSLApplication.html",webcontext);
//This is the GWT entry-point
I think that means all names will get resolved to a base alias of
"/OSLApplication.html" - I wonder whether you really want the ".html". I
suspect what you really want is something like:
httpService.registerResource("/com.mycompany.myapp.OSLApplication","/OSLApplication",webcontext);
//This is the GWT entry-point
This will ensure your alias starts at the "root" of your application
resources, and will let you resolve any and all resources including the
.html "index page"
Your 2nd part of resource resolving looks pretty much the same as ours:
retVal =
GwtServlet.class.getClassLoader().getResource("resources/www" + baseUri
+ name);
Note that we have no leading / though - it's just /resources"
I would suggest putting a System.out trace statement in your routine to
see what the "name" param value is when it comes in.
You need to make sure that the String you construct:
resources/www" + baseUri + name
matches exactly the path to the resource in your bundle JAR. It could be
that the "name" param coming in may have something like a leading / or
some other unexpected prefix. We have to do a couple of "massages" to
the received name in our model on the way in:
public URL getResource(String name)
{
// makes sure a "/" or empty URL resolves to our index page
if (name.equals("/") || name.length() == 0)
{
name = indexPage;
}
//Not sure why we need this - but under Jetty6/GWT1.5.2 there
//seems to be a direct call with alias still attached
if (name.startsWith(alias + "/"))
{
name = name.substring(alias.length());
}
Also note - that the "resource" you're looking for *must* be in the same
bundle JAR as your GWTService class.
resources/www/<your URI base>/<your name>
I found that putting copious trace statements in the resource handling
code helped me get over the initial hump of things not resolving.
Regards
-- Rob
Vinicius Carvalho wrote:
And when the method from webcontext is finally called when the user points
to localhost:8080/myapp/OSLApplication.html:
public URL getResource(String name) {
// TODO Auto-generated method stub
return GWTService.class.getResource("/resources/www/"+baseURI+name);
}
We are always getting null
We tried:
"resources/www/"+baseURI+name
And also did not work
We tried using
GWTService.class.getClassLoader.getResource...
even
Thread.currentThread().getContextClassLoader().getResource
It always returns null.
The jar is packaged:
org/
resources/
META-INF
But it seems that resources/ is not being loaded by the class loader, do we
need any special directive on the MANIFEST?
Regards
--
Ascert - Taking systems to the Edge
[email protected]
+44 (0)20 7488 3470
www.ascert.com