JaCoCo 注入错误通过 ssh 执行 maven 测试
JaCoCo Injection Error executing maven test via ssh
我正在尝试在远程 AIX 服务器上为我的开源项目设置持续集成测试。我可以在交互式 shell:
中很好地执行测试
$ ssh gate.polarhome.com -p 775 -l oshi
<password dialog>
<PATH set via .profile>
$ echo $PATH
> /usr/java8_64/bin:~/apache-maven-3.6.3/bin/:/opt/freeware/bin:/usr/local/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:.
$ cd ~/git/oshi
$ mvn test -B
当完全使用这些步骤在此交互式环境中执行时,测试会正确执行。但是,当尝试通过 SSH 命令行执行相同的命令时,JaCoCo 插件失败:
$ ssh gate.polarhome.com -p 775 -l oshi "export PATH=/usr/java8_64/bin:~/apache-maven-3.6.3/bin/:/opt/freeware/bin:/usr/local/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:.; cd ~/git/oshi; mvn test -B"
输入密码后,命令通过 mvn test
继续执行,但随后失败并出现异常:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Operating System and Hardware Information [pom]
[INFO] oshi-core [jar]
[INFO] oshi-core-shaded [jar]
[INFO] oshi-demo [jar]
[INFO] oshi-dist [pom]
[INFO]
[INFO] --------------------< com.github.oshi:oshi-parent >---------------------
[INFO] Building Operating System and Hardware Information 5.3.7-SNAPSHOT [1/5]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- git-commit-id-plugin:4.0.3:revision (git-commit-id) @ oshi-parent ---
[INFO]
[INFO] --- build-helper-maven-plugin:3.2.0:parse-version (default) @ oshi-parent ---
[INFO]
[INFO] --- maven-enforcer-plugin:3.0.0-M3:enforce (enforce-maven) @ oshi-parent ---
[INFO]
[INFO] --- jacoco-maven-plugin:0.8.6:prepare-agent (pre-unit-test) @ oshi-parent ---
[WARNING] Error injecting: org.jacoco.maven.AgentMojo
java.lang.NoClassDefFoundError: org.jacoco.core.runtime.AgentOptions
at java.lang.Class.getDeclaredMethodsImpl (Native Method)
at java.lang.Class.getDeclaredMethods (Class.java:1008)
at com.google.inject.spi.InjectionPoint.getDeclaredMethods (InjectionPoint.java:766)
at com.google.inject.spi.InjectionPoint.getInjectionPoints (InjectionPoint.java:683)
at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields (InjectionPoint.java:378)
at com.google.inject.internal.ConstructorBindingImpl.getInternalDependencies (ConstructorBindingImpl.java:182)
at com.google.inject.internal.InjectorImpl.getInternalDependencies (InjectorImpl.java:661)
at com.google.inject.internal.InjectorImpl.cleanup (InjectorImpl.java:617)
at com.google.inject.internal.InjectorImpl.initializeJitBinding (InjectorImpl.java:603)
at com.google.inject.internal.InjectorImpl.createJustInTimeBinding (InjectorImpl.java:932)
at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive (InjectorImpl.java:852)
at com.google.inject.internal.InjectorImpl.getJustInTimeBinding (InjectorImpl.java:291)
at com.google.inject.internal.InjectorImpl.getBindingOrThrow (InjectorImpl.java:222)
at com.google.inject.internal.InjectorImpl.getProviderOrThrow (InjectorImpl.java:1040)
at com.google.inject.internal.InjectorImpl.getProvider (InjectorImpl.java:1071)
at com.google.inject.internal.InjectorImpl.getProvider (InjectorImpl.java:1034)
at com.google.inject.internal.InjectorImpl.getInstance (InjectorImpl.java:1086)
at org.eclipse.sisu.space.AbstractDeferredClass.get (AbstractDeferredClass.java:48)
at com.google.inject.internal.ProviderInternalFactory.provision (ProviderInternalFactory.java:85)
at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision (InternalFactoryToInitializableAdapter.java:57)
at com.google.inject.internal.ProviderInternalFactory.call (ProviderInternalFactory.java:66)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision (ProvisionListenerStackCallback.java:112)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision (ProvisionListenerStackCallback.java:127)
at com.google.inject.internal.ProvisionListenerStackCallback.provision (ProvisionListenerStackCallback.java:66)
at com.google.inject.internal.ProviderInternalFactory.circularGet (ProviderInternalFactory.java:61)
at com.google.inject.internal.InternalFactoryToInitializableAdapter.get (InternalFactoryToInitializableAdapter.java:47)
at com.google.inject.internal.InjectorImpl.get (InjectorImpl.java:1050)
at org.eclipse.sisu.inject.Guice4.get (Guice4.java:162)
at org.eclipse.sisu.inject.LazyBeanEntry.getValue (LazyBeanEntry.java:81)
at org.eclipse.sisu.plexus.LazyPlexusBean.getValue (LazyPlexusBean.java:51)
at org.codehaus.plexus.DefaultPlexusContainer.lookup (DefaultPlexusContainer.java:263)
at org.codehaus.plexus.DefaultPlexusContainer.lookup (DefaultPlexusContainer.java:255)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo (DefaultMavenPluginManager.java:520)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:124)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:90)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke (Method.java:508)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
(完整日志可用 here)
在 maven 上使用 -X
开关,错误之前的日志行是:
[DEBUG] Configuring mojo org.jacoco:jacoco-maven-plugin:0.8.6:prepare-agent from plugin realm ClassRealm[plugin>org.jacoco:jacoco
我在 Whosebug 上搜索过类似问题。我找到的最接近的是 ,具有类似的症状,但与 Jenkins 版本控制问题有关。
我尝试了各种其他解决方案:
- 删除了
.m2/repository
并让它重建
- 在 Maven 命令中添加了
clean
- 尝试使用
jacoco.skip=true
跳过 JaCoCo
我很确定这个问题与 JaCoCo 涉及的“注入”有关,但无法弄清楚如何绕过、跳过或进一步调查这个问题。
我不知道下一步的故障排除步骤。交互式 ssh 环境与 ssh
命令行有何不同,会导致与 jacoco-maven-plugin 不同的行为?
事实证明,我的交互式 .profile
中有一个设置是解决此问题的关键:
ulimit -n 8192
似乎与其尝试复制路径和其他东西,不如使用 source .profile
会节省我大量的故障排除时间。
我正在尝试在远程 AIX 服务器上为我的开源项目设置持续集成测试。我可以在交互式 shell:
中很好地执行测试$ ssh gate.polarhome.com -p 775 -l oshi
<password dialog>
<PATH set via .profile>
$ echo $PATH
> /usr/java8_64/bin:~/apache-maven-3.6.3/bin/:/opt/freeware/bin:/usr/local/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:.
$ cd ~/git/oshi
$ mvn test -B
当完全使用这些步骤在此交互式环境中执行时,测试会正确执行。但是,当尝试通过 SSH 命令行执行相同的命令时,JaCoCo 插件失败:
$ ssh gate.polarhome.com -p 775 -l oshi "export PATH=/usr/java8_64/bin:~/apache-maven-3.6.3/bin/:/opt/freeware/bin:/usr/local/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:.; cd ~/git/oshi; mvn test -B"
输入密码后,命令通过 mvn test
继续执行,但随后失败并出现异常:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Operating System and Hardware Information [pom]
[INFO] oshi-core [jar]
[INFO] oshi-core-shaded [jar]
[INFO] oshi-demo [jar]
[INFO] oshi-dist [pom]
[INFO]
[INFO] --------------------< com.github.oshi:oshi-parent >---------------------
[INFO] Building Operating System and Hardware Information 5.3.7-SNAPSHOT [1/5]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- git-commit-id-plugin:4.0.3:revision (git-commit-id) @ oshi-parent ---
[INFO]
[INFO] --- build-helper-maven-plugin:3.2.0:parse-version (default) @ oshi-parent ---
[INFO]
[INFO] --- maven-enforcer-plugin:3.0.0-M3:enforce (enforce-maven) @ oshi-parent ---
[INFO]
[INFO] --- jacoco-maven-plugin:0.8.6:prepare-agent (pre-unit-test) @ oshi-parent ---
[WARNING] Error injecting: org.jacoco.maven.AgentMojo
java.lang.NoClassDefFoundError: org.jacoco.core.runtime.AgentOptions
at java.lang.Class.getDeclaredMethodsImpl (Native Method)
at java.lang.Class.getDeclaredMethods (Class.java:1008)
at com.google.inject.spi.InjectionPoint.getDeclaredMethods (InjectionPoint.java:766)
at com.google.inject.spi.InjectionPoint.getInjectionPoints (InjectionPoint.java:683)
at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields (InjectionPoint.java:378)
at com.google.inject.internal.ConstructorBindingImpl.getInternalDependencies (ConstructorBindingImpl.java:182)
at com.google.inject.internal.InjectorImpl.getInternalDependencies (InjectorImpl.java:661)
at com.google.inject.internal.InjectorImpl.cleanup (InjectorImpl.java:617)
at com.google.inject.internal.InjectorImpl.initializeJitBinding (InjectorImpl.java:603)
at com.google.inject.internal.InjectorImpl.createJustInTimeBinding (InjectorImpl.java:932)
at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive (InjectorImpl.java:852)
at com.google.inject.internal.InjectorImpl.getJustInTimeBinding (InjectorImpl.java:291)
at com.google.inject.internal.InjectorImpl.getBindingOrThrow (InjectorImpl.java:222)
at com.google.inject.internal.InjectorImpl.getProviderOrThrow (InjectorImpl.java:1040)
at com.google.inject.internal.InjectorImpl.getProvider (InjectorImpl.java:1071)
at com.google.inject.internal.InjectorImpl.getProvider (InjectorImpl.java:1034)
at com.google.inject.internal.InjectorImpl.getInstance (InjectorImpl.java:1086)
at org.eclipse.sisu.space.AbstractDeferredClass.get (AbstractDeferredClass.java:48)
at com.google.inject.internal.ProviderInternalFactory.provision (ProviderInternalFactory.java:85)
at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision (InternalFactoryToInitializableAdapter.java:57)
at com.google.inject.internal.ProviderInternalFactory.call (ProviderInternalFactory.java:66)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision (ProvisionListenerStackCallback.java:112)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision (ProvisionListenerStackCallback.java:127)
at com.google.inject.internal.ProvisionListenerStackCallback.provision (ProvisionListenerStackCallback.java:66)
at com.google.inject.internal.ProviderInternalFactory.circularGet (ProviderInternalFactory.java:61)
at com.google.inject.internal.InternalFactoryToInitializableAdapter.get (InternalFactoryToInitializableAdapter.java:47)
at com.google.inject.internal.InjectorImpl.get (InjectorImpl.java:1050)
at org.eclipse.sisu.inject.Guice4.get (Guice4.java:162)
at org.eclipse.sisu.inject.LazyBeanEntry.getValue (LazyBeanEntry.java:81)
at org.eclipse.sisu.plexus.LazyPlexusBean.getValue (LazyPlexusBean.java:51)
at org.codehaus.plexus.DefaultPlexusContainer.lookup (DefaultPlexusContainer.java:263)
at org.codehaus.plexus.DefaultPlexusContainer.lookup (DefaultPlexusContainer.java:255)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo (DefaultMavenPluginManager.java:520)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:124)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:90)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke (Method.java:508)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
(完整日志可用 here)
在 maven 上使用 -X
开关,错误之前的日志行是:
[DEBUG] Configuring mojo org.jacoco:jacoco-maven-plugin:0.8.6:prepare-agent from plugin realm ClassRealm[plugin>org.jacoco:jacoco
我在 Whosebug 上搜索过类似问题。我找到的最接近的是
我尝试了各种其他解决方案:
- 删除了
.m2/repository
并让它重建 - 在 Maven 命令中添加了
clean
- 尝试使用
jacoco.skip=true
跳过 JaCoCo
我很确定这个问题与 JaCoCo 涉及的“注入”有关,但无法弄清楚如何绕过、跳过或进一步调查这个问题。
我不知道下一步的故障排除步骤。交互式 ssh 环境与 ssh
命令行有何不同,会导致与 jacoco-maven-plugin 不同的行为?
事实证明,我的交互式 .profile
中有一个设置是解决此问题的关键:
ulimit -n 8192
似乎与其尝试复制路径和其他东西,不如使用 source .profile
会节省我大量的故障排除时间。