DevMode Jetty classloader problem?

296 views
Skip to first unread message

fuzebest

unread,
Feb 16, 2010, 9:09:23 AM2/16/10
to Google Web Toolkit
Hello,

My project uses GWT 2.0 and Spring DispacherServlet.
The Spring context is bootstrapped in web.xml with this declaration:

<servlet>
<servlet-name>service</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</
servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:/spring/*.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>


Please note the classpath*: resource prefix.

If I run my application in DevMode the Spring context finds no
resources.
This is was not a problem with GWT 1.6 or 1.7.
If I change the resource prefix to classpath: - everything will be
fine, all the resources from the webapp's
/spring directory will be loaded (but obviously not from the /spring
directory in all the jars).

I did some research and found the problem is likely caused by the
DevMode's Jetty classloader -
com.google.gwt.dev.shell.jetty.JettyLauncher.WebAppContextWithReload.WebAppClassLoaderExtension

The implementation overrides the findResource(String) method, but uses
findResources(String) from the superclass.
The default implementation does not find the project resources since
it was forced to use only the system classloader.

The Spring resource loader uses Classloader.getResources() to locate
the classpath*: resources. getResources() calls findResources()
internally, so no project resources for the Spring context.
As you can see this is not a Spring-specific problem, any call to
Classloader.getResources() will not find the project resources.

What do you think? Is this is a problem with the classloader or is it
an intended behavior?

Reply all
Reply to author
Forward
0 new messages