2017-12-06 7 views
-1

eclipse와 maven을 사용하여 JavaEE에서 PluralSight 과정을 따라 왔습니다. 저는 현재 몇 가지 테스트를 작성하기 위해 노력하고있어,하지만 cmd를 라인에서 mvn package을 실행할 때이 오류지고있어 : 때때로NoClassDefFoundError - RunListener : Maven-surefire/JUnit

Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed: There was an error in the forked process

은을 참조 :

java.lang.NoClassDefFoundError: org/junit/runner/notification/RunListener

과 때때로 :

java.lang.NoClassDefFoundError: org/junit/runner/Description

내가했던 JUnit 4.0에서는 RunReader와 RunListener가 소개되었습니다. 하지만 JUnit 4.12는 종속성 계층에 있습니다. 그리고 이제는 문제 해결을 위해 모든 파일을 운동 파일로 변경했습니다.

REBars와 클래스 패스가 어떻게 동작 하는지를 근본적으로 잘못 이해했으며, 이클립스 나 cmd 라인을 JUnit 항아리로 향하게해야한다고 생각합니다. (두 가지 모두에서 같은 오류가 발생합니다). 나는 다른 JUnit 클래스가 자바 객체에서 인식된다는 사실을 알면 이상하다. 은 여기 어쨌든 내 (인 Pluralsight의) 치어 : 클래스 패스 아이디어와 올바른 궤도에

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" 
      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.pluralsight.javaee-getting-started.javaee-getting-started-m6</groupId> 
     <artifactId>bookstore-back</artifactId> 
     <version>1.0</version> 
     <packaging>war</packaging> 
     <name>Getting Started :: javaee-getting-started-m6 :: Testing the Repository :: Back</name> 

     <properties> 
      <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> 
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
      <!-- Test --> 
      <version.junit>4.12</version.junit> 
      <version.arquillian>1.1.13.5</version.arquillian> 
      <version.arquillian.wildfly>2.0.2.Final</version.arquillian.wildfly> 
      <version.shrinkwrap>1.2.6</version.shrinkwrap> 
      <!-- Plugins --> 
      <version.surefire.plugin>2.19.1</version.surefire.plugin> 
     </properties> 

     <dependencyManagement> 
      <dependencies> 
       <dependency> 
        <groupId>org.arquillian</groupId> 
        <artifactId>arquillian-universe</artifactId> 
        <version>${version.arquillian}</version> 
        <type>pom</type> 
        <scope>import</scope> 
       </dependency> 
      </dependencies> 
     </dependencyManagement> 

     <dependencies> 
      <dependency> 
       <groupId>javax</groupId> 
       <artifactId>javaee-web-api</artifactId> 
       <version>7.0</version> 
       <scope>provided</scope> 
      </dependency> 

      <!-- TEST --> 
      <dependency> 
       <groupId>junit</groupId> 
       <artifactId>junit</artifactId> 
       <version>${version.junit}</version> 
       <scope>test</scope> 
      </dependency> 
      <dependency> 
       <groupId>org.arquillian.universe</groupId> 
       <artifactId>arquillian-junit</artifactId> 
       <scope>test</scope> 
       <type>pom</type> 
      </dependency> 
      <dependency> 
       <groupId>org.jboss.shrinkwrap</groupId> 
       <artifactId>shrinkwrap-api</artifactId> 
       <version>${version.shrinkwrap}</version> 
       <scope>test</scope> 
      </dependency> 
      <dependency> 
       <groupId>org.wildfly.arquillian</groupId> 
       <artifactId>wildfly-arquillian-container-remote</artifactId> 
       <version>${version.arquillian.wildfly}</version> 
       <scope>test</scope> 
      </dependency> 
     </dependencies> 

     <build> 
      <finalName>bookstore-back</finalName> 

      <plugins> 
       <plugin> 
        <artifactId>maven-surefire-plugin</artifactId> 
        <version>${version.surefire.plugin}</version> 
        <configuration> 
         <systemPropertyVariables> 
          <arquillian.launch>arquillian-wildfly-remote</arquillian.launch> 
         </systemPropertyVariables> 
        </configuration> 
       </plugin> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-compiler-plugin</artifactId> 
        <version>3.1</version> 
        <configuration> 
         <source>1.8</source> 
         <target>1.8</target> 
         <compilerArguments> 
          <endorseddirs>${endorsed.dir}</endorseddirs> 
         </compilerArguments> 
        </configuration> 
       </plugin> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-war-plugin</artifactId> 
        <version>2.3</version> 
        <configuration> 
         <failOnMissingWebXml>false</failOnMissingWebXml> 
        </configuration> 
       </plugin> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-dependency-plugin</artifactId> 
        <version>2.6</version> 
        <executions> 
         <execution> 
          <phase>validate</phase> 
          <goals> 
           <goal>copy</goal> 
          </goals> 
          <configuration> 
           <outputDirectory>${endorsed.dir}</outputDirectory> 
           <silent>true</silent> 
           <artifactItems> 
            <artifactItem> 
             <groupId>javax</groupId> 
             <artifactId>javaee-endorsed-api</artifactId> 
             <version>7.0</version> 
             <type>jar</type> 
            </artifactItem> 
           </artifactItems> 
          </configuration> 
         </execution> 
        </executions> 
       </plugin> 
       <plugin> 
        <artifactId>maven-assembly-plugin</artifactId> 
        <version>3.0.0</version> 
        <configuration> 
         <descriptorRefs> 
          <descriptorRef>src</descriptorRef> 
         </descriptorRefs> 
        </configuration> 
       </plugin> 
      </plugins> 
     </build> 

    </project> 

