0

I am trying to configure my GWT 2.7.0 app built with maven to work with Tomcat7 server inside the Eclipse IDE.

My project, here is link compiles and run fine in Tomcat server from linux console using maven. Here is how I run:

In first linux shell:

mvn clean install
mvn tomcat7:run-war-only

And in second shell:

mvn gwt:run -pl web

Add Tomcat resources window: enter image description here

My project gwt_2.7.0_maven_eclipse is not there. I do not understand why.

Here is my main pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>pl.derp</groupId>
    <artifactId>parent</artifactId>
    <packaging>pom</packaging>
    <version>1.0.0-SNAPSHOT</version>
    <modules>
        <module>server</module>
        <module>shared</module>
        <module>web</module>
    </modules>

    <properties>
        <gwtVersion>2.7.0</gwtVersion>
        <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <tomcat.webport>8082</tomcat.webport>
        <tomcat.ajpport>8182</tomcat.ajpport>
        <tomcat.context>/parent</tomcat.context>
    </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>
    </dependencies>


    <build>

        <defaultGoal>clean install tomcat7:run-war-only</defaultGoal>

        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>${gwtVersion}</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
            </plugin>

            <!-- IDE -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.7</version>  <!-- Note 2.8 does not work with AspectJ aspect path -->
                <configuration>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>false</downloadJavadocs>
                    <wtpversion>2.0</wtpversion>
                    <additionalBuildcommands>
                        <buildCommand>
                            <name>org.eclipse.jdt.core.javabuilder</name>
                            <arguments>
                            </arguments>
                        </buildCommand>
                        <buildCommand>
                            <name>com.google.gdt.eclipse.core.webAppProjectValidator</name>
                            <arguments>
                            </arguments>
                        </buildCommand>
                        <buildCommand>
                            <name>com.google.gwt.eclipse.core.gwtProjectValidator</name>
                            <arguments>
                            </arguments>
                        </buildCommand>
                    </additionalBuildcommands>
                    <additionalProjectnatures>
                        <projectnature>com.google.gwt.eclipse.core.gwtNature</projectnature>
                    </additionalProjectnatures>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.0</version>
                <configuration>
                    <path>${tomcat.context}</path>
                    <port>${tomcat.webport}</port>
                    <ajpPort>${tomcat.ajpport}</ajpPort>
                    <systemProperties>
                        <JAVA_OPTS>-XX:MaxPermSize=256m</JAVA_OPTS>
                    </systemProperties>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Can any one of You help me with it? I struggle with it for few day, and cannot make it work.

I've already went over so many blogs and tutorial for this.


Edit

Here is my first project structure in Eclipse IDE

Here is my project structure in Eclipse IDE

After some reading I've executed in linux shell: mvn eclipse:eclipse, which had rebuild my single app project into multi project (by project I meen Eclipse project). In the result of that I've got this structure:

enter image description here

masterdany88
  • 5,041
  • 11
  • 58
  • 132

1 Answers1

1

Your Eclipse project is not a "web application project" (it lacks some "facet").


It's still strange that you have a single Eclipse project and not 3–4 ones, one per Maven module.

Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164
  • Yes, because it is Maven Project. How can I add "Web application project" nature to my Maven Project? Somehow in Eclipse IDE project configuration or in main (parent) pom.xml? – masterdany88 Aug 28 '15 at 10:00
  • I prefer to have one project than four in Eclipse. I've tried to do that using: `mvn eclipse:eclipse`. It worked out, but I've had many many errors in Eclipse IDE related to packages name, and not founded classes, etc. I've added into the post project structure in Eclipse Package Explorer – masterdany88 Aug 28 '15 at 10:01
  • I can understand why you prefer one Eclipse project, but then it means you basically have to configure it all by yourself, and cannot really take advantage of Maven here (or many things have to be configured in your POM to help configure Eclipse). It also means that all your server dependencies end up in the GWT classpath (this is already the case anyway with your multi-module setup where GWT code is in the `web` module), and that can cause issues (along with slowing down GWT compilation and DevMode/SDM with a bigger classpath to scan). – Thomas Broyer Aug 28 '15 at 10:07
  • Basically: configure your project in Eclipse "by hand", then possibly try to configure Maven so that importing the project (using M2Eclipse or `mvn eclipse:eclipse`) leads to the same result. Does not really seem worth the trouble to me though. YMMV. – Thomas Broyer Aug 28 '15 at 10:09
  • Ok. I do not prefer one Eclipse project than four. I just prefer the one which work. I am new to GWT and I just would like to start coding than setting up. Normally I would go with ant, but dependencies are killing me. It is way I choose maven instead. If You could explain to me with more details what exactly should I do to make GWT Maven project work with eclipse as it happens with GWT Ant project. then I could go Your way. – masterdany88 Aug 28 '15 at 10:19
  • Ok. I've followed Yours instruction. Now I have four projects in Eclipse IDE. See Post again. Thanks for Web application Project instruction- it helped for single project app. For multiply projects app in eclipse, It just worked out of box. – masterdany88 Aug 28 '15 at 12:03