1

使用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 错误

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

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

严重:配置 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) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:133) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4727) at 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) at 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) 在 java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) 在 java.util.concurrent。ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) at java.lang.Thread.run(Thread.java:680) 2013 年 6 月 17 日下午 4:23:28 org.apache.catalina.core.StandardContext listenerStart 严重:已跳过由于先前的错误而安装应用程序侦听器

我的 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) @ test --- [INFO] com.test:test:war:1.0-SNAPSHOT [INFO] +- com.google.gwt:gwt-user:jar:2.5.1:compile [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:compile [INFO] | +- com.gwtplatform:gwtp-clients-common:jar:1.0:compile [INFO] | -org.apache.velocity:velocity:jar:1.7:compile [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: 编译 [信息] | - 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: 编译 [信息] | +- javax.inject:javax.inject:jar:1:compile [INFO] | - aopalliance:aopalliance:jar:1.0:compile [INFO] +- com.google.inject.extensions:guice-servlet:jar:3.0:compile [INFO] +- com.google.inject.extensions:guice-assistedinject:jar :3.0:compile [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。

2013 [INFO] 最终内存:6M/81M [INFO]

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

有什么建议么?

干杯

4

1 回答 1

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>
于 2013-06-26T05:47:51.607 回答