Google App Engine, GWT in development mode and Maven 2 - java

Currently I'm developing project with GAE/GWT. I'm using IntelliJ IDEA CE so there's no simple way of doing GWT development (it doesn't contain GWT plugin). However it seems to be possible to run the GWT server in development mode, so it will be able to pick up the changes made to classes.
There is some solitions to make IDEA CE GWT-friendly, like http://java.dzone.com/tips/gwt-development-intellij-idea. However nothing about GAE+GWT.
So now I'm looking for the way of starting GAE application (mvn gae:run) with having GWT in development mode. Can you please advice?

So what did I do in order to get it working:
1) add output directory settings so maven will generate files in place where GWT will expect them:
<outputDirectory>${project.build.directory}/${project.artifactId}-${project.version}/WEB-INF/classes</outputDirectory>
2) configure maven-gwt-plugin to respect your GAE app home
<extraJvmArgs>-Dappengine.sdk.root=${appengine.sdk.root}</extraJvmArgs>
3) configure maven-gae-plugin to provide correct paths for GAE home
<configuration>
<sdkDir>${appengine.sdk.root}</sdkDir>
<jvmFlags>-Dappengine.sdk.root=${appengine.sdk.root}</jvmFlags>
</configuration>
4) set the property to point to the home of GAE installation:
<appengine.sdk.root>/path/to/gae/home</appengine.sdk.root>
and then you will be able to run the server
mvn gwt:run
as well as debug it
mvn gwt:debug
works fine with IntelliJ IDEA CE 10, but don't forget to run
mvn war:exploded
after every "mvn clean" task

Just add following lines to gwt-maven-plugin configuration:
<server>com.google.appengine.tools.development.gwt.AppEngineLauncher</server>
<appEngineVersion>${gae.version}</appEngineVersion>
<extraJvmArgs>-Dappengine.sdk.root=${project.build.directory}/appengine-sdk/appengine-java-sdk-${gae.version}</extraJvmArgs>
Then run your application as usually - mvn gwt:run

In our project we use this steps - first run maven task -
mvn gae:debug and the second is remote connection on specific port(5005) to specific address.
If you required more explanation please welcome.

Related

STS, running any of the Guide projects

