Maven: How to remove the jetty dependency?

Hi,

we have switch our projects to maven. At this time all will compiling fine and the ear file will be generated successfully. :slight_smile:

But if we start our application on wildfly we get some exceptions like:

Caused by: javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/eclipse/jetty/websocket/server/WebSocketServerFactory at org.atmosphere.cpr.AtmosphereFramework.init(AtmosphereFramework.java:912) at org.atmosphere.cpr.AtmosphereFramework.init(AtmosphereFramework.java:780) at com.vaadin.server.communication.PushRequestHandler.initAtmosphere(PushRequestHandler.java:219) This means that the Atmosphere Framework detected the wrong WebServer on which it is running (right? See also on https://github.com/Atmosphere/atmosphere/wiki/ClassNotFoundException-at-startup )

If I look into the war file I can also see several jetty.jar files. The question is: how to remove the jetty stuff.

Our pom of the war project is currently:

<?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">
  <parent>
    <artifactId>DFl_MvnParent</artifactId>
    <groupId>com.coco_on.docFlow</groupId>
    <version>2.3.0-SNAPSHOT</version>
  </parent>

  <modelVersion>4.0.0</modelVersion>
  <artifactId>DFl_Vaadin</artifactId>
  <packaging>war</packaging>

  <prerequisites>
    <maven>3</maven>
  </prerequisites>

  <scm>
    <connection>scm:svn:https://maven:svN.89mA+veN@192.168.1.2/repos/c-onDocFlow/trunk/c-onDocFlowVaadin/</connection>
    <developerConnection>scm:svn:https://maven:svN.89mA+veN@192.168.1.2/repos/c-onDocFlow/trunk/c-onDocFlowVaadin/</developerConnection>
    <tag>HEAD</tag>
    <url>https://maven:svN.89mA+veN@192.168.1.2/repos/c-onDocFlow/trunk/c-onDocFlowVaadin/</url>
  </scm>

  <properties>
    <vaadin.version>7.7.3</vaadin.version>
    <vaadin.plugin.version>7.7.3</vaadin.plugin.version>
    <!-- jetty.plugin.version>9.3.9.v20160517</jetty.plugin.version -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <!-- If there are no local customisations, this can also be "fetch" or "cdn" -->
    <vaadin.widgetset.mode>local</vaadin.widgetset.mode>
  </properties>

  <repositories>
    <repository>
      <id>vaadin-addons</id>
      <url>http://maven.vaadin.com/vaadin-addons</url>
    </repository>
  </repositories>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-bom</artifactId>
        <version>${vaadin.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.0.1</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.vaadin</groupId>
      <artifactId>vaadin-server</artifactId>
    </dependency>
    <dependency>
      <groupId>com.vaadin</groupId>
      <artifactId>vaadin-push</artifactId>
    </dependency>
    <dependency>
      <groupId>com.vaadin</groupId>
      <artifactId>vaadin-client-compiled</artifactId>
    </dependency>
    <dependency>
      <groupId>com.vaadin</groupId>
      <artifactId>vaadin-themes</artifactId>
    </dependency>
    <dependency>
        <groupId>com.vaadin.external.gwt</groupId>
        <artifactId>gwt-codeserver</artifactId>
        <version>2.7.0.vaadin4</version>
    </dependency>
    <dependency>
        <groupId>com.vaadin.external.gwt</groupId>
        <artifactId>gwt-dev</artifactId>
        <version>2.7.0.vaadin4</version>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>
    <!-- dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-testbench</artifactId>
        <version>4.1.0</version>
    </dependency -->
    <dependency>
        <groupId>com.coco_on.tools</groupId>
        <artifactId>CSVReporter</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.6</version>
        <configuration>
          <failOnMissingWebXml>false</failOnMissingWebXml>
          <!-- Exclude an unnecessary file generated by the GWT compiler. -->
          <packagingExcludes>WEB-INF/classes/VAADIN/widgetsets/WEB-INF/**</packagingExcludes>
           <archive>                   
            <manifest>
              <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
              <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
            </manifest>
            <manifestEntries>
              <SCM-Revision>${buildNumber}</SCM-Revision>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>buildnumber-maven-plugin</artifactId>
        <version>1.4</version>
        <executions>
          <execution>
            <phase>validate</phase>
            <goals>
              <goal>create</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <doCheck>true</doCheck>
          <doUpdate>true</doUpdate>
        </configuration>
      </plugin>
      <plugin>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-maven-plugin</artifactId>
        <version>${vaadin.plugin.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>update-theme</goal>
              <goal>update-widgetset</goal>
              <goal>compile</goal>
              <!-- Comment out compile-theme goal to use on-the-fly theme compilation -->
              <!-- goal>compile-theme</goal -->
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-clean-plugin</artifactId>
        <version>3.0.0</version>
        <!-- Clean up also any pre-compiled themes -->
        <configuration>
          <filesets>
            <fileset>
              <directory>src/main/webapp/VAADIN/themes</directory>
              <includes>
                <include>**/styles.css</include>
                <include>**/styles.scss.cache</include>
              </includes>
            </fileset>
          </filesets>
        </configuration>
      </plugin>

      <!-- The Jetty plugin allows us to easily test the development build by
        running jetty:run on the command line. -->
      <!-- plugin>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>${jetty.plugin.version}</version>
        <configuration>
          <scanIntervalSeconds>2</scanIntervalSeconds>
        </configuration>
      </plugin -->
    </plugins>
  </build>

  <profiles>
    <profile>
      <!-- Vaadin pre-release repositories -->
      <id>vaadin-prerelease</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>

      <repositories>
        <repository>
          <id>vaadin-prereleases</id>
          <url>http://maven.vaadin.com/vaadin-prereleases</url>
        </repository>
        <repository>
          <id>vaadin-snapshots</id>
          <url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>vaadin-prereleases</id>
          <url>http://maven.vaadin.com/vaadin-prereleases</url>
        </pluginRepository>
        <pluginRepository>
          <id>vaadin-snapshots</id>
          <url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
</project>

Thanks,
Steffen

Hi Steffen,
have you tried to launch
mvn dependency:tree
to check the transitive dependencies?

Maybe gwt-codeserver has jetty as dependency; try to remove it (or to change the scope as provided)

HTH
Marco

Thanks. I’m new to maven and so I did not known the “dependency:tree” goal.
dependency:tree
shows me no jetty dependencies. After a

mvn clean

the jetty stuff is gone.

Thanks a lot and a nice weekend! :slight_smile:

You’re welcome :slight_smile: