PlayN GWT/HTML, keeps insisting module must be (re)compiled - eclipse

I created a new PlayN project from the 1.2 archetype using the command line given in the GettingStarted wiki page. I then imported this Maven Project into Eclipse, just bringing in the core, java, and html modules. If I right-click the Java project, I can choose my main class, and a window pops up with the background image shown. Note that I've done no real programming yet: I'm just using the default project configuration.
Next, I used GWT-compile through Eclipse on the HTML project, and I got no errors. When I run it as a Web application by using the provided URL (without removing the "?gwt.codesvr=127.0.0.1:9997" bit), the application runs fine aside the Eclipse Console gives a warning about being in Development Mode. (Specifically, "You are running in GWT Development Mode. For optimal performance you may want to use an alternative method.")
However, if I run the application the recommended way, by removing the gwt.codesvr parameter, then I keep getting a dialog box saying "GWT module 'testproject' may need to be (re)compiled."
After reading How do I run a maven/eclipse/GWT/playN app in production mode?, I tried doing mvn test -Ptest-html
and then pointing my browser at http://localhost:8080, but it gives the same error.
Am I doing something wrong?
(EDIT: I have no idea if this next point is significant or not, but I'll share it anyway. When I try to create a project from Eclipse, the newest PlayN archetype I can see is 1.0.3, even after telling Eclipse to update the Maven index. I'm running Eclipse Indigo.)

I guess you are running PlayN 1.0.3.
There is a bug in 1.0.3:
So you need to do the following:
Run GWT-Compile
Run the web application and get the error message: "GWT module 'testproject' may need to be (re)compiled."
Run again GWT-compile, while the Web-Application is running
Reload your browser with CTRL-F5
The important step is step 3.
Note:
You can update to PlayN 1.2 to get rid of the error. For this you have to change the file playn-showcase/pom.xml.
Change the line
<version>1.0.3</version>
to
<version>1.2</version>

Related

in my eclipse its showing red cross error on each project.how to fix it?

I removed tomcat server after going into windows-->preferences-->server-->run time environmentsenter image description here. after this its showing red cross on each project .and not running any project even after adding the server. but newly created projects are running without any error. how to fix this red cross error from every project
As mentioned by #howlger, you should clean up your project's Java Build Path so that you only build against one Java runtime.
Ok, so after removing that Tomcat Server Runtime, you were probably prompted to remove it from any projects that were referring to it. If so, this is how to get things working again.
When working with Java, you need a Java Runtime from which to get the classes to compile your own code against. When working with servlets and JSP files, you need to get the Servlet API from somewhere so you can compile against them, and WTP (which you're using) has you get them from an actual server--like Tomcat (ideally the same version of the server you're going to deploy to, so you have the same libraries and classes at development time that you have at runtime). By removing it from your preferences and project(s), they no longer have jar files with those classes to compile your own sources against, so the Java tools don't know what those types are.
That means that fixing the problem requires getting a server runtime back on the Java Build Path. Screenshots are valid for Eclipse IDE 2021-12 (WTP 3.24).
Make sure you have a valid runtime on the Server / Runtime Environments preference page. In this picture, I've let it download both Apache Tomcat 9 and 10 for me. Really, you must have something here to proceed.
Open the Java Build Path property page of your project and select the Classpath node. Unless you select that node, the buttons to Add a Library won't enable.
Select the Server Runtime type of Library from the list. Continue through the later pages in the dialog until you've selected the runtime you intended. Once finished, your Servlets will be recompiled the next time a build happens.
I found the solution for this. To solve this issue just right click on project name and go to properties and then click on project facets. After that, click on runtimes and tick on Apache tomcat and and JRE and then apply. Done.

Run compiled/production javascript code of GWT maven project in Eclipse (through Jetty DevMode server)

