java - How to configure mvn/Jrebel/wtp/gwt/eclipse to work smoothly with changes on the service interface -
i started investigate guice-rf-activities
artifact new maven gwt plugin thomas broyer.
i played little bit code , added function on greetingservice
on serverside. followed down path , added required bits , bytes until code calling either greetserver
or insultserver
method.
i found, simple sdm recompile did not make method available on server. restarting tomcat did not either. saving file in eclipse did not trigger compile properly.
in end, running full module compile did trick.
i see problem, change on service potentially give time coffee on large projects. there "trick", did not do, or complexity of requestfactory code generation heavy, cannot use sdm + jrebel or server restart change service interfaces?
update: way described thomas (thanks!) works, if plan start tomcat maven tomcat target.
update2: described launcherdir
approach wtp/eclipse/mvn/jrebel run.
if want use eclipse wtp tomcat launcher and, do, jrebel, compile server-classes on fly, jrebel reload not catch ofuscated rf service names.
fix this, add following jvm attribute wtp launch configuration (thanks, thomas!):
-dgwt.rf.servicelayercache=false
when server interface changes, following happens
(eclipse luna service release 2 (4.4.2), jrebel 6.x):
- change service , context classes required
- you see jrebel reloading class
- call
mvn process-classes
on commandline- you see jrebel reloading obfuscationfactory
- sdm compile in browser (f5 trick)
- your service working in client
linking gwt client code wtp server
to link codeserver wtp environment, src/main/webapp
folder needs contain gwt code folder. achieve this, codeserver must directed generate sdm stub @ right location. add property module/pom.xml
such:
<properties> <gwt.launcherdir>${project.build.directory}/gwt/launcherdir</gwt.launcherdir> </properties>
additionally, configure gwt maven plugin use property instead:
<build> <plugins> <plugin> <groupid>net.ltgt.gwt.maven</groupid> <artifactid>gwt-maven-plugin</artifactid> <inherited>false</inherited> <configuration> <launcherdir>${gwt.launcherdir}</launcherdir> </configuration> </plugin> </plugins> ...
to run codeserver inside eclipse or on commandline, give proper definition gwt.launcherdir
maven. using small cmd run codeserver eclipse:
mvn -dgwt.launcherdir=module-app-server\src\main\webapp gwt:codeserver
this way, "recompile on f5" works nice , smooth. full integration of gwt in eclipse maven , jrebel. wow. kudos @tbroyer :-)
the client side doesn't need special. server side though requires requestfactory
, requestcontext
, proxies hierarchy processed validation tool.
from command line, in context of archetypes, means launching process-classes
phase on *-server
module, e.g.
mvn process-classes -pl *-server -am
with mvn tomcat7:run -denv=dev
running, tomcat should detect class changes , automatically reload webapp.
then refresh page in browser, , after authenticating again (reloading webapp in tomcat loses session/authentication) can see changes end-to-end.
steps reproduce:
- create project
- in 1 terminal, launch
mvn gwt:codeserver -pl *-client -am
- in terminal, launch
mvn tomcat7:run -pl *-server -am -denv=dev
- open
http://localhost:8080
in browser, sign webapp , notice client-side app compiling automatically (that's new sdm in gwt 2.7) - edit
*-shared/src/main/java/**/greetingcontext.java
, duplicategreetserver
insultserver
- similarly, edit
*-server/src/main/java/**/greetingservice.java
, duplicategreetserver
,insultserver
(changehello
message insult feel change) - edit
*-client/src/main/java/**/greetingactivity.java
, replace callgreetserver
callinsultserver
(or add button , duplicate code) - in yet terminal, run
mvn process-classes -pl *-server -am
; notice tomcat reloads webapp - refresh page in browser, sign in again, , notice client-side app recompiling. hit button , insulted rather greeted. qed.
the validation tool can configured annotation processor in ide; see https://code.google.com/p/google-web-toolkit/wiki/requestfactoryinterfacevalidation details. note eclipse notoriously bad (broken?) wrt annotation processing; might better not run processor in editor call (i.e. incrementally) , instead trigger project build when you're done (that should –hopefully– equivalent mvn process-classes
), or launch mvn process-classes
within eclipse.
note advise against launching mvn gwt:codeserver
, mvn tomcat7:run
within eclipse, eclipse hard-kills processes, causes codeserver
stay alive (it's forked process), , won't run jvm shutdown hooks or servletcontextlistener
's contextdestroyed
.
Comments
Post a Comment