deltascience
deltascience

Reputation: 3380

Exclude javax.servlet package from com.google.gwt dependency on pom.xml

I use Vaadin 7, and vaadin have a default package javax.servlet and I need com.google.gwt in my dependencies which contains another javax.servlet. When I run my application I got this error :

SEVERE: Allocate exception for servlet Vaadin Application Servlet
java.lang.ClassCastException: com.vaadin.server.VaadinServlet cannot be cast to javax.servlet.Servlet

Now I want to exclude javax.servlet from this dependency, and here is what I tried so far :

<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.6.1</version>
  <exclusions>
    <exclusion>  <!-- declare the exclusion here -->
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
    </exclusion>
  </exclusions>
</dependency>

and this :

<build>
<plugins>
<plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-shade-plugin</artifactId>
      <version>2.3</version>
      <executions>
        <execution>
          <phase>package</phase>
          <goals>
            <goal>shade</goal>
          </goals>
          <configuration>
            <filters>
              <filter>
                <minimizeJar>true</minimizeJar>
                <artifact>com.google.gwt:gwt-user</artifact>
                <includes>
                  <include>com/google/**</include>
                </includes>
                <excludes>
                  <exclude>javax/servlet/**</exclude>
                  <exclude>javax/servlet/http/**</exclude>
                  <exclude>javax/servlet/resources/**</exclude>
                </excludes>
              </filter>
            </filters>
          </configuration>
        </execution>
      </executions>
    </plugin>
 <plugin>

But both didn't work !. Help!

Upvotes: 1

Views: 2731

Answers (2)

Thomas Broyer
Thomas Broyer

Reputation: 64541

I think you actually want the gwt-servlet dependency rather than gwt-user.

That said, I don't know Vaadin; maybe there's a com.vaadin dependency that contains the GWT classes?

Upvotes: 2

Florescent Ticker
Florescent Ticker

Reputation: 645

According to your 2nd try, exclude the required package in a way given below:

Example :

                <configuration>
                        <packagingExcludes>
                           WEB-INF/lib/servlet-api*.jar,
                           WEB-INF/lib/jsp-api*.jar,
                           WEB-INF/lib/jstl-api*.jar,
                    </packagingExcludes>
                </configuration>

Upvotes: 1

Related Questions