Oh, I see now what Joe's done. Hack the web.xml in the gwt-dev-xxx jar. Make sure to do it again when you upgrade GWT versions. That's a cool way to get round it.
On Jan 7, 1:36 am, gregor <[email protected]> wrote: > Hi Scott, > > If you want to use features like this kicked off from web.xml then you > probably need to run hosted mode with the -noserver option. You cannot > access and modify web.xml for hosted mode embedded Tomcat. To run > using -noserver efectively you just need an Ant build file you can > easily run from your IDE to deploy your RPC servlets etc to your own > Tomcat instance when you change them, and then set a remote debugging > session on it so you can debug them if needed. > > Another way to get round this problem it is to instantiate all your > start up stuff from a static method in some class that when deployed > that gets called from a simple startup servlet instead of using > web.xml tags. Now that won't get called in GWT hosted mode (because > you can't edit web.xml to add a startup servlet...). But if you add a > static boolean to that start up class which gets set when its static > config method is run, then you can test for this in an init() method > of the first RPC servlet your application calls (or you can add a new > RPC service that specifically calls it using an if (!GWT.isScript()) > clause in onModuleLoad() which will be ignored in deployed mode). It > will then pick this up in hosted mode and call the config method, but > ignore it in deployed mode. It's a crude workaround, but it does work. > > Basically, if you want to use web.xml based conveniences they won't > work in normal GWT hosted mode. I don't think there are any plans to > change that, I guess because doing so would complicate things for > normal hosted mode operation and require a lot of work to do. > > regards > gregor > > On Jan 7, 12:42 am, "[email protected]" <[email protected]> > wrote: > > > It's great we got this figured out, but how come GWT hosted mode > > doesnt work with exisitng web.xml files so we dont have to code > > special configuration for development and production deployment? > > > Scott > > > On Dec 12 2008, 4:26 pm, Joe Cole <[email protected]> > > wrote: > > > > Oh, and in your web.xml's that you ship to your production environment > > > you would have a different listener setup. > > > > <listener> > > > > > > <listener-class>com.yourcompany.ProductionConfiguration</listener-class> > > > </listener> > > > > On Dec 13, 11:00 am, Joe Cole <[email protected]> wrote: > > > > > Here is our way: > > > > > In: > > > > tomcat/webapps/ROOT/WEB-INF/web.xml > > > > > <resource-ref> > > > > <res-ref-name>jdbc/dbsource</res-ref-name> > > > > <res-type>javax.sql.DataSource</res-type> > > > > <res-auth>Container</res-auth> > > > > </resource-ref> > > > > <listener> > > > > <listener-class>com.yourcompany.LocalConfiguration</listener-> > > > > class> > > > > </listener> > > > > > The only gotcha with this is that when you upgrade gwt it changes the > > > > web.xml - we just revert it from version control and all works well. > > > > > That listener sets up the entire servlet side, including properties & > > > > guice bindings: > > > > > public class LocalConfiguration extends AbstractConfiguration { > > > > protected IPropertyManager createPropertyManager( > > > > final ServletContext context) { > > > > return new LocalPropertyManager(); > > > > } > > > > public IBindings getBindings() { > > > > return new LocalBindings(); > > > > } > > > > > } > > > > > This allows us to ship different setups to the system depending on > > > > where it's being used (one for hosted mode, production, test, staging > > > > etc). > > > > The datasource is container managed which is why it's defined in the > > > > file. > > > > > The other file you will need for hosted mode is: > > > > tomcat/conf/gwt/localhost/ROOT.xml > > > > <Context privileged="true" antiResourceLocking="false" > > > > antiJARLocking="false" debug="1" reloadable="true" > > > > path=""> > > > > > <!-- GWT uses Tomcat 5.0.28 - use the 5.0 "style" for > > > > defining resources --> > > > > <!-- note that you ALSO have to add stuff like commons- > > > > pool, commons-dbcp > > > > and your JDBC driver to the GWTShell > > > > classpath --> > > > > > <Resource name="jdbc/ToopsterDB" auth="Container" > > > > type="javax.sql.DataSource" /> > > > > > <ResourceParams name="jdbc/dbsource"> > > > > > <parameter> > > > > <name>factory</name> > > > > <value> > > > > > org.apache.commons.dbcp.BasicDataSourceFactory > > > > </value> > > > > </parameter> > > > > > <parameter> > > > > <name>username</name> > > > > <value>YOURDBUSERNAME</value> > > > > </parameter> > > > > <parameter> > > > > <name>password</name> > > > > <value>SECRET</value> > > > > </parameter> > > > > <parameter> > > > > <name>driverClassName</name> > > > > <value>org.postgresql.Driver</value> > > > > </parameter> > > > > <parameter> > > > > <name>url</name> > > > > <value>jdbc:postgresql://URL/DB</value> > > > > </parameter> > > > > > </ResourceParams> > > > > </Context> > > > > > Let me know if this is useful - it took us a while to get this right, > > > > and we have used it in multiple deployed apps and it works well. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
