图书馆没有在游戏服务器端加载

时间:2014-01-30 18:57:19

标签: java google-app-engine gwt

我有一个包含此文件的简单库:

import java.util.Date;

public class DateUtils {
       public static Date addDays(Date date, int days) {
            assert date != null : "Date cannont be null";
              return new Date(date.getYear(), date.getMonth(), date.getDate() + days);
        }

}

这是用gwt运行的。我在服务器和客户端中调用此函数。它在开发模式下完美运行。当我将它上传到gae时,它只适用于客户端。

错误日志说org.jboss.resteasy.spi.UnhandledException:java.lang.NoClassDefFoundError:com / mt / utilities / shared / DateUtils

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.mt.ba</groupId>
  <artifactId>basicapp</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>
  <name>GWTP Basic with GXT</name>
  <description>Basic GWTP application with the GXT library</description>

  <properties>
    <!-- client -->
    <!-- Get the latest GXT release through support 3.0.6... -->
    <gxt.version>3.0.1</gxt.version>
    <gwt.version>2.5.1</gwt.version>
    <gwtp.version>1.1.1</gwtp.version>
    <gin.version>2.0.0</gin.version>

    <!-- server -->
    <guice.version>3.0</guice.version>

    <!-- REST -->
    <resteasy.version>3.0.2.Final</resteasy.version>
    <arcbees.version>1.1.1</arcbees.version>

    <!-- testing -->
    <junit.version>4.11</junit.version>
    <!--
    <jukito.version>1.3</jukito.version>
 -->
    <!-- maven -->
    <gwt-maven-plugin.version>2.5.1</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.7</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>

    <!-- GAE -->
    <gae.version>1.8.8</gae.version>
    <gae.home>${settings.localRepository}/com/google/appengine/appengine-java-sdk/${gae.version}/appengine-java-sdk-${gae.version}</gae.home>

    <!-- mt Libraries -->
    <mt.rest>0.3.1</mt.rest>
    <mt.utilities>0.1.3</mt.utilities>

  </properties>

  <build>
    <outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>

    <plugins>
            <plugin>
                <groupId>com.google.appengine</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>${gae.version}</version>
            </plugin>

      <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 Junit tests -->
      <!-- 'mvn integration-test` - runs GWT test cases -->
      <!-- 'mvn integration-test -P selenium-local` - runs GWT selenium unit test cases -->
      <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>
          <gwtSdkFirstInClasspath>true</gwtSdkFirstInClasspath>
          <strict>true</strict>

          <testTimeOut>180</testTimeOut>
          <includes>**/*GwtTestSuite.java</includes>
          <excludes>**/*GwtTest.java</excludes>
          <mode>htmlunit</mode>

          <extraJvmArgs>-Xss1024K -Xmx1024M -XX:MaxPermSize=256M</extraJvmArgs>
          <logLevel>INFO</logLevel>
          <style>${gwt.style}</style>

          <copyWebapp>true</copyWebapp>
          <hostedWebapp>${webappDirectory}</hostedWebapp>

          <runTarget>ba.html</runTarget>
          <modules>
            <module>com.mt.ba.ba</module>
          </modules>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>test</goal>
              <goal>compile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <repositories>
    <repository>
        <id>RestLibrary</id>
        <url>https://dl.dropboxusercontent.com/u/45032161/mvn-repository/com/mt/rest/restlibrary/${mt.rest}/restlibrary-${mt.rest}.jar</url>
    </repository>
    <repository>
        <id>UtilitiesLibrary</id>
        <url>https://dl.dropboxusercontent.com/u/45032161/mvn-repository/com/mt/utilities/utilitieslibrary/${mt.utilities}/utilitieslibrary-${mt.utilities}.jar</url>
    </repository>
    </repositories>


  <!-- Get the latest release through support, 3.0.6... -->
  <!-- <repositories> -->
    <!-- <repository> -->
      <!-- ~/.m2/settings.xml add <server/> with same id here with login credentials -->
      <!-- <id>sencha-gxt-repository</id> -->
      <!-- <name>Sencha GXT Repository</name> -->
      <!-- Support Subscribers Only: Subscribe to support for -->
      <!-- Latest GPL Support GXT Versions -->
      <!-- <url>https://maven.sencha.com/repo/gxt-support-gpl-release</url> -->
      <!-- Commercial Support GXT Versions -->
      <!-- <url>https://maven.sencha.com/repo/gxt-commercial-release</url> -->
    <!-- </repository> -->
  <!-- </repositories> -->

  <dependencies>

    <!-- mt Libraries -->
    <dependency>
        <groupId>com.mt.rest</groupId>
        <artifactId>restlibrary</artifactId>
        <version>${mt.rest}</version>
    </dependency>
    <dependency>
        <groupId>com.mt.utilities</groupId>
        <artifactId>utilitieslibrary</artifactId>
        <version>${mt.utilities}</version>
    </dependency>

    <!-- GXT -->
    <!-- http://docs.sencha.com/gxt-guides/3/ -->
    <dependency>
      <groupId>com.sencha.gxt</groupId>
      <artifactId>gxt</artifactId>
      <version>${gxt.version}</version>
    </dependency>
    <dependency>
      <groupId>com.sencha.gxt</groupId>
      <artifactId>gxt-chart</artifactId>
      <version>${gxt.version}</version>
    </dependency>

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

        <!-- AppEngine -->
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-1.0-sdk</artifactId>
            <version>${gae.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
            <version>${gwt.version}</version>
        </dependency>

        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-dev</artifactId>
            <version>${gwt.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>

    <!-- Rest -->
    <dependency>
        <groupId>com.gwtplatform</groupId>
        <artifactId>gwtp-dispatch-rest</artifactId>
        <version>${gwtp.version}</version>
        <scope>provided</scope>
     </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>
 -->
     <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-remote-driver</artifactId>
      <version>2.33.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-java</artifactId>
      <version>2.33.0</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <profiles>
    <!-- run with 'mvn integration-test -P selenium-local' -->
    <profile>
      <id>selenium-local</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>gwt-maven-plugin</artifactId>
            <configuration>
              <mode>selenium</mode>
              <productionMode>true</productionMode>
              <selenium>localhost:4444/*firefox,localhost:4444/*opera</selenium>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

确保将DateUtils代码上传到GAE。 您可能拥有War Server Project和Client Projet。 您只需使用GWT编译的文件将War Server Projet部署到服务器上吗?

最好是拥有一个包含在两个项目中的共享项目。