reportportal / agent-java-testNG

TestNG listener
Apache License 2.0
54 stars 20 forks source link

java.lang.NoClassDefFoundError: com/epam/reportportal/utils/MemoizingSupplier while running the tests #201

Closed vinnus8660 closed 1 year ago

vinnus8660 commented 1 year ago

Describe the bug Trying to integrate TestNG + Selenium framework with Report Portal, but getting error while running the tests after adding the report portal configurations, agent-java-testng and logger-java-log4j jars.

Steps to Reproduce Steps to reproduce the behavior:

  1. TestNG + Selenium framework - using TestNG Jar 7.4.0
  2. Report Portal Properties and log4j2.xml supplied in src/test/main/resources
  3. Listener com.epam.reportportal.testng.ReportPortalTestNGListener added in the TestNG suite xml file from which is triggerred.
  4. Trigger the TestNG xml file, then we are seeing the below error.

Expected behavior The tests are working fine before passing the report portal integration with TestNG configuration mentioned in the readme at https://github.com/reportportal/agent-java-testNG.

Expecting it to work fine even with the plugin additions and configurations.

Actual behavior Getting below error after adding the report portal configuration.

[RemoteTestNG] detected TestNG version 7.4.0
java.lang.NoClassDefFoundError: com/epam/reportportal/utils/MemoizingSupplier
    at com.epam.reportportal.testng.ReportPortalTestNGListener.<clinit>(ReportPortalTestNGListener.java:31)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
    at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128)
    at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:347)
    at java.base/java.lang.Class.newInstance(Class.java:645)
    at org.testng.internal.InstanceCreator.newInstance(InstanceCreator.java:30)
    at org.testng.TestNG.addListeners(TestNG.java:964)
    at org.testng.TestNG.initializeConfiguration(TestNG.java:924)
    at org.testng.TestNG.initializeEverything(TestNG.java:1012)
    at org.testng.remote.support.RemoteTestNG6_12.initialize(RemoteTestNG6_12.java:22)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:98)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.ClassNotFoundException: com.epam.reportportal.utils.MemoizingSupplier
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    ... 16 more

Dependency versions TestNG Jar - 7.4.0 agent-java-testng - 5.3.1 logger-java-log4j - 5.1.8 selenium-server - 3.141.59 slf4j-api - 1.7.32 slf4j-log4j12 - 1.7.32 log4j - 1.2.17

Hi @DzmitryHumianiuk @HardNorth Can I request your insights on this issue.

HardNorth commented 1 year ago

@vinnus8660 That's happens because you project refers old version of our client-java library. Please study your dependency tree and remove or add exclusions on transitive dependency. You can do this with commands mvn dependency:tree for Maven or gradle dependencies for Gradle.

vinnus8660 commented 1 year ago

@HardNorth Thanks for responding! I have tried to fix it, but nothing worked so far, appreciate your further inputs.

I'm using the eclipse testng manual plugin downloaded from https://github.com/testng-team/testng-eclipse to run the tests, I have upgraded my project to use testng 7.8.0 and other dependencies latest versions as well.

My current dependencies in project are:

TestNG Eclipse Plugin 7.8.0 slf4j-api - 2.0.7 agent-java-testng - 5.3.1 logger-java-log4j - 5.1.8 selenium-server - 4.8.1

I'm not sure which of the above dependency is referring to the older older version of client-java.

I'm configuring the below listener in suite.xml file but still the same error.

<listener class-name="com.epam.reportportal.testng.ReportPortalTestNGListener" />
HardNorth commented 1 year ago

@vinnus8660 Sorry, I don't provide consultancy for apart of the area of Report Portal libraries. What I can say, this class is here: https://github.com/reportportal/client-java/blob/develop/src/main/java/com/epam/reportportal/utils/MemoizingSupplier.java

It is here for a long time, more than 3 years.

To fix your case you need to find out which library in your project overrides our client-java library with a very old version.