Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testng 7.1.0 java.lang.ClassNotFoundException: com.google.inject.Stage #2223

Closed
7 tasks
missedone opened this issue Jan 12, 2020 · 38 comments · Fixed by #2264
Closed
7 tasks

testng 7.1.0 java.lang.ClassNotFoundException: com.google.inject.Stage #2223

missedone opened this issue Jan 12, 2020 · 38 comments · Fixed by #2264

Comments

@missedone
Copy link
Contributor

TestNG Version

TestNG 7.1.0

Expected behavior

Actual behavior

the testng-remote integration test failed
https://travis-ci.org/testng-team/testng-remote/jobs/481901771

[RemoteTestNG] revisions:
	git.commit.id=32c8977
	git.branch=32c8977911e409c8c8c2d4bce973e94d2acf5ca7
	git.build.version=1.4.1-SNAPSHOT
[RemoteTestNG] loaded class org.testng.internal.Version at file:/home/travis/.groovy/grapes/org.testng/testng/jars/testng-7.1.0.jar
[RemoteTestNG] detected TestNG version 7.1.0
Caught: java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: com/google/inject/Stage
java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: com/google/inject/Stage
	at org.testng.internal.Configuration.<init>(Configuration.java:33)
	at org.testng.TestNG.init(TestNG.java:216)
	at org.testng.TestNG.<init>(TestNG.java:200)
	at org.testng.remote.AbstractRemoteTestNG.<init>(AbstractRemoteTestNG.java:17)
	at org.testng.remote.support.RemoteTestNG6_12.<init>(RemoteTestNG6_12.java:18)
	at org.testng.remote.support.RemoteTestNGFactory6_12.createRemoteTestNG(RemoteTestNGFactory6_12.java:16)
	at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:67)
	at org.testng.remote.RemoteTestNG$main.call(Unknown Source)
	at TestNGTest.run(TestNGTest.groovy:49)
Caused by: java.lang.NoClassDefFoundError: com/google/inject/Stage
	... 9 more
Caused by: java.lang.ClassNotFoundException: com.google.inject.Stage
	... 9 more
[BaseMessageSender] Stopped receiver

Is the issue reproductible on runner?

  • Shell
  • Maven
  • Gradle
  • Ant
  • Eclipse
  • IntelliJ
  • NetBeans

Test case sample

Please, share the test case (as small as possible) which shows the issue
https://github.com/testng-team/testng-remote/blob/master/remote-test/src/test/groovy/Tester.groovy

@krmahadevan
Copy link
Member

krmahadevan commented Jan 12, 2020

@missedone

In 7.0.0 pom below was the dependency information on guice

<dependency>
    <groupId>com.google.inject</groupId>
    <artifactId>guice</artifactId>
    <version>4.1.0</version>
    <classifier>no_aop</classifier>
    <scope>provided</scope>
</dependency>

In 7.1.0 pom below was the dependency information on guice

<dependency>
    <groupId>com.google.inject</groupId>
    <artifactId>guice</artifactId>
    <version>4.1.0</version>
    <classifier>no_aop</classifier>
    <scope>compile</scope>
</dependency>

So perhaps this issue is because guice became a compile time dependency from being a provided dependency ?

@cbeust
Copy link
Collaborator

cbeust commented Jan 13, 2020

Doubtful. The dependency is harder now than it was before.

Note that the error is NoClassDefFound, not ClassNotFound. Guice is missing a dependency, it seems.

@liry
Copy link

liry commented Jan 15, 2020

Making guice compile time dependency seems to me as a wrong direction. And BTW, it's not backward compatible, so such a change should be in major version only.

@cbeust
Copy link
Collaborator

cbeust commented Jan 15, 2020

It is api only though.

If the pom.xml was generated as compile, this looks like a bug in Gradle(?).

@liry
Copy link

liry commented Jan 16, 2020

Well, maven (i.e. pom.xml) doesn't have "api only" scope. It's needed for compilation and it's being exposed by api -> compile scope.

BTW, what will happen, if I have guice required in the project in different incompatible version? Is it backward compatible?

@missedone
Copy link
Contributor Author

missedone commented Jan 28, 2020

Guice is compile time dependency: https://github.com/cbeust/testng/blob/master/src/main/java/org/testng/internal/Configuration.java#L33

so it's hard dependency

the fix is either make Guice the compile dependency in pom manifest or make injectorFactory lazy init

@missedone missedone mentioned this issue Feb 14, 2020
1 task
@rahulmogar
Copy link

please remove the jar file from the build path and install TestNG from help menu(install software)
worked for me

@SantiBailors0
Copy link

Eclipse IDE for Java Developers, Version: 2019-12 (4.14.0), Build id: 20191212-1212.
TestNG 7.1.0.r202001120626

