Getting There was an error in the forked process error while running my tests

5,556 views
Skip to first unread message

Qaddaffi Sulaiman

unread,
Sep 25, 2019, 9:29:40 AM9/25/19
to testng-users

I am getting the following error when I try to run the testng suite.xml file through maven. The class name is masked intentionally. Can anyone help me with this please..?


Cannot instantiate class *****

[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process

[ERROR] 

[ERROR] Cannot instantiate class ****

[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:657)

[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:283)

[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:246)

[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1161)

[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1002)

[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:848)

[ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)

[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)

[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)

[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)

[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)

[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)

[ERROR] at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)

[ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)

[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)

[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)

[ERROR] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)

[ERROR] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:956)

[ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)

[ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:192)

[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

[ERROR] at java.lang.reflect.Method.invoke(Method.java:498)

[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)

[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)

[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)

[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)

[ERROR] 


Thanks,

Qaddaffi

Krishnan Mahadevan

unread,
Sep 26, 2019, 12:14:35 AM9/26/19
to testng...@googlegroups.com

Without providing any information, how do you expect anyone to resolve your query ?

 

You haven’t told us how your project structure looks like, where your test class resides, what your TestNG dependency looks like etc.,

 

Without any of this, all I can tell you is that, TestNG is NOT able to instantiate your class. You need to take a look at what is causing it. Perhaps you have a non default constructor in your test class ? Perhaps TestNG is not able to find it (because you have your test class defined in src/main/java and surefire plugin is looking for the test class in src/test/java)

 

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.com/

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/testng-users/09d8031c-7d77-4b85-94f1-ca0e4a31661e%40googlegroups.com.

Aliasger Kiranawala

unread,
Dec 17, 2021, 3:13:36 AM12/17/21
to testng-users
Hey Krishnan,

From what I understand is this is not a testNg problem but a maven plugin issue.
I have two suites executing in sequential mode, Both these suites have a parent dependency in pom.xml

That parent dependency contains some api calls so mostly when those apis are down these suites are unable to execute the methods exists

21:05:51 Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream. 21:05:51 There was an error in the forked process 21:05:51 21:05:51 Cannot instantiate class sh.abc.xx.xxxxxxx.SeedResourcesTest 21:05:51 org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process 21:05:51 21:05:51 Cannot instantiate class sh.abc.xx.xxxxxxx.SeedResourcesTest 21:05:51 at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:665) 21:05:51 at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:533) 21:05:51 at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:279) 21:05:51 at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:243) 21:05:51 at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1077) 21:05:51 at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:907) 21:05:51 at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:785) 21:05:51 at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137) 21:05:51 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210) 21:05:51 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156) 21:05:51 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148) 21:05:51 at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117) 21:05:51 at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81) 21:05:51 at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56) 21:05:51 at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) 21:05:51 at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305) 21:05:51 at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192) 21:05:51 at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105) 21:05:51 at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957) 21:05:51 at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289) 21:05:51 at org.apache.maven.cli.MavenCli.main(MavenCli.java:193) 21:05:51 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 21:05:51 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 21:05:51 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 21:05:51 at java.lang.reflect.Method.invoke(Method.java:498) 21:05:51 at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282) 21:05:51 at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225) 21:05:51 at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406) 21:05:51 at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)

Is there a way I can simplify this error exception so that viewer can make out what is wrong with the service called in parent pom project?

⇜Krishnan Mahadevan⇝

unread,
Dec 17, 2021, 5:03:35 AM12/17/21
to testng-users
Surefire is basically saying that the class instantiation itself failed. Usually happens when you have a constructor that threw an exception or when you have class level data member assignments failing.

One thing that you can do is to basically refactor the code such that it does the following:

1. Move out all sorts of dependencies from the object construction phase so that these dont happen.
2. If there are prerequisites that are to be fulfilled, then they should be moved into either a configuration method (or) you can define a base class that implements IHookable interface (from which all your test classes would now need to extend) and whose implementation can first take care of invoking the init() method and if it fails it can basically throw a proper exception.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribblings @ https://rationaleemotions.com/


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.

Aliasger Kiranawala

unread,
Dec 17, 2021, 5:14:39 AM12/17/21
to testng-users
Thanks Krishnan,

Will follow your suggested steps and get back.

Reply all
Reply to author
Forward
0 new messages