2012-07-06 3 views
6

surefire v2.12를 사용해야하지만 해당 버전을 실행할 때마다 첨부 된 스택 추적을 얻습니다. v2.10을 실행하면 오류가 발생하지 않습니다. 이 버전이 필요하기 때문에 테스트 클래스에 @Category를 추가하고 UnitTests 또는 IntegrationTests로 레이블을 지정할 수 있습니다. 다음은 내 명령입니다 : MVN 테스트 -Dsurefire.version = 2.12 -XMaven의 테스트 단계가있는 surefire 플러그인의 예외

 
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project PROJECT: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test failed: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null: ExceptionInInitializerError: Unexpected ClassNotFoundException looking up class 'org.apache.maven.cli.MavenCli' -> [Help 1] 
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project ASPEN: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test failed: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225) 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) 
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) 
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) 
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) 
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) 
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) 
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) 
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) 
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) 
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) 
    Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test failed: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null 
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110) 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) 
    ... 19 more 
    Caused by: org.apache.maven.surefire.util.SurefireReflectionException: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null 
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:197) 
    at org.apache.maven.surefire.util.ReflectionUtils.invokeGetter(ReflectionUtils.java:69) 
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.getSuites(ProviderFactory.java:148) 
    at org.apache.maven.plugin.surefire.booterclient.ForkStarter.getSuitesIterator(ForkStarter.java:317) 
    at org.apache.maven.plugin.surefire.booterclient.ForkStarter.runSuitesForkPerTestSet(ForkStarter.java:149) 
    at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:118) 
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:199) 
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAllProviders(AbstractSurefireMojo.java:176) 
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:135) 
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:98) 
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) 
    ... 20 more 
    Caused by: java.lang.reflect.InvocationTargetException 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189) 
    ... 30 more 
    Caused by: java.lang.ExceptionInInitializerError 
    ... 2 more 
    at java.lang.Class.forName0(Native Method) 
    at java.lang.Class.forName(Class.java:169) 
    at org.junit.runner.Description.getTestClass(Description.java:207) 
    at org.apache.maven.surefire.common.junit48.FilterFactory$GroupMatcherCategoryFilter.shouldRun(FilterFactory.java:207) 
    at org.apache.maven.surefire.junitcore.JUnitCoreProvider.getSuitesAsList(JUnitCoreProvider.java:169) 
    at org.apache.maven.surefire.junitcore.JUnitCoreProvider.getSuites(JUnitCoreProvider.java:102) 
    ... 35 more 
    Caused by: java.lang.RuntimeException: Unexpected ClassNotFoundException looking up class 'org.apache.maven.cli.MavenCli' 
    ... 12 more 

    (deleted lines here) 

내 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"> 
<parent> 
    <artifactId>sample</artifactId> 
    <groupId>sample</groupId> 
    <version>1.0</version> 
</parent> 
<modelVersion>4.0.0</modelVersion> 
<artifactId>webapp</artifactId> 
<packaging>war</packaging> 
<dependencies> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-api</artifactId> 
     <version>${org.slf4j-version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-log4j12</artifactId> 
     <version>${org.slf4j-version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.mockito</groupId> 
     <artifactId>mockito-all</artifactId> 
     <version>1.9.0</version> 
    </dependency> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>4.10</version> 
    </dependency> 
</dependencies> 
<reporting> 
    <plugins> 
     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>findbugs-maven-plugin</artifactId> 
      <version>2.5.1</version> 
     </plugin> 
    </plugins> 
</reporting> 
<build> 
    <plugins> 
     <plugin> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <dependencies> 
       <dependency> 
        <groupId>org.apache.maven.surefire</groupId> 
        <artifactId>surefire-junit47</artifactId> 
        <version>${surefire.version}</version> 
        <scope>test</scope> 
       </dependency> 
      </dependencies> 
      <configuration> 
       <groups>com.webapp.api.annotation.type.${group.include}</groups> 
       <excludedGroups>com.webapp.api.annotation.type.${group.exclude}</excludedGroups> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 
</project> 

또한, 나는에서 설정 한 다른 프로젝트에서이 작업을 수행 할 수 있었다 한조각. 하지만이 경우에는 내가 볼 수 있듯이 확실한 플러그인 버전을 덮어 씁니다.

아이디어가 있으십니까?

감사

이 치어로 버전을 참을 수 없어 왜이 치어 당신에 의해 제어되며, 그 특성을 제공하기 위해 놓친 원인 이제까지 당신의 프로젝트를 사용하는 다른 사람이, 그것은 작동하지 않습니다 놀라게 될 것입니다 원인이
+0

사용중인 메이븐 버전은 무엇입니까? – gkamal

+0

통합 테스트가있는 경우 maven-surefire-plugin이 잘못된 방법입니다. 통합 테스트를 위해서는 maven-failsafe-plugin을 대신 사용하십시오. – khmarbaise

+0

@gkamal I use maven 3.0.4 – bclarance

답변

1

명령 줄에서. BTW : mvn -X -Dsurefire.version = 2.12 등을 통해 출력을 확인 했습니까? 동일한 오류 메시지가 나타날 것이라고 생각합니다.

내가 다시 확인하고 당신이 그런 식으로 버전을 정의하는 경우 프로젝트가 누군가가 명령 행 옵션 (-D ...)이 같은 일을 얻을 것이다 놓치면 더 이상 올바르지 않습니다 :

INFO] Scanning for projects... 
[ERROR] The build could not read 1 project -> [Help 1] 
[ERROR] 
[ERROR] The project com.soebes.katas:code:1.0-SNAPSHOT (/home/katas/pom.xml) has 1 error 
[ERROR]  'build.plugins.plugin.version' for org.apache.maven.plugins:maven-surefire-plugin must be a valid version but is '${surefire.version}'. @ line 36, column 20 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException 

즉, 명령 행에서 옵션을 통해 플러그인 버전 (또는 플러그인의 종속성)을 정의하는 것은 정말 안 좋은 생각입니다. 필요한 버전을 pom에 정의하고 surefire 및/또는 failsafe 플러그인을 통해 유닛 및 통합 테스트를 올바르게 사용하는 것이 좋습니다. 이것은 당신의 문제를 해결할 것입니다.

+0

나는 더 동의 할 수 없어, 그 부모 pom 결국 업데이트됩니다. 내 문제는 부모님이 많은 다른 부양 가족이 있기 때문에 변경/업그레이드를 영구적으로 적용하기 전에 그것이 작동하는지 확인해야합니다. 예, -X 옵션을 사용하여 실행했지만 어떻게 도움이되는지는 알지 못합니다. 찾으려는 것이 무엇인지 안다면 조언하십시오. – bclarance

+0

간단히 버전 번호를 넣고 그런 식으로 테스트하십시오. 또한 플러그인의 버전 및/또는 명령 행에서의 종속성을 사용하면 작동하지 않습니다.그 pom을 바꾸는 데 50 초가 걸렸을 것이고 당신이 준 버전으로 테스트했을 것입니다. 당신은 왜 당신이 상속 된 대신에 다른 maven-surefire-pugin 버전을 사용하기로 결정했는지 pom에서 언급 할 수 있습니다. – khmarbaise

+0

프로젝트 pom을 버전으로 변경했지만 여전히 예외가 발생했습니다. mvn clean test -e -X. 다음은 변경 사항이 적용되었는지 확인하기위한 출력입니다. [DEBUG] org.apache.maven.surefire : surefire-api : jar : 2.12 : 다른 아이디어를 컴파일하려면 (컴파일을 위해 선택)? – bclarance

관련 문제