首页 > 解决方案 > 从命令提示符执行时找不到类和 SurefireBooterForkException

问题描述

使用 mvn clean install 命令从命令提示符运行时出现上述错误。

在类路径中找不到类:com.test.selenium.TestHello [ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException:分叉进程中出现错误

完整的堆栈跟踪:

enter code here


Skip to content
titletitle

search

6
Manage
Dismiss
You have data stored in an older format and/or unreadable data.
Disable CLI over Remoting
Dismiss
Allowing Jenkins CLI to work in -remoting mode is considered dangerous and usually unnecessary. You are advised to disable this mode. Please refer to the CLI documentation for details.
Setup Security
Dismiss
Jenkins is currently unsecured and allows anyone on the network to launch processes on your behalf. It is recommended to set up security and to limit anonymous access even on private networks.
Go to plugin manager
Configure which of these warnings are shown
Warnings have been published for the following currently installed components.
Matrix Authorization Strategy Plugin 1.1
Dangerous permissions can be configured independently of Administer permission
Subversion Plug-in 1.54
CSRF vulnerability and insufficient permission checks allow capturing credentials
Users without Overall/Read are able to access lists of user names and node names
SSH Slaves plugin 1.9
Man-in-the-middle vulnerability due to missing host key verification
Ant Plugin 1.2
Cross-site scripting (XSS) vulnerability
Translation Assistance plugin 1.10
Cross-site request forgery (CSRF) vulnerability
Dismiss
You have not configured the CSRF issuer. This could be a security issue. For more information, please refer to this page.
You can change the current configuration using the Security section CSRF Protection.
This Jenkins instance uses deprecated protocols: CLI-connect,CLI2-connect,JNLP-connect,JNLP2-connect. It may impact stability of the instance. If newer protocol versions are supported by all system components (agents, CLI and other clients), it is highly recommended to disable the deprecated protocols. See Protocol Configuration.
Manage Jenkins

Jenkins
TestMaven
#11
 Back to Project
 Status
 Changes
 Console Output
 View as plain text
 Edit Build Information
 Delete Build
 Git Build Data
 No Tags
 Redeploy Artifacts
 See Fingerprints
 Previous Build
SuccessConsole Output
Started by user unknown or anonymous
Building in workspace /Users/i339884/.jenkins/jobs/TestMaven/workspace
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://github.com/sreekumarthesun/selenium # timeout=10
Fetching upstream changes from https://github.com/sreekumarthesun/selenium
 > git --version # timeout=10
 > git fetch --tags --progress https://github.com/sreekumarthesun/selenium +refs/heads/*:refs/remotes/origin/*
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision d0cde4d90c2accf2574411d0d46d5dd1ba0d6e07 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f d0cde4d90c2accf2574411d0d46d5dd1ba0d6e07
Commit message: "first checkin"
 > git rev-list --no-walk d0cde4d90c2accf2574411d0d46d5dd1ba0d6e07 # timeout=10
Parsing POMs
Established TCP socket on 59031
[com.ariba.selenium] $ /ariba/s6053/ariba/3rdParty/jdk/Darwin/1.8.0/bin/java -cp /Users/i339884/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-agent-1.12-alpha-1.jar:/Users/i339884/Desktop/selenium/Selenium/softwares/apache-maven-3.5.2/boot/plexus-classworlds-2.5.2.jar:/Users/i339884/Desktop/selenium/Selenium/softwares/apache-maven-3.5.2/conf/logging jenkins.maven3.agent.Maven35Main /Users/i339884/Desktop/selenium/Selenium/softwares/apache-maven-3.5.2 /Users/i339884/.jenkins/war/WEB-INF/lib/remoting-3.20.jar /Users/i339884/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-interceptor-1.12-alpha-1.jar /Users/i339884/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.12-alpha-1.jar 59031
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven:  -B -f /Users/i339884/Documents/maven/com.ariba.selenium/pom.xml clean install
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.ariba.selenium:com.ariba.selenium:jar:1.0.0
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 40, column 12
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building com.ariba.selenium 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ com.ariba.selenium ---
[INFO] Deleting /Users/i339884/Documents/maven/com.ariba.selenium/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ com.ariba.selenium ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/i339884/Documents/maven/com.ariba.selenium/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ com.ariba.selenium ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ com.ariba.selenium ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/i339884/Documents/maven/com.ariba.selenium/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ com.ariba.selenium ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.21.0:test (default-test) @ com.ariba.selenium ---
[INFO] No tests to run.
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[ERROR] There are test failures.

Please refer to /Users/i339884/Documents/maven/com.ariba.selenium/target/surefire-reports for the individual test results.
Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
There was an error in the forked process

Cannot find class in classpath: com.test.selenium.TestHello
org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process

Cannot find class in classpath: com.test.selenium.TestHello
    at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:658)
    at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:533)
    at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:278)
    at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:244)
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1149)
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:978)
    at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:854)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
    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:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
    at org.jvnet.hudson.maven3.launcher.Maven35Launcher.main(Maven35Launcher.java:130)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at jenkins.maven3.agent.Maven35Main.launch(Maven35Main.java:176)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:139)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:70)
    at hudson.remoting.UserRequest.perform(UserRequest.java:212)
    at hudson.remoting.UserRequest.perform(UserRequest.java:54)
    at hudson.remoting.Request$2.run(Request.java:369)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