I install Spring Toolsuite.
I go to New -> Import Getting Started project.
I choose the 'Building a RESTful Web Service' one. Download only the 'complete' project, select maven and not to open the site.
Now what on earth to I have to do to launch it? Right-click on the project, run as, run on server, shows 'The selection cannot be run on any server'.
I have gone through loads of posts trying to find out what else I can do, done maven clean, maven install, changed the JRE Environment, nothing works.
Running a maven clean or maven install will only update the dependencies of the project (for instance, bring in Spring and its child dependencies, loggers, etc. specified in the pom.xml file).
To run the project right click on the class with the #SpringBootApplication
annotation (it will likely be the one with a main method in it, that's the one you want!). Then select 'Run as->Java Application'.
First a disclaimer. This answer applies to most of the guides. But there may be some to which it doesn't apply, because there's such a diversity of guides available.
Assuming you are trying a 'typical' guide which does something in the context of a web-app... then read on.
The reason that you can not run a guide with "Run On Server" is because of spring-boot adheres to the slogan of "Make Jar not War". The guide sample code are not things you deploy on a server (i.e war) but are standalone Java apps (i.e. jar) which contain their own embedded servlet container (if they need one). That means running them is really quite simple. Just find the 'main' method/class in the guide and use Eclipse "Run As >> Java Application".
There's also a convenient alias in STS called "Run As >> Spring Boot App" which does pretty much the same thing but gives you a few extra bells and whistles in the launch configuration editor.
Also... you don't really have to go look for the main method yourself because the "Run As >> Spring Boot App" knows how to find it in most cases. So clicking project and "Run As >> Spring Boot App" should do the trick.

How to run AngularJS in eclipse kepler?

I'm new to Angularjs and i'm trying to run first angular program with Spring. I downloaded the code from here: http://javahonk.com/spring-mvc-angularjs-integration/. Imported it as a maven project. Downloaded JSDT and AngualrJs plugin from eclipse marketplace but it's still not running. There is no error message. I'm running this on tomcat 7. What am I missing?
Any help would be appreciated?
I'm not a Eclipse user. so I have no idea for that. But you can use nodejs as a static server. it is explained here
1) Install nodejs for your OS
2) Run this command in a terminal (console)
> npm install http-server -g
3) Start server
> cd /path/to/your/project
> http-server -o --cors
Now you can access your project from browser http://localhost:8080/yourfile.html
Work in Eclipse and just refresh page on browser to see changes.
If you are working on a Spring Application within Eclipse IDE, your best alternative would be to start you appliction using an embedded Application Server (Best I would recommand are Jetty or Tomcat if you ain't need EE level components).
You can follow this link, which holds basic steps for adding a new Application Server within Eclipse IDE.
Once you have added a new application server, you can deploy your application in it then launch it and you should have your applcation reachable at http://localhost:8080/SpringMVCAngularJS.
A good alternative when using Maven as a build tool, is using an embedded AS plugin such as Tomcat7 Plugin or Jetty Plugin. This plugin will provide the ability to start your applcation using the Maven different goals (which does not require adding a new AS into Eclipse IDE).
I've pushed a sample module based on the tutorial you mentioned. YOu can test the above described plugin as follows in a *nix shell (You may need to setup git if not already done):
git clone https://github.com/tmarwen/stackoverflow-showcase.git
cd stackoverflow-showcase/springmvc-angularjs
mvn tomcat7:run

Managing Maven project in Eclipse with git repository

we recently migrated to Maven Build manager & git hub repository for our Java web-app. Also i switched to eclipse as eclipse has good set of plugins.
As a new bie, i am simply running mvn clean package from terminal at the code root directory. And then moving the compiled code i.e., /target/SNAPSHOT/* to tomcat/webapps/ROOT location.
And then starting Tomcat7 server. The process is time taking especially when i do code changes in Java & configuration .xml files.
I want to do it completely in IDE environment as i did earlier in Netbeans, update code -> build and run in debug mode, -> do code changes and then commit.
Heard of egit & m2e in eclipse for maven & github integration, but not sure how to use it.
Please walk me through the steps required in doing so. I am completely new to eclipse.
--
Thanks
You might want to consider using maven-jetty-plugin http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin for running the webapp. You will not need to copy over stuff to tomcat. After configuring this plugin, you can simply run your application by doing mvn jetty:run
I generally do not like running webapps inside Eclipse. It's a personal prefrence, but it is always nice to have an IDE neutral way of building and running your applications. If you have m2e things should work simply fine. I have seen maven-jetty-plugin having hot pluggability where if you changed your web.xml, jetty would reload your application.
We use Git for version control and Maven for dependency management and build automation. Once your project has successfully imported into Eclipse and recognized as a valid java web project, you don't need either Git or Maven in order to build/run it inside IDE. Just creat a server using you existing tomcat installation, add the project to server, then select Run as > Run on Server.
The Complete Guide:
Creating a server
Adding projects to a server
Starting a server
For more details, check out Testing and publishing on your server.

Publish for tomcat:run on Maven

I am considering using Maven 3 for my Spring projects which I have been developing using Eclipse and Tomcat. Until now;
I have been disabling "Republish automatically" because sometimes I don't need publish, I only save .java files (classes) and keep development on debug mode.
I republish (by clicking Eclipse's "publish" button on Servers view) only when I changed js, jsp or htm-like files, not class files, so I can keep developing without restarting Tomcat.
Now I am going to use Maven for debug/run on development but whenever I changed my code, I don't know how to do this "publish" issues on Maven as it doesn't use Eclipse's Tomcat directly. I stop maven and start again. Do I have to do this for all changes on my code? How can I make this maven -tomcat:run- "publish/republish" for js/jsp/html files and "do nothing" for .java files?
Unfortunately, yes, you'll have to run maven for every change.
Maven't isn't really intended to be used this way - it assumes that you're going to use maven when you're ready to build (ie after development), but use something like Eclipse if you're trying to see your changes in real time. It has no mechanism for listening for changes.
For my webapps I use both maven and Eclipse, with the m2e and the 'Maven Integration for Eclipse WTP' plugins. With that setup I can see my changes in real time using an embedded Tomcat instance in Eclipse, and when I'm done, I use maven to build.
Give those two plugins a shot - I think it'll meet your needs.
I had the same problem. And it happens because I ran maven eclipse:eclipse. Then, Server stop publishing (click on publish and said it was synchronized). I downloaded again .classpath and .project and other innerit files of eclipse project structure from cvs and server starts publishing again. May be this could help.
Regards,
For the benefit of Googlers:
I was getting NoClassDefFound errors using tomcat:run to start the app.
It took some googling but the following post notes that using tomcat:run-war enables your dependencies to get picked up from the WAR:
http://www.hascode.com/2010/06/java-server-facesjsf-2-tutorial-step-1-project-setup-maven-and-the-first-facelet/
However, for debugging and hot code replace, it's simplest to run Tomcat from the Servers view in Eclipse.

Problem with running Maven GWT application in Eclipse

I'm trying to create a GWT project through WebAppCreator enabled Maven2.
Project creation steps:
Create project with WebAppCreator (i'm using gwt-2.3.0) ->webAppCreator -noant -maven -XnoEclipse -out MyApp com.example.MyApp
Import project as existing maven project in eclipse (helios)
Enable "Project" -> "Properties" -> "Google" -> "Google web toolkit" -> "Use google web toolkit" checkbox
Set in project properties "Google" -> "Web application" -> "This project has a WAR directory". Set WAR directory path "src/main/webapp" and uncheck "launch and deploy from this directory"
Java build path is "MyApp/target/www/WEB-INF/classes"
I did not change the settings in pom.xml
Compile project using gwt eclipse plugin (2.3.0 version). It successfully compiled.
Try to run project as Web Application. When i run application GWT plugin does not ask me about WAR folder.
I did all this, I saw in the logs:
[WARN] Server class 'com.example.server.GreetingServiceImpl' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/home/redfox/workspace/java/redfox/MyApp/target/www/WEB-INF/classes/' to the web app classpath for this session
[WARN] Server class 'com.google.gwt.user.client.rpc.RemoteService' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/home/redfox/.m2/repository/com/google/gwt/gwt-servlet/2.3.0/gwt-servlet-2.3.0.jar' to the web app classpath for this session
And when i try to load page from URL (http://127.0.0.1:8888/MyApp.html?gwt.codesvr=127.0.0.1:9997) i see 404 error.
In logs i don't see any errors. How can i run this default application? Also i have another question: if this problev will be solved, how can i run this application in web mode (not in development mode) for using links like "http://127.0.0.1:8888" whithout param gwt.codesvr?
P.S. Sorry for my bad English.
I understand your frustration, trust me, I recently went through exactly the same issue you having now.
As Eugene indicated, follow his instructions, but...
On the Select an Archetype choose version 2.3.0-1 (Others may work but this one works for me)
Generate your sample app using theat Archtype version. Do a mvn gwt:run, you will see this screen (If all goes well)
Click on "Launch Default Browser".
Good luck.
Cheers
PB
I know this question is two years old. But i just had the same issue and now figured out how to fix it.
When eclipse doesn't ask you at the first launch for your "WAR" directory, you can also set it manually:
In eclipse go to "Run" -> "Debug Configuration...". Select your "Web Application" -> Select the "Arguments"-Tab and add the parameter e.g. "-war C:\YourProjectPath\target\YourProject-1.0-SNAPSHOT". Provide the full path here pointing to your target, generated by maven.
Hope that helps someone solving this issue faster :)
I know this is old, but here is my latest approach (as also answered here)
I can't speak for the webAppCreator because I haven't used it, but I have had good luck creating the Maven projects in Eclipse using the gwt-maven-plugin from codehause.
Creating a Maven GWT Project Directy in Eclipse
Open the new project wizard in Eclipse and filter on Maven Project.
Select the Maven Project and click next.
Enter the project location of your preference and click next.
Enter "gwt-" into the archetype filter and select the gwt-maven-plugin from codehaus. Click Next.
Enter your maven project details and a module value, then click Finish.
This will create a maven - gwt project for you in Eclipse. This comes with a sample application that you can use to make sure you can launch the application correctly.
Running the Application Command Line
Open command line.
Navigate to your project home.
Run the command "mvn clean package".
Run the command "mvn gwt:run"
This should get you up and running. If you used the 2.7.0 gwt-maven-plugin this should run the application in super dev mode by default.
Run the application in Eclipse
As you have done, navigate to Properties > Google > Web Application and check "This project has a WAR directory". The WAR directory using this plugin should be src/main/webapp.
Navigate to Properties > Google > Web Toolkit and check "This project has a WAR directory. You may be able to specify the module here. I am actually unable to do so, it may be specific to my Google Plugin for Eclipse or something environment specific...
Run As > Web Application.
If you had issues, as I have had, in step 2 then you will get an error Missing required argument 'module[s]'. To fix this open up your run configuration (should have been auto created) and in the arguments tab add the package qualified name for your module at the end of the arguments, e.g. com.mycompany.abc.GwtSampleModule. Do not add the ".gwt.xml" prefix.
It's worth also checking that the HTML page referenced in your arguments is correct, I have also had issues with that.
The application should now be configured for Launch in Eclipse using this run configuration. My verified environment is:
Eclipse Luna (v4.4)
Google Plugin for Eclipse (v3.8)
GWT Maven Plugin (v2.7.0)
What I suggest may start slightly different than you prefer but with better results :)
Install m2eclipse plugin. This will add a lot of nice maven features to your environment.
Using new project wizard create new Maven project
Do not select "simple project" check box, instead use the one of GWT archetypes (I suggest gwt-maven-plugin)
Then appropriate project structure with all required dependencies will be created for you by maven. More info about GWT plugin can be found at http://mojo.codehaus.org/gwt-maven-plugin/user-guide/archetype.html, including on how to execute it.
P.S. Your English is fine :)

Categories

Resources