Adel Boutros
Adel Boutros

Reputation: 10285

gwt-servlet.jar missing in the WEB-INF/lib on compiling GWT with maven

In my pom file, I have included the dependency of gwt-servlet but if i run mvn clean install and mvn eclipse:eclipse and open the project in eclipse, I get the following error

GWT SDK JAR gwt-servlet.jar is missing in the WEB-INF/lib directory

EDIT : Here is my dependency (we use a custom maven repository):

<dependency>
    <groupId>com.google.gwt</groupId>
    <artifactId>gwt-user</artifactId>
    <version>2.4.0</version>
</dependency>
<dependency>
    <groupId>com.google.gwt</groupId>
    <artifactId>gwt-servlet</artifactId>
    <version>2.4.0</version>
</dependency>
<dependency>
    <groupId>com.smartgwt</groupId>
    <artifactId>smart-gwt</artifactId>
    <version>2.5</version>
</dependency>

EDIT 2 (main pom):

<build>
    <extensions>
      <extension>
        <groupId>org.apache.maven.wagon</groupId>
        <artifactId>wagon-ftp</artifactId>
      </extension>
    </extensions>
....

Upvotes: 1

Views: 9706

Answers (2)

Peter Szanto
Peter Szanto

Reputation: 7722

There are two things I noticed.

1) The smartgw dependency you specified cannot be resolved from the maven central repository

<dependency>
    <groupId>com.smartgwt</groupId>
    <artifactId>smart-gwt</artifactId>
    <version>2.5</version>
</dependency>

It only has the 2.4 version of smartgw (see here http://search.maven.org/#search%7Cga%7C1%7Csmartgwt) Instead I had to use this

<dependency>
    <groupId>com.smartgwt</groupId>
    <artifactId>smartgwt</artifactId>
    <version>2.4</version>
</dependency>

notice that the artifact ID is different too. (If you have a custom repository containing this then please update your question)

2) You dont need to do eclipse:eclipse instead you can issue the

File > Import > Existing Maven projects

this will auto generate the eclipse project from your pom.xml

UPDATE

I tested with the following :

Parent pom in gwttest2 folder

<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>com.test</groupId>
    <artifactId>gwttest2-main</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>

    <modules>
        <module>gwttest2-module1</module>
    </modules>

    <build>
        <extensions>
            <extension>
                <groupId>org.apache.maven.wagon</groupId>
                <artifactId>wagon-ftp</artifactId>
            </extension>
        </extensions>
    </build>


    <dependencies>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <version>2.4.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
            <version>2.4.0</version>
        </dependency>
        <dependency>
            <groupId>com.smartgwt</groupId>
            <artifactId>smartgwt</artifactId>
            <version>2.4</version>
        </dependency>

    </dependencies>

</project>

child pom in gwttest2/gwttest2-module1 folder

<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>com.test</groupId>
    <artifactId>gwttest2-module1</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <parent>
        <artifactId>gwttest2-main</artifactId>
        <groupId>com.test</groupId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>

    <build>
        <extensions>
            <extension>
                <groupId>org.apache.maven.wagon</groupId>
                <artifactId>wagon-ftp</artifactId>
            </extension>
        </extensions>
    </build>


    <dependencies>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <version>2.4.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
            <version>2.4.0</version>
        </dependency>
        <dependency>
            <groupId>com.smartgwt</groupId>
            <artifactId>smartgwt</artifactId>
            <version>2.4</version>
        </dependency>

    </dependencies>

</project>

Upvotes: 2

Renato
Renato

Reputation: 13690

Tell Eclipse to use Maven dependencies by right-clicking on your Project folder and selecting

Configure > Convert to Maven Project.

It seems that even after running mvn eclipse:eclipse, you must do this manually to get Eclipse to actually let Maven take care of your dependencies.

If you don't see this option you may not have the M2Eclipse plugin installed in your Eclipse...

Upvotes: 1

Related Questions