ClassNotFoundException:com.google.gwt.junit.server.JUnitHostImpl

时间:2013-05-09 19:00:46

标签: java google-app-engine gwt

如何摆脱此错误:

java.lang.ClassNotFoundException: com.google.gwt.junit.server.JUnitHostImpl
[ERROR]     at java.net.URLClassLoader$1.run(URLClassLoader.java:359)
[ERROR]     at java.net.URLClassLoader$1.run(URLClassLoader.java:348)
[ERROR]     at java.security.AccessController.doPrivileged(Native Method)
[ERROR]     at java.net.URLClassLoader.findClass(URLClassLoader.java:347)
[ERROR]     at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
[ERROR]     at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:213)

我试过了:

  • mvn clean
  • Eclipse项目清理

但仍然存在错误。

2 个答案:

答案 0 :(得分:1)

我删除了:

<inherits name='com.google.gwt.junit.JUnit'/>

来自我的* .gwt.xml和

<servlet>
    <servlet-name>jUnitHostImpl</servlet-name>
    <servlet-class>com.google.gwt.junit.server.JUnitHostImpl</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>jUnitHostImpl</servlet-name>
    <url-pattern>/MyProject/junithost/*</url-pattern>
</servlet-mapping>

来自我的web.xml,根据this answer的建议修复此问题。

答案 1 :(得分:-2)

我发现问题出在maven-war-plugin插件:

         <plugin>
            <!-- Copies static web files from src/main/webapp to target/${webappDirectory} -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1.1</version>
            <executions>
               <execution>
                  <!-- the exploded goal gets executed during compile phase -->
                  <phase>compile</phase>
                  <goals>
                     <goal>exploded</goal>
<!--                      <goal>war</goal> -->
                  </goals>
               </execution>
            </executions>
            <configuration>
            <failOnMissingWebXml>false</failOnMissingWebXml>
                <warName>${project.artifactId}</warName>
                <!-- Exclude GWT client local classes from the deployment, lest
                classpath scanners such as Hibernate and Weld get confused when the webapp 
                is bootstrapping. -->
                <packagingExcludes>**/javax/**/*.*,**/client/local/**/*.class</packagingExcludes>
                <warSourceExcludes>WEB-INF/web.xml</warSourceExcludes>             
                <!-- the exploded war structure ends up in target/${webappDirectory} -->
                <webappDirectory>${webappDirectory}</webappDirectory>
            </configuration>
         </plugin>

我从这里复制了这个配置:

https://github.com/errai/errai/blob/master/errai-jpa/demos/errai-jpa-demo-todo-list/pom.xml

作为在CapeDwarf环境中运行我的Errai应用程序的假设。