PlayN Maven Archetype and Running HTML5 in Eclipse - 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.

Related

How to bootstrap UI5 resources without CDN in Eclipse?

I'm doing a walkthrough for SAPUI5.
The code src="/resources/sap-ui-core.js" doesn't work, because I can't find this directory in my project.
When using a CDN URL, it works fine. But I don't want to use CDN for my application.
So how can I get and import the sap-ui-core.js file into my project so that it is saved on my computer locally?
I'm working with Eclipse btw. and installed the SAPUI5 Tools for Eclipse.
The SAPUI5-Plugin for eclipse includes the SAPUI5 library files.
If you start the App using "Run as..."->"Web App Preview" on your index.html, eclipse starts a jetty http server which serves the SAPUI5 library at /resources.
As long as you don't close the preview window in eclipse you can use any browser to debug your application at the url you find in that preview window.
Check that the dependencies are correct in your project, because the general dependency file such as sap.m may be missing in the project file.

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

Issue with deploying GWT app to tomcat in eclipse

Following this tutorial, I could execute GWT app using eclipse. I could access the app at http://127.0.0.1:8888/De_vogella_gwt_helloworld.html?gwt.codesvr=127.0.0.1:9997.
Then, I googled to find a way to deploy the app to tomcat, and I found this site. It has two step way to exporting GWT app to tomcat.
Exporting the src directory into jar file.
Using ant create a war file.
I copied the hello.war file into /Library/Tomcat/webapps, and open the browser with localhost:8080/hello to get this error.
When I click the HTML file in webapps directory, so I think something's wrong with the packaging.
What might be wrong?
You need to compile your GWT app to run in production mode. See this section of the GWT doc for detailed steps (for GWT 2.4).
From David's answer, I could get it working.
I had to compile the application again.
to get it working.

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

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>