Removing the TestNG library from the build path of the project containing the test and installing TestNG from menu Help / Install New Software did not work for me, I kept getting this error.

What worked for me was downloading guice-4.2.2.jar (from https://github.com/google/guice/wiki/Guice422), copying it into any folder, and adding it to the build path of the project as external JAR.

@gauravpratap01
Copy link

please remove the jar file from the build path and install TestNG from help menu(install software)
worked for me

Can you please provide me the link to install plugin from "Install new software"

@bharathkjv
Copy link

bharathkjv commented Mar 3, 2020

please remove the jar file from the build path and install TestNG from help menu(install software)
worked for me

Can you please provide me the link to install plugin from "Install new software"

From Eclipse, Go to Help > Install software or You can install from market place as well (Help > Market Place). After installing TestNG from market place, it dint work, but installing the GUICE422.jar to the build path worked for me
So make sure after installing TestNG from market place, install the Guice422 Jar file as well

@nixlend
Copy link

nixlend commented Mar 10, 2020

Eclipse IDE for Java Developers, Version: 2019-12 (4.14.0), Build id: 20191212-1212.
TestNG 7.1.0.r202001120626

Removing the TestNG library from the build path of the project containing the test and installing TestNG from menu Help / Install New Software did not work for me, I kept getting this error.

What worked for me was downloading guice-4.2.2.jar (from https://github.com/google/guice/wiki/Guice422), copying it into any folder, and adding it to the build path of the project as external JAR.

That is the only way that works for me as well, and the weirdest thing was TestNG version 7.0.1 was displayed in the console regardless of the TestNG version that I installed was 7.1.1. Anyway it works now.

@yaminikb
Copy link

@krmahadevan We need this fix, when is the next release of TestNG?

@krmahadevan
Copy link
Member

@yaminikb - The release should be out soon (in a week or so).

@SantiBailors0
Copy link

JFI, my TestNG apparently has just updated, to 7.1.1.202003100345, but if I remove from the build path the Guice JAR that I had to add manually to avoid the NoClassDefFoundError, the error reappears.

So for me today's update made zero difference, besides the fact that now I can't tell for sure which TestNG version I have: expanding the TestNG node in Package Explorer says 7.1.0.r202001120626 (which is the same I already had since long before today's update), and under C:\eclipse\plugins, besides the 7.1.0.* JARs that I already had, I now also have two 7.1.1.* JARs which, as I mentioned, don't seem to be used.
But the bottom line is that for me this update did not affect the NoClassDefFoundError: the Guice JAR on the build path as an external JAR is still necessary for me.

@missedone
Copy link
Contributor Author

The eclipse plugin update is not to fix this issue. Still need to wait for the new testng release .

@mlook172
Copy link

How to downgrade to version 7.0.?

@mlook172
Copy link

[RemoteTestNG] detected TestNG version 7.0.1
Exception in thread "main" java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: com/google/inject/Stage
at org.testng.internal.Configuration.(Configuration.java:33)
at org.testng.TestNG.init(TestNG.java:216)
at org.testng.TestNG.(TestNG.java:200)
at org.testng.remote.AbstractRemoteTestNG.(AbstractRemoteTestNG.java:17)
at org.testng.remote.support.RemoteTestNG6_12.(RemoteTestNG6_12.java:18)
at org.testng.remote.support.RemoteTestNGFactory6_12.createRemoteTestNG(RemoteTestNGFactory6_12.java:16)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:67)
Caused by: java.lang.NoClassDefFoundError: com/google/inject/Stage
... 7 more
Caused by: java.lang.ClassNotFoundException: com.google.inject.Stage
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more

I faced this issue kindly advice..

@missedone
Copy link
Contributor Author

@mlook172 , you can try to install the beta build in your eclipse:
"Help -> Install New Software.. -> paste the below update site url into Work with: field"
https://dl.bintray.com/testng-team/testng-p2/updatesites/7.2.0.b202003151750/

@mlook172
Copy link

its working fine now

thanks

@nixlend
Copy link

nixlend commented Mar 17, 2020

7.2.0.r202003151902 has fixed the issue, thank you!

@mlook172
Copy link

mlook172 commented Mar 17, 2020 via email

@zehrabatool
Copy link

Works for me as well. Thanks !

@subhashri1207
Copy link

I also faced the same issue. Thank you. It's working for me now

@twinki1624
Copy link

Eclipse IDE for Java Developers, Version: 2019-12 (4.14.0), Build id: 20191212-1212.
TestNG 7.1.0.r202001120626

Removing the TestNG library from the build path of the project containing the test and installing TestNG from menu Help / Install New Software did not work for me, I kept getting this error.

What worked for me was downloading guice-4.2.2.jar (from https://github.com/google/guice/wiki/Guice422), copying it into any folder, and adding it to the build path of the project as external JAR.

It did excuse the error. But all the test cases are skipping/ failing on introducing guice.jar
image

@missedone
Copy link
Contributor Author

@twinki1624 , could you try with my comment: testng-team/testng-eclipse#472 (comment)

@twinki1624
Copy link

@twinki1624 , could you try with my comment: cbeust/testng-eclipse#472 (comment)

Unfortunately, it's still now working.
image

Can you guide me through any other steps? I'm in the mid of a project, need it to be resolved at the earliest.

@missedone
Copy link
Contributor Author

@twinki1624 , for this DTD https url issue, pls update testng eclipse plugin to latest update site: https://dl.bintray.com/testng-team/testng-eclipse-release

@twinki1624
Copy link

@twinki1624 , for this DTD https url issue, pls update testng eclipse plugin to latest update site: https://dl.bintray.com/testng-team/testng-eclipse-release

I tried it using the above link, help>install new software,it's not getting installed.
image

@kportner
Copy link

kportner commented Apr 20, 2020

Any movement on this? I'm seeing the same issue.

Exception in thread "main" java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: com/google/inject/Stage

@SantiBailors
Copy link

SantiBailors commented Apr 20, 2020

Any movement on this? I'm seeing the same issue.

Your version is probably not up to date, the problem was fixed with 7.2.0.r202003151902

@kukreja1980
Copy link

Install TestNG 7.1 and then install P2 libraries from TestNG 7.2
"Help -> Install New Software.. -> paste the below url Work with: field"
https://dl.bintray.com/testng-team/testng-eclipse-release/
Eclipse is restarted, then again:
"Help -> Install New Software.. ->
https://dl.bintray.com/testng-team/testng-p2-release/

@Geethu2593-GIT
Copy link

I'm also facing the same issue. I tried all the above solutions nothing worked for me

[RemoteTestNG] detected TestNG version 7.0.0
Exception in thread "main" java.lang.NoSuchMethodError: org.testng.TestNG.configure(Lorg/testng/CommandLineArgs;)V
at org.testng.remote.AbstractRemoteTestNG.configure(AbstractRemoteTestNG.java:75)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:235)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

I tried to match all the verion plugin and testng jar

For testNG p2- i used this urlhttps://dl.bintray.com/testng-team/testng-p2-release/7.0.0/

Can someone please help me here

@SantiBailors
Copy link

SantiBailors commented May 21, 2020

It's not the same issue, you have a NoSuchMethodError, not a NoClassDefFoundError. Look up the causes of NoSuchMethodError. A JAR is found in your case but you probably have some version mismatch, maybe an old JAR.
As first thing I would uninstall TestNG and do a full reinstallation of the latest version, especially if you have been trying different workarounds.

@Geethu2593-GIT
Copy link

Geethu2593-GIT commented May 21, 2020

@SantiBailors thanks for your reply.

I also, tried that, uninstalled the TestNG and reinstalled the latest version, it didnt work.

then again i uninstalled the latest version an installed TestNG7.0.0 just to maintain same versions for jar file and plugin.

Although I'm not sure if that should be the case,

@SantiBailors
Copy link

SantiBailors commented May 21, 2020

I don't know how it didn't work so it's difficult to say much, but if you mean that you got the NoSuchMethodError even from a clean reinstallation I would be surprised. Anyway, based on what is known, if it was me I would install another Eclipse in a separate folder (it won't interfere with the existing Eclipse installation), making sure it's the latest Eclipse, then install TestNG there, via marketplace. If it still gives the NoSuchMethodError it would be really strange.

You could also try to uninstall TestNG, close Eclpise, delete from the plugins subfolder of Eclipse all the JARs that start with org.testng before reinstalling TestNG from marketplace.

Also note that from your stacktrace it's clear that that NoSuchMethodError has nothing to do with Guice or other external libraries, so you should really open a new issue, your problem is not linked with the one discussed in this thread. And maybe by giving a specific title to the new thread you can get more focused help.

@Geethu2593-GIT
Copy link

I already tried everything on brand new stuff, but once again i will try the same thing, may be I'm missing some key thing.

Also, I copied my previous pom.xml file(dependencies only) in the new one, as it has many jars that are required in my project. may be that could be the reason too..

once again thank you @SantiBailors

@sujaniw-spec
Copy link

Removed TestNG jar file from the build path and add the following dependency to the POM.

org.testng
testng
7.1.0
test

It worked for me.

@vinayhegde2013
Copy link

@SantiBailors0 You saved my day after wasting 3-4 hrs to find the right answer. Adding a dependency of GUICE4.2.2 is working like charm. Thanks man

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.