2014-06-10 56 views
1

我用Vaadin 7,和vaadin有一個默認的包javax.servlet,我需要在我的依賴其中包含另一個javax.servletcom.google.gwt。當我運行我的應用程序,我得到這個錯誤:從com.google.gwt依賴排除javax.servlet包上的pom.xml

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

現在我想從這種依賴排除的javax.servlet,這裏就是我試過到目前爲止:

<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> 

這:

<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> 

但兩者沒有工作!幫幫我!

回答

2

我想你真正想要的gwt-servlet依賴,而不是gwt-user

這麼說,我不知道Vaadin;也許有一個com.vaadin依賴包含GWT類?

+0

它的工作,非常感謝!你能否在你的文章中解釋'gwt-sevlet'和'gwt-user'之間的區別? – deltascience

1

根據你的第二個嘗試,排除所需的程序包在下面給出一個方法:

例子:

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