암 I?

+0

먼저 Maven이 의존성을 저장하고 다른 빌드를 저장하는'.m2' 폴더를 삭제하십시오. 때때로 jar 파일이 손상 될 수 있습니다 (예 : Junit jar 파일이 손상되어 클래스를 찾지 못하는 이유를 설명 할 수 있음). 또한'mvn dependency-tree'를 실행하여 올바른 버전을 가지고 있는지 확인하십시오. 또한 모든 테스트는'src/test/java'에 있습니까? – helospark

+0

내 .m2 파일을 삭제하고 리 패키징 -이 문제를 해결했다고 생각합니다. 하지만 고마워! 이제 런타임 예외'http-remoting : //127.0.0.1 : 9990'에 연결할 수 없습니다. 어떤 성가신 동안, 적어도 jboss-cli.bat --connect --controller = localhost : 9990'을 실행하는 동안 나는 오류입니다. 나는 이전에이 명령으로 WildFly를 시작하는 데 문제가 있었지만 (standalone.bat는 잘 작동합니다.) – NickW

+0

'mvn dependency : tree'를 실행하면 다음과 같은 결과가 발생합니다 :'목표 default.close.main.plugins의 실행 기본값 -cli : maven-dependency- 플러그인 : 2.6 : 트리 실패 : org.apache.maven.plugins를 실행하는 동안 필수 클래스가 누락되었습니다 : maven-dependency-plugin : 2.6 : tree : org/sonatype/aether/graph/DependencyNode' – NickW

답변

0

Maven이 의존성을 저장하고 다른 빌드를 저장하는 .m2 폴더를 삭제하십시오. 때때로 jar 파일이 손상 될 수 있습니다 (예 : Junit jar 파일이 손상되어 클래스를 찾지 못하는 이유를 설명 할 수 있음).

+0

추측하는 동안 하드 드라이브의 포맷을 권장하지 말고 OS 및 기타 모든 것을 다시 설치하거나 완전한 * 답변 *이 필요하지 않은 이유는 무엇입니까? –

+0

더 많은 질문에 답하기 전에 [어떻게 좋은 답변을 작성합니까?] (http://stackoverflow.com/help/how-to-answer)를 읽어보십시오. –

+0

@JarrodRoberson 내 대답은 내가이 질문의 코멘트 섹션에서 OP와 함께했던 대화를 기반으로합니다. 그것은 OP의 문제를 해결했습니다. 질문에 대답을하지 않는 것이 낫습니까? – helospark