使用GWT RPC的GAE上的ClassNotFoundException

Nic*_*ner 5 gwt google-app-engine gwt-rpc playn

我正在使用PlayN来开发游戏.它包含一个GameEventmy-game-core项目中定义的类型.我的GWT和GAE代码存在my-game-html,它具有my-game-coreMaven依赖性.

这是服务impl:

package com.mygame.html.server;

import com.mygame.core.event.GameEvent;
import com.mygame.html.client.ServerEventHandlerService;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

@SuppressWarnings("serial")
public class ServerEventHandlerServiceImpl extends RemoteServiceServlet
        implements ServerEventHandlerService {

    @Override
    public String handleEvent(final GameEvent event) {
        return "holy porkchops batman!";
    }

}
Run Code Online (Sandbox Code Playgroud)

编译得很好.但是,当我尝试在本地开发服务器上运行时调用该服务时,我收到以下错误:

SEVERE: javax.servlet.ServletContext log: Exception while dispatching incoming RPC call
java.lang.NoClassDefFoundError: com/mygame/core/event/GameEvent
...
Caused by: java.lang.ClassNotFoundException: com.mygame.core.event.GameEvent
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:176)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 39 more
Run Code Online (Sandbox Code Playgroud)

如果我拿出GameEvent并用类似的类型替换它String,一切正常.

我在这里做错了什么?GameEvent有一个默认的构造函数.

更新:这是*-html项目的pom.xml:

<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>
  <parent>
    <artifactId>mygame-game</artifactId>
    <groupId>com.mygame</groupId>
    <version>0.0.1-SNAPSHOT</version>
    <relativePath>..</relativePath>
  </parent>
  <artifactId>mygame-game-html</artifactId>
  <packaging>war</packaging>
  <name>my game html build</name>

  <properties>
    <gwt.module>com.mygame.MygameGame</gwt.module>
    <gwt.name>mygame</gwt.name>
  </properties>

  <dependencies>
    <dependency>
      <groupId>com.mygame</groupId>
      <artifactId>mygame-game-core</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>com.googlecode.playn</groupId>
        <artifactId>playn-html</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
  </dependencies>

  <build>
    <sourceDirectory>src</sourceDirectory>
    <outputDirectory>war/WEB-INF/classes</outputDirectory>

    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.1.1</version>
        <configuration>
          <warSourceDirectory>war</warSourceDirectory>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
        <!-- we need class metadata, override PlayN's disabling of such -->
        <configuration>
          <disableClassMetadata>false</disableClassMetadata>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-eclipse-plugin</artifactId>
        <version>2.8</version>
        <configuration>
          <downloadSources>true</downloadSources>
          <downloadJavadocs>false</downloadJavadocs>
          <wtpversion>2.0</wtpversion>
          <additionalBuildcommands>
            <buildCommand>
              <name>com.google.gwt.eclipse.core.gwtProjectValidator</name>
            </buildCommand>
          </additionalBuildcommands>
          <additionalProjectnatures>
            <projectnature>com.google.gwt.eclipse.core.gwtNature</projectnature>
          </additionalProjectnatures>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
Run Code Online (Sandbox Code Playgroud)

更新2:在war/WEB-INF/lib,我有:

  • 应用服务引擎的API-1.0-SDK-1.5.4.jar
  • 应用服务引擎的API-1.0-SDK-1.5.5.jar
  • AppEngine上-API实验室-1.5.4.jar
  • AppEngine上-API实验室-1.5.5.jar
  • AppEngine上-jsr107cache-1.5.4.jar
  • AppEngine上-jsr107cache-1.5.5.jar
  • DataNucleus将-AppEngine上,1.0.9.final.jar
  • DataNucleus将核心-1.1.5.jar
  • DataNucleus将-JPA-1.1.5.jar
  • Geronimo的jpa_3.0_spec-1.1.1.jar
  • Geronimo的jta_1.1_spec-1.1.1.jar
  • GWT-的servlet.jar
  • JDO2-API-2.3-eb.jar
  • jsr107cache-1.1.jar

Dan*_*rka 2

您在 gwt 启动的 jetty 的运行时类路径中缺少依赖项 my-game-core 。

您是否使用 mvn eclipse:eclipse 将您的项目导入到 eclipse 中?也许您的运行时类路径仍然指向您的本地 Maven 存储库,但您已经更改了 Eclipse 项目 (my-game-core)。查看您的 Eclipse 类路径,并确保其上只有其他项目,而不是存储库中的 jar。

另请检查运行配置中的类路径选项卡。