gpt4 book ai didi

maven - 部署 gwtp hello world

转载 作者:行者123 更新时间:2023-11-28 22:21:22 25 4
gpt4 key购买 nike

使用 https://github.com/ArcBees/ArcBees-tools/blob/master/archetypes/gwtp-basic/README.md 中的说明和 http://c.gwt-examples.com/home/maven/ide-import/eclipse我用 Maven 创建了一个 GWTP 项目。它在 Debug模式下运行良好,但我在部署它时遇到问题。

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

我在 catalina.out 中收到以下错误:

INFO: validateJarFile(/Library/Tomcat/webapps/test/WEB-INF/lib/gwt-user-2.5.1.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class

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

SEVERE: Error configuring application listener of class com.test.server.guice.GuiceServletConfig java.lang.ClassNotFoundException: com.test.server.guice.GuiceServletConfig at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559) at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:532) at 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) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1105) at 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) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) at java.lang.Thread.run(Thread.java:680) Jun 17, 2013 4:23:28 PM org.apache.catalina.core.StandardContext listenerStart SEVERE: Skipped installing application listeners due to previous error(s)

我的 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] Building 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: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:compile [INFO] | +- 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.8.5:test [INFO] - org.objenesis:objenesis:jar:1.0:test [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.746s [INFO] Finished at: Mon Jun 17 16:36:10 MDT

2013 [INFO] Final Memory: 6M/81M [INFO]

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

有什么建议吗?

干杯

最佳答案

不要在 war 中使用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>

关于maven - 部署 gwtp hello world,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17158023/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com