[JENKINS] Recording test results
[WARNING] Attempt to (de-)serialize anonymous class hudson.maven.reporters.BuildInfoRecorder$1; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ com.ariba.selenium ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: /Users/i339884/Documents/maven/com.ariba.selenium/target/com.ariba.selenium-1.0.0.jar
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ com.ariba.selenium ---
[INFO] Installing /Users/i339884/Documents/maven/com.ariba.selenium/target/com.ariba.selenium-1.0.0.jar to /Users/i339884/.m2/repository/com/ariba/selenium/com.ariba.selenium/1.0.0/com.ariba.selenium-1.0.0.jar
[INFO] Installing /Users/i339884/Documents/maven/com.ariba.selenium/pom.xml to /Users/i339884/.m2/repository/com/ariba/selenium/com.ariba.selenium/1.0.0/com.ariba.selenium-1.0.0.pom
[WARNING] Attempt to (de-)serialize anonymous class hudson.maven.reporters.MavenArtifactArchiver$2; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[WARNING] Attempt to (de-)serialize anonymous class hudson.maven.reporters.MavenFingerprinter$1; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.305 s
[INFO] Finished at: 2018-05-12T10:56:23+05:30
[INFO] Final Memory: 17M/265M
[INFO] ------------------------------------------------------------------------
[JENKINS] Archiving /Users/i339884/Documents/maven/com.ariba.selenium/pom.xml to com.ariba.selenium/com.ariba.selenium/1.0.0/com.ariba.selenium-1.0.0.pom
[JENKINS] Archiving /Users/i339884/Documents/maven/com.ariba.selenium/target/com.ariba.selenium-1.0.0.jar to com.ariba.selenium/com.ariba.selenium/1.0.0/com.ariba.selenium-1.0.0.jar
/Users/i339884/Documents/maven/com.ariba.selenium/pom.xml is not inside /Users/i339884/.jenkins/jobs/TestMaven/workspace/Users/i339884/Documents/maven/com.ariba.selenium/; will archive in a separate pass
/Users/i339884/Documents/maven/com.ariba.selenium/target/com.ariba.selenium-1.0.0.jar is not inside /Users/i339884/.jenkins/jobs/TestMaven/workspace/Users/i339884/Documents/maven/com.ariba.selenium/; will archive in a separate pass
channel stopped
[htmlpublisher] Archiving HTML reports...
[htmlpublisher] Archiving at PROJECT level /Users/i339884/.jenkins/jobs/TestMaven/workspace to /Users/i339884/.jenkins/jobs/TestMaven/htmlreports/Extent_20Html_20Report
TestNG Reports Processing: START
Looking for TestNG results report in workspace using pattern: **/testng-results.xml
testng-results.xml was last modified before this build started. Ignoring it.
Saving reports...
Found matching files but did not find any TestNG results.
Finished: SUCCESS
 Help us localize this page Page generated: 14-May-2018 11:30:34 ISTREST APIJenkins ver. 2.121

从命令版本运行 maven 项目时出现此错误。我怀疑从 Maven 运行时 java 类文件没有正确生成

标签: maventestng

解决方案


我在 Jenkins 上运行测试时遇到了类似的问题。在我的本地,所有测试都运行良好,但 Jenkins 给了我这个错误,因为所有插件和依赖项都必须在我公司的防火墙后面手动安装。

最初我只使用了Maven Surefire Plugin 3.0.0-M3这给了我错误。然后我不得不添加一个依赖“surefire-testng” 版本3.0.0-M3解决了它。


推荐阅读