I am trying to run GWT compiled/production javascript code from inside Eclipse for a project generated through the gwt-maven-plugin. Each time I launch a run/debug configuration (which points to the target/MyApplication-0.0.1-SNAPSHOT folder) through the Google plugin , the DevMode server mercilessly wipes out my compiled javascripts, and start to run things in dev mode, end-result being that if I remove the gwt.codesvr parameter from the URL, I get the dreaded "GWT module 'MyModuleName' may need to be (re)compiled".
How can I run my compiled/production javascript code through the DevMode server inside Eclipse ?
The aim being:
1) to confirm that the prod javascript code behaves the same in dev mode
2) to be still able to debug the server side java code if I want
Thank you very much in advance for your feedback and your expertise.
Regards
kb
This is a known regression of GWT 2.7, but it's not clear yet whether it'll be fixed or not: https://code.google.com/p/google-web-toolkit/issues/detail?id=9021
To debug your server-side code, use "Debug As… → Maven…" and use the jetty-maven-plugin or some tomcat?-maven-plugin, e.g. using the jetty:run-exploded goal.
Or use M2Eclipse Webby or the M2Eclipse WTP integration (in other words: do what you'd do for any other Maven-based Web project, as you want to put GWT out of the equation and only use the output of its compiler)

Running GWT application in production mode

I am newbie to GWT. I have built gwt maven project. To run in development mode, I first compiled project Google|Compile Project, then from command mvn gwt:run, it runs fine on
http://localhost:8888/index.html?gwt.codesvr=127.0.0.1:9997
but for production I want to access module
http://localhost:8888/index.html
When I omit gwt.codesvr= argument, I am getting error "gwt module may need to be recompiled". After Recompiling, I get the same error. Any help/pointer?
Thanks,
i run gwt project on tomcat on production mode. Jetty cant show it. Try to tun with external web module. When you are look at the IDE console title show us 'Development Mode'. Tyr with external , in any exception i can help.
You did it correctly, but as the error states, the module needs to be re-compiled (GWT Compiled). Once recompiled, Force your browser to reload (Ctrl + F5). If that doesn't work, you can look at this answer I wrote regarding cleanup of compiled output. Do what's listed there, and try running GWT compile again.
To run production mode outside Eclipse, you must do a GWT compile and create a WAR file, which you can then deploy on a Java application server such as Tomcat. This process is much easier with an ant build script.
To make an ant build script for your project:
You can easily create an ant build script by running the webAppCreator command from the directory where the GWT library is installed. That command will create a sample project just like clicking "New Web Application Project" in Eclipse, except it will also make a build.xml file.
You can run it in Eclipse by right clicking build.xml > Run As... > Ant build. By default it will run the build target. It also has a war target, which you can run to create a WAR file.
For more details on the webAppCreator, look here.

Running PlayN in HTML DevMode

I'd like to be able to run my PlayN project as a Web Application in DevMode, so that I can use a quick browser refresh to see code changes without having to recompile. From what I'm reading on the wiki and on this question it sounds like that should be possible.
I set up my project using: mvn archetype:generate -DarchetypeGroupId=com.googlecode.playn -DarchetypeArtifactId=playn-archetype -DarchetypeVersion=1.7 and importing the pom.xml into eclipse.
Here's what I can do:
Run from eclipse as a Java Application
Start the server using Maven command line: mvn -Phtml integration-test
While I can do most of my programming in Java and occasionally do the long build to test HTML, I'd love to be able to modify the code while testing HTML without recompiling.
By default, the option to run as a Web Application doesn't show up. I've tried going into the project's properties and checking the "Use Google App Engine" and "Use Google Web Toolkit" options, which creates the "Run As Web Application" option, but when I do so I get "Could not find any host pages in project XXX".
I then attempt to set a WAR directory under Properties->Google-Web Application. However, the closest thing to a WAR in the project is "src/main/webapp". I've tried using that, and I get the error: "The archive: /myproject-assets/src/main/java which is referenced by the classpath, does not exist."
I have the feeling I'm going about this all wrong. Can anyone point me in the right direction? Is what I'm doing even supposed to be possible? Thanks!
It is possible, but just know that in dev mode, playn runs very slow.
I don't know how to do this with eclipse, but with intelli IDEA, you do the following:
you need to create a module with a war artifact (to run as a server)
add the correct gwt libraries so that you can run gwt dev mode server with the aforementioned war module.
choose a GAE server (or, any gwt compatible server actually, this will be the server that runs the aformentioned war module).
run it! see this screenshot http://screencast.com/t/qK4JKvF33V
when you change code, the gwt devmode server should detect it, and automatically recompile (not sure if this needs to be in debug mode - i don't think it does).
you can try doing it via the command line, not sure if works, but this is what intellij runs (i've taken out the intellij specific bits out):
java -cp CLASSPATH_WITH_GAE_DEV_TOOLS_AND_GWT_DEV_TOOLS com.google.gwt.dev.DevMode
-war /path/to/war
-startupUrl Roborally.html com.yourgame.YourGwtEntryModule
-server com.google.appengine.tools.development.gwt.AppEngineLauncher

PlayN Maven Archetype and Running HTML5 in Eclipse

I generated a skeleton PlayN project from the playn-archetype and imported into Eclipse via m2e after verifying a successful build via
mvn clean package
After using the Google Plugin for Eclipse to successfully compile the html subproject, I then right click on the html subproject and perform a Run As -> Web Application.... Per the 'Getting Started' instructions on the PlayN wiki, I attempt to load the resulting Development Mode URL minus the ?gwt.codesvr=120.0.0.1:9997 suffix and am greeted with a dialog containing the following:
GWT module named 'project' may need to be (re)compiled.
I have verified that the <script> tag in my project.html is pointing to the appropriate javascript file (project/project.nocache.js), and I've verified that said javascript file exists and its contents browsed when navigating directly to it (i.e. http://127.0.0.1:8888/project/project.nocache.js).
The project works fine (albeit slowly) when the ?gwt.codesvr=120.0.0.1:9997 suffix is part of the URL (which is expected), and it also works fine when running mvn gae:run from the html subproject folder and browsing to http://127.0.0.1:8080/.
This is more of an annoyance than anything else, but I would at least like to know why it's happening and how to fix it :).
After you started the web application with "Run as... Web application" you need to recompile the project again (while the web application is running).
When you refresh your browser (be aware of the browser-cache) it should work.
This is a known issue is some older versions of PlayN.