I have a Maven project built using the gwt-maven archetype. Although it works fine for the purpose of mvn gwt:run , however, when I try to run it in the tomcat7 container either mvn tomcat:run or mvn gwt:compile && mvn tomcat:run , it does not load dynamically created GWT widgets.
According to the Google Chrome console, it cannot find the *.nocache.js file, although it is exactly where it should be in the /target/ folder.
I'm currently trying to display a simple "Hello" label in the entry point module:
GWT Entry Point
public class Hello implements EntryPoint { public void onModuleLoad() { Label hello = new Label("TESTESTSTSTS"); RootPanel.get("helloContainer").add(hello); } }
*. HTML
<html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link type="text/css" rel="stylesheet" href="veltisto.css"> <title>Web Application Starter Project</title> <script type="text/javascript" language="javascript" src="veltisto/veltisto.nocache.js"></script> </head> <body> <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe> <noscript> <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif"> Your web browser must have JavaScript enabled in order for this application to display correctly. </div> </noscript> <div id="helloContainer"></div> </body> </html>
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>gr.veltisto</groupId> <artifactId>web</artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name>GWT Maven Archetype</name> <properties> <gwtVersion>2.4.0</gwtVersion> <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt-servlet</artifactId> <version>${gwtVersion}</version> <scope>runtime</scope> </dependency> <dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt-user</artifactId> <version>${gwtVersion}</version> <scope>provided</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.7</version> <scope>test</scope> </dependency> <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <version>1.0.0.GA</version> <scope>test</scope> </dependency> <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <version>1.0.0.GA</version> <classifier>sources</classifier> <scope>test</scope> </dependency> <dependency> <groupId>com.github.gwtbootstrap</groupId> <artifactId>gwt-bootstrap</artifactId> <version>2.0.4.0</version> </dependency> </dependencies> <build> <outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.1.1</version> <executions> <execution> <phase>compile</phase> <goals> <goal>exploded</goal> </goals> </execution> </executions> <configuration> <webappDirectory>${webappDirectory}</webappDirectory> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.0</version> <configuration> <path>/veltisto</path> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>gwt-maven-plugin</artifactId> <version>2.4.0</version> <executions> <execution> <goals> <goal>compile</goal> </goals> </execution> </executions> <configuration> <runTarget>veltisto.html</runTarget> <hostedWebapp>${webappDirectory}</hostedWebapp> </configuration> </plugin> </plugins> </build> </project>
*. GWT.XML
<module rename-to='veltisto'> <inherits name='com.google.gwt.user.User' /> <inherits name="com.google.gwt.uibinder.UiBinder" /> <inherits name='com.google.gwt.junit.JUnit' /> <inherits name='com.google.gwt.user.theme.standard.Standard' /> <inherits name="com.google.gwt.uibinder.UiBinder" /> <inherits name="com.github.gwtbootstrap.Bootstrap" /> <entry-point class='gr.veltisto.web.client.Hello' /> <source path='client' /> <source path='shared' /> </module>
source share