testng icon indicating copy to clipboard operation
testng copied to clipboard

TestNG 6.8 throws exception: org.testng.ITestNGListener: Provider test.serviceloader.TmpSuiteListener not found

Open gpawel opened this issue 12 years ago • 12 comments

When testng task is executed from ant script it throws the following exception. The discussion at https://groups.google.com/forum/#!msg/testng-users/N1X1oIMXXso/9ym9wmuLk9kJ does not help to re-solve the problem.

Exception:

[testng] Exception in thread "main" java.util.ServiceConfigurationError: org.testng.ITestNGListener: Provider test.serviceloader.TmpSuiteListener not found [testng] at java.util.ServiceLoader.fail(Unknown Source) [testng] at java.util.ServiceLoader.access$300(Unknown Source) [testng] at java.util.ServiceLoader$LazyIterator.nextService(Unknown Source) [testng] at java.util.ServiceLoader$LazyIterator.next(Unknown Source) [testng] at java.util.ServiceLoader$1.next(Unknown Source) [testng] at org.testng.TestNG.addServiceLoaderListeners(TestNG.java:961) [testng] at org.testng.TestNG.initializeConfiguration(TestNG.java:896) [testng] at org.testng.TestNG.run(TestNG.java:1031) [testng] at org.testng.TestNG.privateMain(TestNG.java:1364) [testng] at org.testng.TestNG.main(TestNG.java:1333)

BUILD FAILED C:\java\mfc\build.xml:57: The tests failed.

The butild file is here:

<tstamp>
    <format property="current.time"
     pattern="dd.MM.yyyy HH:mm" />
</tstamp>

<property name="etc" value="./etc" />
<property name="src" value="./src" />
<property name="lib" value="./lib" />
<property name="bin" value="./bin" />
<property name="report" value="./test-output" />
<property name="suitesPath" value="./test_suites" />

<path id="classpath">
    <pathelement location="${bin}" />
    <fileset dir="${lib}">
        <include name="**/*.jar" />
    </fileset>
    <fileset dir="${lib}/reportng/reportng-1.1.4">
        <include name="*.jar" />
    </fileset>
</path>

<target name="init">
    <delete dir="${bin}" />
    <mkdir dir="${bin}" />
   <delete dir="${report}" />
    <mkdir dir="${report}" />
   <delete file="jackrabbit.log_IS_UNDEFINED" />
</target>

<target name="compile" depends="init">
    <javac includeantruntime="false" srcdir="${src}" fork="true" destdir="${bin}">
        <classpath refid="classpath">
            <!--pathelement path="${bin}">
            </pathelement-->                
            <!--
            <fileset dir="${lib}">
                <include name="**/*.jar" />
            </fileset>
            -->
        </classpath>
    </javac>
</target>





<target name="Run_Suite" depends="compile">
    <echo>${browser}</echo>
    <echo>${suitesPath}/${suiteName}</echo>
    <taskdef resource="testngtasks" classpathref="classpath" /> 
    <testng outputdir="${report}" classpathref="classpath" haltonfailure="true" useDefaultListeners="false" listeners="org.uncommons.reportng.HTMLReporter" >
        <sysproperty key="browser" value="${browser}" />
        <sysproperty key="suiteName" value="${suiteName}" />
        <sysproperty key="propertiesFile" value="${propertiesFile}" />          
        <xmlfileset dir="${suitesPath}" includes="${suiteName}" />
    </testng>
</target>

gpawel avatar Jun 11 '14 15:06 gpawel

The example project with build and suite files can be found here: https://drive.google.com/file/d/0B2Oj5VU5ZPzDQloycTFzX0hVTVk/edit?usp=sharing

gpawel avatar Jul 06 '14 03:07 gpawel

Sharing project does not work and throwing same error.

What is the error mean ?

neerajl avatar Oct 31 '14 06:10 neerajl

I don't know what does the error mean. I hope some one can help me to find it out here. the example project is added in order to trigger the problem.

gpawel avatar Oct 31 '14 13:10 gpawel

Maybe you should make a maven-project out of it? This is clearly a project which can be improved by it.

FibreFoX avatar Oct 31 '14 14:10 FibreFoX

My goal to understand the problem with testng task and find out what I am doing wrong. Moving to maven will leave the problem opened.

gpawel avatar Oct 31 '14 16:10 gpawel

Hi gpawel,

I agree with you, If you search this error on internet and hardly 10 post are available and that to only questions.

Anyway, I got solution, may be workaround, I didnt dig in to the error. however according to me this problem could be because of jar files of TestNg which I am pointing in Ant file. When i changed to other sets of Jar files which i kept somewhere else in my system. Its working and error disappeared.

I am preparing post on this error and upload on my blog, once I complete the draft I will update here for your reference.

Thanks friends, Neeraj

neerajl avatar Nov 03 '14 03:11 neerajl

NeerajI, Thank you, very much. I am looking forward to read the article.

gpawel avatar Nov 03 '14 14:11 gpawel

This happens because you have lib/testng-6.8/src/test/resources/serviceloader.jar in classpath when running tests using ant. That's caused by <include name="**/*.jar" /> rule.

Two ways:

  • Don't use aggressive patterns for classpath (recommended), specify really required jars instead.
  • Don't put library sources into project (recommended), so remote everything from lib/testng-6.8 except one jar.

VladRassokhin avatar Nov 15 '14 05:11 VladRassokhin

@cbeust issue can be closed as Invalid

VladRassokhin avatar Nov 15 '14 05:11 VladRassokhin

Hi Vlad. Thank you very much for the advice. I will try the proposed solution shortly.

gpawel avatar Nov 15 '14 23:11 gpawel

Just build the project in eclipse, using maven clean And then it worked for me!!!

metacubeqa avatar Sep 03 '18 06:09 metacubeqa

Closing this issue based on the above comments.

krmahadevan avatar Sep 03 '18 15:09 krmahadevan