TestNG 6.8 throws exception: org.testng.ITestNGListener: Provider test.serviceloader.TmpSuiteListener not found
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>
The example project with build and suite files can be found here: https://drive.google.com/file/d/0B2Oj5VU5ZPzDQloycTFzX0hVTVk/edit?usp=sharing
Sharing project does not work and throwing same error.
What is the error mean ?
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.
Maybe you should make a maven-project out of it? This is clearly a project which can be improved by it.
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.
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
NeerajI, Thank you, very much. I am looking forward to read the article.
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.8except one jar.
@cbeust issue can be closed as Invalid
Hi Vlad. Thank you very much for the advice. I will try the proposed solution shortly.
Just build the project in eclipse, using maven clean And then it worked for me!!!
Closing this issue based on the above comments.