Saturday, November 19, 2016

Running GWT DevMode from a main()

I have to develop a GWT webapp, which in deployment will need to run from a standalone jar. To do this, I have a class with a main() method, in which jetty is executed and the pages served.
However, since I need to debug what happens in the main() also in development mode, so I'm looking for a solution that allows me to run the DevMode while at the same time having a main() method.
I tried with a dirty solution - i.e., call DevMode by reflection, so if (as in deployment) the class is not there, the standard jetty server is executed:
try {
Class<?> cls = Class.forName( "com.google.gwt.dev.DevMode" );
Method meth = cls.getMethod("main", String[].class);
meth.invoke(null, (Object) args );
} catch (Exception e) {
runJetty( args );
}
While this initially seemed to work, I then realized that the GWT DevMode seem to have its own ClassLoader, and all the REST methods and jetty listeners are loaded by this ClassLoader, thus preventing me from acceccing the initialization (e.g. some static variables) done in the main()
So what I want to understand is:
1) Is it feasible what I'm trying to do?
2) What's the correct way of running GWT's DevMode from a main?
3) How can I access the ClassLoader of GWT?

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment