I would like to add some GWT (Google web toolkit) functionality to my existing web application built with maven (servlets, jsps etc). I have read some tutorials about GWT and managed to successfully write some basic examples but I can't seem to understand how to integrate it with my existing project. All the tutorials that I found focus on building this application from scratch (without Maven) or by crating new project with GWT archetype (with Maven).
How do I proceed with existing application (webapp archetype)? I tried adding the path do GWT SDK to the project and created basic HelloWorld class (I created separate package structire just for GWT) following THIS tutorial.
What I don't understand is how to setup everything correctly and where to place the configuration files? Is the config file supposed to be in the root folder of the project (next to pom.xml)? Should it be named the same as my project is named or based on the class specified as entry point?
Basically, my current structure looks like this:
src/main/java/wa2/gwt/clients/CarRental.java
src/main/webapp/CarRental.html (same directory as my JSPs)
src/resousrce/wa2/gwt/CarRental.gwt.xml (same directory as pom.xml) - let's say that my project is called "CarRental"
This obviously does not work. Did I forgot some configuration? Are the locations wrong? Thanks for any help!
EDIT: I changed the structure of the project and added the maven dependencies. It seems that GWT is recognized now. However, it is still not running any GWT code when accessing the html page.
This is my silly test with CarRental.html (src/main/webapp/CarRental.html):
<html>
<head>
<title>CarRental</title>
<script language="javascript" src="carrental/carrental.nocache.js">
</script>
</head>
<body>
<h1>Hello World</h1>
<p>Welcome to first GWT application</p>
</body>
</html>
The CarRental.java (src/main/java/wa2.gwt.clients.CarRental.java):
package wa2.gwt.clients;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Window;
public class CarRental implements EntryPoint {
public void onModuleLoad() {
Window.alert("Hello, World!");
}
}
Am I still missing something? I am accessing the html file by clicking it and executing run as > run on server (the webapp is deployed to my Tomcat server) or alternatively just typing the URL on localhost.
I have a Maven/GWT app with the following structure:
approot/pom.xml
approot/src/main/resources
approot/src/main/java/org/mydomain/MyApplication.gwt.xml
approot/src/main/java/org/mydomain/client/...
approot/src/main/java/org/mydomain/others/...
All the GWT Java code is in the client package, as deined in the gwt.xml file like this:
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.6.4//EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.6.4/distro-source/core/src/gwt-module.dtd">
<module rename-to='resources'>
<inherits name='com.google.gwt.user.User'/>
<inherits name="com.google.gwt.resources.Resources" />
<inherits name="com.google.gwt.uibinder.UiBinder"/>
<inherits name="some.other.Dependency" />
<source path="client" />
<entry-point class='org.mydomain.client.Main'/>
</module>
Here, the source element specifies that all Java in the client package (and any sub-packages) is to be processed by the GWT compiler and converted into JavaScript. All other packages are server-side and are not converted. If you have no server-side Java, then you'll only have the client package.
You'll need the GWT dependencies. Here's the minimum, there are others:
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.5.1</version>
<scope>provided</scope>
</dependency>
It is also important to include the GWT maven plugin, so the GWT compiler will run during a Maven build. Configure the plugin in your <plugins> section of your pom.xml. Here's an example:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
Related
I trying to merge two war files using maven cargo plugin. The problem is that. I have only one web.xml in one archive. Other archives not include web.xml. So the situation looks like below:
first.war --> with web.xml
second.war --> without web.xml
third.war --> without web.xml
So after merging my merged file uberwar.war file should contain exactly the same web.xml which is included in first.war.
Every tags in merged web.xml are the same instead of error-page. There is only taken first error-page from web.xml. Rest of the error-page tags are skipped. I dont know why. Have someone exeprience with this plugin and could help with issue?? I will be grateful for any help.
1. assemble.xml
<?xml version="1.0"?>
<uberwar>
<wars>
<war>org.vcm.modules:core-web</war>
<war>org.vcm.modules:attributes-web</war>
<war>org.vcm.modules:delivers-web</war>
<war>org.vcm.modules:movies-web</war>
<war>org.vcm.modules:zones-web</war>
<war>org.vcm.modules:opinions-web</war>
<war>org.vcm.modules:payments-web</war>
<war>org.vcm.modules:storages-web</war>
<war>org.vcm.modules:taxes-web</war>
<war>org.vcm.shops:shops-web</war>
</wars>
2. pom.xml
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.7.9</version>
<extensions>true</extensions>
<configuration>
<descriptor>src/assemble/merge.xml</descriptor>
</configuration>
</plugin>
I found cause. The problem was with my web.xml version. I used 3.1 when I change to 2.3 the merging process working correct. It seems the cargo plugin analyze the xml in different way when is newest version.
I have a web application deployed as exploded war using wildfly. What I want to get is
Changes in jsp files are automatically reflected, without redeploying the app
Changes in .class files enforce an app redeployment.
At the moment I am in a situation in which either I can get one option or the other, but not both at the same time (meaning that either every jsp change forces a new deployment or that .class files do not force a new deployment).
Current configuration of wildfly (using version 8.1.0) is
<deployment-scanner
path="deployments"
relative-to="jboss.server.base.dir"
scan-enabled="true"
scan-interval="1000"
auto-deploy-exploded="true"
runtime-failure-causes-rollback="${jboss.deployment.scanner.rollback.on.failure:false}"
/>
...
<servlet-container name="default">
<jsp-config development="true"/>
</servlet-container>
Also, something I have found is that no matter what I set in the deployment-scanner config, once the server is up and running, if I go to the wildfly web console, the parameter auto-deploy-war is marked as true and auto-deploy-exploded is marked as false, even the scan-interval is always set to 5000 ms, which makes me think that the deployment scanner config is somehow being ignored.
I am kind of lost here quite frankly, it has to be possible for wildfly to reload the app if the change is a .class file and not do it if it is a jsp.
Have you tried JRebel? following my blog entries would help also.
http://www.nailedtothex.org/roller/kyle/entry/evaluating-jrebel-for-wildfly-and
http://www.nailedtothex.org/roller/kyle/entry/exploded-deployment-for-wildfly-on
Manik Hot deploy is an open source Maven Plugin that simplifies your web development. The plugin provides both deployment modes - the auto-deployment and also the hot-deployment. It can be easily configured in a maven project by adding the plugin to the pom.xml
....
<build>
<plugins>
.....
<!-- Manik Hotdploy -->
<plugin>
<groupId>org.imixs.maven</groupId>
<artifactId>manik-hotdeploy-maven-plugin</artifactId>
<version>2.0.0</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- List Source and Target folders for Autodeploy and Hotdeploy -->
<autodeployments>
<deployment>
<!-- wildcard deployment -->
<source>target/*.{war,ear,jar}</source>
<target>/opt/wildfly/standalone/deployments/</target>
<unpack>true</unpack>
</deployment>
</autodeployments>
<hotdeployments>
<deployment>
<source>src/main/webapp</source>
<target>/opt/wildfly/standalone//deployments/my-app.war</target>
</deployment>
</hotdeployments>
</configuration>
</plugin>
.....
</plugins>
</build>
....
Upon attempting to run my Google Web Application I've been working on in Eclipse using GWT, it gives me this error:
"Loading modules
com.example.pbot.Pbot
Loading inherited module 'com.example.pbot.Pbot'
[ERROR] Unable to find 'com/example/pbot/Pbot.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
[ERROR] shell failed in doStartup method"
All of my packages are com.pbot, com.pbot.client, com.pbot.server, etc; I don't know where it's seeing com.example.
The entry-point class in the gwt.xml file is com.pbot.client.Pbot, which is my entry point class. Here's the full gwt.xml:
-->
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.1//EN"
"http://google-web-toolkit.googlecode.com/svn/tags/2.5.1/distro-source/core/src/gwt-module.dtd">
<module rename-to='pbot'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.clean.Clean'/>
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<!-- Specify the app entry point class. -->
<entry-point class='com.pbot.client.Pbot'/>
<!-- Specify the paths for translatable code -->
<source path='client'/>
<source path='shared'/>
</module>
I've cleaned, refreshed and restarted the project, I don't know what else to do. Where is it reading "com.example?" Please help!
Check the run configurations -> Arguments. There will be a reference of com.example.pbot.Pbot.
I think, this is what Thomas mentioned.
Check the project properties, in the GWT page, it probably references the com.example that you initially created.
Till now, our web application supports only English. Now we have to provide support for Italian as well. There is GWT module for some functionality. To support the Italian language I have added below line in the file "APP_Module.gwt.xml"
<extend-property name="locale" values="it"/>
I have also placed "XXX_it.properties" file under the source code where the properties file for en is kept.
Setting the locale in the jsp by following line:
<meta name="gwt:property" content="locale=${locale}">
Now, the issue is how to compile the code. I am debugging the application but it is not hitting the client code of GWT presented under WEB-INF/src.
I am very new to GWT. Please suggest how can I compile the code or there is no need of compilation. It will automatically take the changes done in "APP_Module.gwt.xml" and there is some other issue. How can I see logs of GWT?
To add support for locales to GWT application, you need to do the following in your xxx.gwt.xml:
under <module> add this to include the support:
<inherits name="com.google.gwt.i18n.I18N" />
and this to configure it:
<extend-property name="locale" values="en,it"/>
<set-property-fallback name="locale" value="en"/>
Add all your property files under some package like this:
src/main/resources/foo/bar/client/i18n/MyMessages.properties
src/main/resources/foo/bar/client/i18n/MyMessages_it.properties
Then you need to tell GWT to compile them into classes. This is example from a pom.xml file (if you don't use maven, you will have to use a different way, but you still need to configure it).
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.3.1.google</version>
<executions>
<execution>
<goals>
<goal>i18n</goal>
<goal>generateAsync</goal>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<i18nMessagesBundles>
<resourceBundle>foo.bar.client.i18n.MyMessages</resourceBundle>
</i18nMessagesBundles>
</configuration>
</plugin>
Then you need to recompile the code. In maven mvn compile. And that's all, you will have your messages in generated sources folder ready to use.
For seeing the logs of gwt you can use gradlew gwt also you can use it to compile the code too.
I have followed the guide for JQueryUI for GWT in Eclipse, but I get the error:
The type com.google.gwt.query.client.GQuery cannot be resolved. It is indirectly referenced from required .class files
I'm not quite sure if I'm doing everything correctly, though. I never imported JQueryUI (I have no clue how to import non-jar files correctly), but I think that the Google CDN network takes care of that, no? The tutorial I followed is here:
http://code.google.com/p/gwtquery-ui/wiki/GettingStarted
I tried converting my file to Maven by right clicking and choosing convert to maven. This created a POM.xml file. I added this to the pom file:
<repositories>
<repository>
<id>gwtquery-ui-repository</id>
<url>http://gwtquery-ui.googlecode.com/svn/mavenrepo</url>
</repository>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwtquery-ui</artifactId>
<version>r146</version>
<scope>provided</scope>
</dependency>
I have this for JQueryUI part in my.gwt.xml file:
<inherits name='gwtquery.plugins.UiGoogleCdn' />
<inherits name='gwtquery.plugins.UiEmbedded' />
Any tips at all would be appreciated!
I found my error. You are required to install and setup GWTQuery before you can use GWTQueryUI. I thought it was standalone, but it was not.