0
votes

We had to migrate a gwt project and in the process we started using maven. We are having serious trouble to get it started again now. It's the first time working with maven, so bear with me

I do the following commands without errors:

mvn gwt:compile

mvn package

mvn gwt:run

Now jetty gives me the following url: http://127.0.0.1:8888/Aprov.html?gwt.codesvr=127.0.0.1:9997 

enter image description here

When I try to access that url in firefox, it loads the web elements correctly, but it seems it cant access the classes:

enter image description here

In jetty I get the error:

enter image description here

In eclipse I get the error

enter image description here

In my pom.xml I specfy this location:

enter image description here

And if I check, mvn package did it correctly, this is the class that its not finding: enter image description here

Although the files are in the correct location, they dont appear in eclipse, but I would say that doesnt matter:

enter image description here

The class folder doesnt show in eclipse, but it's there in windows explorer, generated by mvn package

This is the pom.xml file

  <modelVersion>4.0.0</modelVersion>
  <packaging>war</packaging>
  <version>0.1.0-SNAPSHOT</version>

  <groupId>bbva.cib</groupId>
  <artifactId>Aprov</artifactId>

  <properties>
    <appengine.maven.plugin.version>2.4.0</appengine.maven.plugin.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.showDeprecation>true</maven.compiler.showDeprecation>
    
    <!-- WebApp/War Output Directory -->
    <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
    <!-- for hot reload of the web application-->
    <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
    <sourceDirectory>src</sourceDirectory>    
    
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.google.cloud</groupId>
        <artifactId>libraries-bom</artifactId>
        <version>14.4.1</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
           <groupId>com.google.gwt</groupId>
           <artifactId>gwt</artifactId>
           <version>2.7.0</version>
           <type>pom</type>
           <scope>import</scope>
       </dependency>
    </dependencies>
   </dependencyManagement>

  <dependencies>
    <!-- Compile/runtime dependencies -->
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.1.0</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>javax.servlet.jsp</groupId>
      <artifactId>javax.servlet.jsp-api</artifactId>
      <version>2.3.1</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>jstl</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
    </dependency>

    <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-api-1.0-sdk</artifactId>
        <version>1.9.83</version>
    </dependency>
    <dependency>
        <groupId>com.google.endpoints</groupId>
        <artifactId>endpoints-framework</artifactId>
        <version>2.2.1</version>
    </dependency>
    
    <!-- Test Dependencies -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>2.4.5</version>
        <scope>provided</scope>         
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.4.5</version>
        <scope>provided</scope>         
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.12</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml-schemas</artifactId>
        <version>3.12</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-excelant</artifactId>
        <version>3.12</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-examples</artifactId>
        <version>3.12</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-scratchpad</artifactId>
        <version>3.12</version>
    </dependency>   
    <dependency>
        <groupId>commons-fileupload</groupId>
        <artifactId>commons-fileupload</artifactId>
        <version>1.3.1</version>
    </dependency>
    
    <!-- https://mvnrepository.com/artifact/com.google.gwt/gwt-servlet -->
    <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt-servlet</artifactId>
        <version>2.7.0</version>
        <scope>runtime</scope>
    </dependency>

     <dependency>
         <groupId>com.google.gwt</groupId>
         <artifactId>gwt-user</artifactId>
         <scope>provided</scope>
     </dependency>
     <dependency>
         <groupId>com.google.gwt</groupId>
         <artifactId>gwt-dev</artifactId>
         <scope>provided</scope>
     </dependency>
     
    
  </dependencies>


  <build>
    <!-- for hot reload of the web application-->
    <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
    <plugins>
      <plugin>
        <groupId>com.google.cloud.tools</groupId>
        <artifactId>appengine-maven-plugin</artifactId>
        <version>${appengine.maven.plugin.version}</version>
      </plugin>
      <plugin>
         <groupId>org.eclipse.jetty</groupId>
         <artifactId>jetty-maven-plugin</artifactId>
      </plugin>
      
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>3.0.0-M3</version>
        <executions>
          <execution>
            <id>enforce-maven</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <!-- appengine-maven-plugin requires Maven 3.5.0 or later -->
                <requireMavenVersion>
                  <version>3.5.0</version>
                </requireMavenVersion>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>2.7.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
                <!-- Plugin configuration. There are many available options, see gwt-maven-plugin 
                    documentation at codehaus.org -->
                <configuration>
                    <runTarget>Aprov.html</runTarget>
                    <hostedWebapp>${webappDirectory}</hostedWebapp>
                    <superDevMode>false</superDevMode> 
                    <sourceLevel>1.7</sourceLevel>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    
                </configuration>
            </plugin>
    </plugins>
  </build>
</project>

This is the web.xml part of the greet class:

 <servlet>
   <servlet-name>greetServlet</servlet-name>
   <servlet-class>bbva.cib.server.GreetingServiceImpl</servlet-class>
   <load-on-startup>1</load-on-startup>
 </servlet>
 <servlet-mapping>
   <servlet-name>greetServlet</servlet-name>
   <url-pattern>/aprov/greet</url-pattern>
 </servlet-mapping>

Any idea why it doesnt manage to load the classes, only the web files? Thanks in advance

1
Are you sure your <servlet> tag in web.xml has the correct <servlet-class> name? - Rob Newton
I added the web.xml part to the post, after the pom.xml. The thing is, this worked before trying to migrate using maven, that's why I thought the problem would be related to the pom.xml or some other configuration - Kal
Yes I see your point. The pom.xml looks OK as far as I can tell. - Rob Newton

1 Answers

0
votes

Eclipse and Maven are not the best friends. Depending on how you create the Maven project it might be a set up problem. I would use an artifact creator, build a Maven GWT artifact on the command line , run it from the command line and check if it is working. Once you got it working, I would import it into Eclipse.

Some things you should do:

  • use Thomas Broyers GWT Plugin
  • create a multi module Maven project (use one of the mentioned artifact creators)

To run a multi module project use: mvn gwt:codeserver -pl *-client -am to start the code server and mvn jetty:run -pl *-server -am -Denv=dev

Then call http://localhost:8080/index.html.

If you are running a GWT Maven project without separate modules for client, shared and server (don't do that), use gwt:devmode.

Your posted url show, that you try to run the old dev mode and not SDM.

There are several ways to create Maven based GWT projects.

You can use:

All these artifact generator will create a ready to go artifact. Just follow the docs to get it working. Once you got it running, add your code.

If you have questions, use the GWT Gitter room: https://gitter.im/gwtproject/gwt