部署gwtp hello world

时间:2013-06-17 22:39:25

标签: maven gwt tomcat gwtp

使用https://github.com/ArcBees/ArcBees-tools/blob/master/archetypes/gwtp-basic/README.mdhttp://c.gwt-examples.com/home/maven/ide-import/eclipse上的路线,我已经使用maven创建了一个GWTP项目。它在调试模式下运行良好,但我在部署它时遇到了问题。

  1. 运行命令mvn gwt:compile
  2. 将.war文件复制到两个不同的Tomcat服务器
  3. 重新启动服务器
  4. 浏览到该文件的位置,我收到404错误
  5. 我在catalina.out中收到以下错误:

      

    信息:   validateJarFile(/Library/Tomcat/webapps/test/WEB-INF/lib/gwt-user-2.5.1.jar)    - jar没装。请参阅Servlet规范2.3,第9.7.2节。违规类:javax / servlet / Servlet.class

    根据建议我从/WEB-INF/删除了gwt-user-2.5.1.jar,我收到以下错误:

      

    SEVERE:配置类的应用程序侦听器时出错   com.test.server.guice.GuiceServletConfig   抛出java.lang.ClassNotFoundException:   com.test.server.guice.GuiceServletConfig at   org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)     在   org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)     在   org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:532)     在   org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:514)     在   org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:133)     在   org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4727)     在   org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)     在   org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)     在   org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)     在   org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)     在   org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)     在   org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1105)     在   org.apache.catalina.startup.HostConfig $ DeployDirectory.run(HostConfig.java:1664)     在   java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:439)     at java.util.concurrent.FutureTask $ Sync.innerRun(FutureTask.java:303)     在java.util.concurrent.FutureTask.run(FutureTask.java:138)at   java.util.concurrent.ThreadPoolExecutor中的$ Worker.runTask(ThreadPoolExecutor.java:895)     在   java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:918)     在java.lang.Thread.run(Thread.java:680)2013年6月17日下午4:23:28   org.apache.catalina.core.StandardContext listenerStart SEVERE:已跳过   由于先前的错误而安装应用程序侦听器

    我的pom.xml是:

    <?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">
    <modelVersion>4.0.0</modelVersion>
    
    <groupId>com.test</groupId>
    <artifactId>test</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>GWTP Basic</name>
    <description>Basic GWTP application</description>
    
    <properties>
        <!-- client -->
        <gwt.version>2.5.1</gwt.version>
        <gwtp.version>1.0</gwtp.version>
        <gin.version>2.0.0</gin.version>
    
        <!-- server -->
        <guice.version>3.0</guice.version>
    
        <!-- testing -->
        <junit.version>4.11</junit.version>
        <jukito.version>1.1</jukito.version>
    
        <!-- maven -->
        <gwt-maven-plugin.version>2.5.0</gwt-maven-plugin.version>
        <maven-surefire-plugin.version>2.6</maven-surefire-plugin.version>
        <maven-compiler-plugin.version>2.3.2</maven-compiler-plugin.version>
        <maven-resources-plugin.version>2.5</maven-resources-plugin.version>
        <maven-processor-plugin.version>2.0.5</maven-processor-plugin.version>
        <maven-build-helper-plugin.version>1.7</maven-build-helper-plugin.version>
    
        <target.jdk>1.6</target.jdk>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    
        <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
    </properties>
    
    <build>
        <outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
    
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <source>${target.jdk}</source>
                    <target>${target.jdk}</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
    
            <!-- JUnit Testing - skip *.GwtTest cases -->
            <!-- 'mvn test' - runs the Jukito tests -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire-plugin.version}</version>
                <configuration>
                    <includes>
                        <include>**/*Test.java</include>
                    </includes>
                    <excludes>
                        <exclude>**/*GwtTest.java</exclude>
                    </excludes>
                </configuration>
            </plugin>
    
            <!-- GWT -->
            <!-- 'mvn gwt:run' - runs development mode -->
            <!-- 'mvn gwt:debug' - runs debug mode -->
            <!-- 'mvn gwt:compile' - compiles gwt -->
            <!-- 'mvn integration-test' - runs the gwt tests (*GwtTest.java) -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>${gwt.version}</version>
                <configuration>
                    <!-- With multiple tests use GwtTestSuite.java for speed -->
                    <includes>**/*GwtTest.java</includes>
                    <extraJvmArgs>-Xss1024K -Xmx1024M -XX:MaxPermSize=256M</extraJvmArgs>
    
                    <copyWebapp>true</copyWebapp>
                    <hostedWebapp>${webappDirectory}</hostedWebapp>
    
                    <runTarget>Project.html</runTarget>
                    <modules>
                        <module>com.test.Project</module>
                    </modules>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    
    <dependencies>
        <!-- Google Web Toolkit -->
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <version>${gwt.version}</version>
        </dependency>
    
        <!-- GWT-Platform -->
        <dependency>
            <groupId>com.gwtplatform</groupId>
            <artifactId>gwtp-mvp-client</artifactId>
            <version>${gwtp.version}</version>
        </dependency>
        <dependency>
            <groupId>com.gwtplatform</groupId>
            <artifactId>gwtp-dispatch-client</artifactId>
            <version>${gwtp.version}</version>
        </dependency>
        <dependency>
            <groupId>com.gwtplatform</groupId>
            <artifactId>gwtp-dispatch-server-guice</artifactId>
            <version>${gwtp.version}</version>
        </dependency>
        <dependency>
            <groupId>com.gwtplatform</groupId>
            <artifactId>gwtp-dispatch-shared</artifactId>
            <version>${gwtp.version}</version>
        </dependency>
    
        <!-- DI -->
        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
            <version>${guice.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.inject.extensions</groupId>
            <artifactId>guice-servlet</artifactId>
            <version>${guice.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.inject.extensions</groupId>
            <artifactId>guice-assistedinject</artifactId>
            <version>${guice.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.gwt.inject</groupId>
            <artifactId>gin</artifactId>
            <version>${gin.version}</version>
        </dependency>
    
        <!-- Test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jukito</groupId>
            <artifactId>jukito</artifactId>
            <version>${jukito.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    

    当我运行mvn dependency:tree时,这是它的输出:

      

    [INFO]构建GWTP Basic 1.0-SNAPSHOT [INFO]   -------------------------------------------------- ---------------------- [INFO] [INFO] --- maven-dependency-plugin:2.1:tree(default-cli)@   测试--- [INFO] com.test:测试:war:1.0-SNAPSHOT [INFO] + -   com.google.gwt:gwt-user:jar:2.5.1:编译[INFO] | + -   javax.validation:validation-api:jar:1.0.0.GA:compile [INFO] | + -   javax.validation:validation-api:jar:sources:1.0.0.GA:compile [INFO] |    - org.json:json:jar:20090211:compile [INFO] + -   com.gwtplatform:gwtp-mvp-client:jar:1.0:编译[INFO] | + -   com.gwtplatform:gwtp-clients-common:jar:1.0:compile [INFO] | -   org.apache.velocity:velocity:jar:1.7:编译[INFO] | + -   commons-collections:commons-collections:jar:3.2.1:compile [INFO] |
       - commons-lang:commons-lang:jar:2.4:compile [INFO] + -   com.gwtplatform:gwtp-dispatch-client:jar:1.0:compile [INFO] + -   com.gwtplatform:gwtp-dispatch-server-guice:jar:1.0:compile [INFO] |    - com.gwtplatform:gwtp-dispatch-server:jar:1.0:compile [INFO] + -   com.gwtplatform:gwtp-dispatch-shared:jar:1.0:compile [INFO] + -   com.google.inject:guice:jar:3.0:编译[INFO] | + -   javax.inject:javax.inject:jar:1:编译[INFO] | -   aopalliance:aopalliance:jar:1.0:编译[INFO] + -   com.google.inject.extensions:guice-servlet:jar:3.0:compile [INFO] + -   com.google.inject.extensions:吉斯 - assistedinject:罐子:3.0:编译   [INFO] + - com.google.gwt.inject:gin:jar:2.0.0:compile [INFO] + -   junit:junit:jar:4.11:test [INFO] | -   org.hamcrest:hamcrest-core:jar:1.3:test [INFO] -   org.jukito:jukito:jar:1.1:test [INFO] -   org.mockito:mockito-core:jar:1.8.5:test [INFO] -   org.objenesis:objenesis:jar:1.0:test [INFO]   -------------------------------------------------- ---------------------- [INFO]建立成功[信息]   -------------------------------------------------- ---------------------- [INFO]总时间:1.746s [INFO]完成时间:Mon Jun 17 16:36:10 MDT

         

    2013 [INFO]最终记忆:6M / 81M [INFO]

    当我尝试在本地Tomcat服务器和arixe.com服务器上部署此错误时,我遇到了同样的错误。

    任何建议?

    干杯

1 个答案:

答案 0 :(得分:1)

请勿在战争中使用gwt-user,而是使用gwt-servlet。修改您的pom并删除:

<dependency>
    <groupId>com.google.gwt</groupId>
    <artifactId>gwt-user</artifactId>
    <version>${gwt.version}</version>
</dependency>

替换为:

<dependency>
    <groupId>com.google.gwt</groupId>
    <artifactId>gwt-servlet</artifactId>
    <version>${gwt.version}</version>
</dependency>