有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java ClassNotFoundException:com。谷歌。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) 个答案

  1. # 1 楼答案

    我发现问题出在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

    作为在CapeAdwarf环境中运行Errai应用程序的假定修复程序

  2. # 2 楼答案

    我删除了:

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

    从我的网站。xml来解决这个问题,正如this answer所建议的那样