title: Google Guice + TestNG(v6.14.3) groups throws java.lang.RuntimeException: Unable to instantiate resource
body: <p>I have below hierarchy </p>
  
  <pre><code>@Guice(modules = ServiceModule.class)
  public abstract class BaseTest {
    @Inject
    protected FooBarService _fooBarService;
  
    //some generic stuff here
    //used TestNG @BeforeSuite etc tags here
  }
  </code></pre>
  
  <p>Then I inherit <code>BaseTest</code> in <code>NextBase</code> as below with some classes Injected</p>
  
  <pre><code>public class NextBase extends BaseTest { 
     @Inject
     protected BlaBlaService _blaBlaService;
  
    //again some generic stuff here
    //used TestNG @Before/After etc tags here
  }
  </code></pre>
  
  <p><strong>and finally I have my Test class which works without TestNG groups as below</strong></p>
  
  <pre><code>public class MyTests extends NextBase {
  
   @Test
   firstTest(){
    //test implementation 
   }
  
   @Test
   secondTest(){
    //test implementation 
   }
  }
  </code></pre>
  
  <p><strong>But If I introduce TestNG groups, I got the error to instantiate the object using <code>@Inject</code>.</strong> How can I get rid of it?</p>
  
  <pre><code>public class MyTests extends NextBase {
  
    @Test(groups = {"ReadOnly"})
    firstTest(){
     //test implementation   
    }
  
    @Test(groups = {"ReadOnly"})
    secondTest(){
     //test implementation   
    }
   }
  </code></pre>
  
  <p>I have a <code>final</code> BaseClass of all <code>@Inject</code> Services, I think that <code>final class</code> is causing this issues? how can I overcome this?</p>
  
  <pre><code>/**
   * Base class for services that need access to the resource SDKs.
   * This class isolates consumers from having to worry about the lazy-injected SDK resource classes.
   */
  public final class SdkService { }
  </code></pre>
  
  <p><strong>Get error as</strong> </p>
  
  <pre><code>java.lang.RuntimeException: Unable to instantiate resource
      at com.abc.test.service.SdkService.getResource(SdkService.java:392)
      at com.abc.test.service.SdkService.getOrgResource(SdkService.java:248)
          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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
      at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:59)
      at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:458)
      at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:222)
      at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:142)
      at org.testng.TestRunner.beforeRun(TestRunner.java:529)
      at org.testng.TestRunner.run(TestRunner.java:497)
      at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
      at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
      at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
      at org.testng.SuiteRunner.run(SuiteRunner.java:364)
      at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
      at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
      at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
      at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
      at org.testng.TestNG.runSuites(TestNG.java:1049)
      at org.testng.TestNG.run(TestNG.java:1017)
      at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:293)
      at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:84)
      at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:91)
      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.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:208)
      at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:156)
      at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:82)
      at org.apache.maven.plugin.surefire.InPluginVMSurefireStarter.runSuitesInProcess(InPluginVMSurefireStarter.java:82)
      at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:951)
      at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:831)
      at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:729)
      at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
      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: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:956)
      at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:290)
      at org.apache.maven.cli.MavenCli.main(MavenCli.java:194)
      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 org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
      at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
  Caused by: java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  </code></pre>