testng-team / testng-eclipse

Eclipse plug-in for TestNG
https://testng.org
194 stars 164 forks source link

An error occurred while instantiating class Tryagain1.sumValidation: Unable to make public Tryagain1.sumValidation() accessible: module Tryagain does not "exports Tryagain1" to module org.testng #549

Closed v91negi closed 1 year ago

v91negi commented 1 year ago

Problem Statement

please read https://github.com/cbeust/testng-eclipse/blob/master/docs/Troubleshooting.md first An error occurred while instantiating class Tryagain1.sumValidation: Unable to make public Tryagain1.sumValidation() accessible: module Tryagain does not "exports Tryagain1" to module org.testng

Any relate message in "Error Log" view

"Windows -> Show View -> Others -> Error Log"

An error occurred while instantiating class Tryagain1.sumValidation: Unable to make public Tryagain1.sumValidation() accessible: module Tryagain does not "exports Tryagain1" to module org.testng
    at org.testng@7.7.1/org.testng.internal.objects.SimpleObjectDispenser.createInstance(SimpleObjectDispenser.java:99)
    at org.testng@7.7.1/org.testng.internal.objects.SimpleObjectDispenser.dispense(SimpleObjectDispenser.java:40)
    at org.testng@7.7.1/org.testng.internal.objects.GuiceBasedObjectDispenser.dispense(GuiceBasedObjectDispenser.java:28)
    at org.testng@7.7.1/org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:106)
    at org.testng@7.7.1/org.testng.internal.ClassImpl.getInstances(ClassImpl.java:136)
    at org.testng@7.7.1/org.testng.TestClass.getInstances(TestClass.java:129)
    at org.testng@7.7.1/org.testng.TestClass.initTestClassesAndInstances(TestClass.java:109)
    at org.testng@7.7.1/org.testng.TestClass.init(TestClass.java:101)
    at org.testng@7.7.1/org.testng.TestClass.<init>(TestClass.java:66)
    at org.testng@7.7.1/org.testng.TestRunner.initMethods(TestRunner.java:464)
    at org.testng@7.7.1/org.testng.TestRunner.init(TestRunner.java:336)
    at org.testng@7.7.1/org.testng.TestRunner.init(TestRunner.java:289)
    at org.testng@7.7.1/org.testng.TestRunner.<init>(TestRunner.java:219)
    at org.testng.remote.support.RemoteTestNG6_12$1.newTestRunner(RemoteTestNG6_12.java:33)
    at org.testng.remote.support.RemoteTestNG6_12$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG6_12.java:66)
    at org.testng@7.7.1/org.testng.ITestRunnerFactory.newTestRunner(ITestRunnerFactory.java:52)
    at org.testng@7.7.1/org.testng.SuiteRunner$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:710)
    at org.testng@7.7.1/org.testng.SuiteRunner.init(SuiteRunner.java:225)
    at org.testng@7.7.1/org.testng.SuiteRunner.<init>(SuiteRunner.java:115)
    at org.testng@7.7.1/org.testng.TestNG.createSuiteRunner(TestNG.java:1349)
    at org.testng@7.7.1/org.testng.TestNG.createSuiteRunners(TestNG.java:1325)
    at org.testng@7.7.1/org.testng.TestNG.runSuitesLocally(TestNG.java:1167)
    at org.testng@7.7.1/org.testng.TestNG.runSuites(TestNG.java:1099)
    at org.testng@7.7.1/org.testng.TestNG.run(TestNG.java:1067)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make public Tryagain1.sumValidation() accessible: module Tryagain does not "exports Tryagain1" to module org.testng
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
    at java.base/java.lang.reflect.Constructor.checkCanSetAccessible(Constructor.java:188)
    at java.base/java.lang.reflect.Constructor.setAccessible(Constructor.java:181)
    at org.testng@7.7.1/org.testng.internal.objects.SimpleObjectDispenser.instantiateUsingDefaultConstructor(SimpleObjectDispenser.java:177)
    at org.testng@7.7.1/org.testng.internal.objects.SimpleObjectDispenser.createInstance(SimpleObjectDispenser.java:87)
    ... 26 more

The Dependency Management tool for your project

Operating System :-

v91negi commented 1 year ago

please suugest for this

missedone commented 1 year ago

do you have the same issue if run the test with build tool like maven or gradle?

v91negi commented 1 year ago

i didn't test in other build tool but i convert project to maven, it still occur

On Thu, May 4, 2023 at 9:05 PM Nick Tan @.***> wrote:

do you have the same issue if run the test with build tool like maven or gradle?

— Reply to this email directly, view it on GitHub https://github.com/testng-team/testng-eclipse/issues/549#issuecomment-1534995551, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC6M5DFOXWJIHGACX5JLDYTXEPEFBANCNFSM6AAAAAAXAGOMSY . You are receiving this because you authored the thread.Message ID: @.***>

krmahadevan commented 1 year ago

@missedone -

accessible: module Tryagain does not "exports Tryagain1" to module org.testng

This looks like there is Java modules involved.

@v91negi - Do you have a module-info.java in your project somewhere? What happens when you delete this file and try again?

v91negi commented 1 year ago

Ok, I will check.

On Fri, 5 May 2023, 07:55 Krishnan Mahadevan, @.***> wrote:

@missedone https://github.com/missedone -

accessible: module Tryagain does not "exports Tryagain1" to module org.testng

This looks like there is Java modules involved.

@v91negi https://github.com/v91negi - Do you have a module-info.java in your project somewhere? What happens when you delete this file and try again?

— Reply to this email directly, view it on GitHub https://github.com/testng-team/testng-eclipse/issues/549#issuecomment-1535617987, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC6M5DHXTDI3PMWQSVDQME3XERQJZANCNFSM6AAAAAAXAGOMSY . You are receiving this because you were mentioned.Message ID: @.***>

v91negi commented 1 year ago

Thank you ,after deleting module info file. Issue resolved and test case pass, as below:-


[RemoteTestNG] detected TestNG version 7.7.0
300
160
450
PASSED: Tryagain.files.sumValidationtest.sumofCourses

===============================================
    Default test
    Tests run: 1, Failures: 0, Skips: 0
===============================================

===============================================

Can you share more details about this, why module_info.java causing error?

krmahadevan commented 1 year ago

@v91negi - If you have a module-info.java then it means that you are trying to leverage the modularisation capabilities that JDK9 and above provide. modules are basically a higher level grouping on top of package. Until JDK8 one could group classes into a package and there was no further grouping that was possible. JDK9 introduced the notion of modules wherein you could basically group a bunch of package into module.

I suggest that you read a bit about module so that it clears out the concept. After that the error message should be self explanatory. In a nutshell, you defined a module-info.java and so Java started expecting that you would tell which all packages are to be visible to the outside world (and to TestNG since TestNG also would be part of the outside world). Since nothing was visible and since TestNG is trying to access your packages, Java flags this as a problem.