2014-01-30 52 views
0

不加載我有一個包含該文件的簡單庫:庫在GAE服務器端

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 /噸/公共事業/共享/ 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> 

有什麼建議?

+0

您使用的是Maven嗎?螞蟻?蝕?問題可能出現在您的項目設置中。 –

+0

謝謝Gilberto,我使用Maven並剛添加了我的pom.xml文件。我使用Eclipse上傳到gae – user1256378

回答

0

確保您的DateUtils代碼已上傳到GAE。 你可能有War Server Project和一個Client Projet。 而你只是將War Server Projet部署到GWT編譯文件的服務器上?

最好的是有一個共同的項目誰被包括在這兩個項目。

+0

感謝Partice,我只是添加了我的pom.xml並使用Eclipse中的gwt插件上傳。當我看着我的目標/ WEB-INF/lib目錄時,庫就在那裏。它在gae的客戶端工作正常,而不是服務器端,在開發模式下,它在服務器端和客戶端都能正常工作。 – user1256378