[quote:1ayswhrt]WARNING: multiple versions of ant detected in path for junit[/quote:1ayswhrt]
this is the problem. more then 1 ant jar file is lying in the folder. you are using maven so, delete .m2 repo.
I am running build.xml with ant and build.xml has jar files reference to maven repositories
I think this issue is seen more frequently for others also
Can you please give detailed document of how to resolve this please?
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE project>
-<project basedir="." default="usage" name="Module_8_Junit_Ant">
<!-- ========== Initialize Properties =================================== -->
<property environment="env"/> <property name="ws.home" value="${basedir}"/> <property name="ws.jars" value="${user.home}/.m2/repository/"/> <property name="test.dest" value="${ws.home}/build"/> <property name="test.src" value="${ws.home}/src"/> <property name="test.reportsDir" value="D:/Selenium_Practice/rep"/> -<path id="testcase.path"> <pathelement location="${test.dest}"/> -<fileset dir="${ws.jars}"> <include name="*.jar"/> </fileset> </path>
<!--target name="start-selenium-server"> <java jar="${ws.home}/lib/selenium-server.jar"/> </target-->
-<target name="setClassPath" unless="test.classpath"> -<path id="classpath_jars"> <fileset dir="${ws.jars}" includes="**/*.jar"/> </path> <pathconvert refid="classpath_jars" property="test.classpath" pathsep=":"/> </target> -<target name="init" depends="setClassPath"> -<tstamp> <format property="start.time" pattern="MM/dd/yyyy hh:mm aa"/> </tstamp> -<condition value="${env.ANT_HOME}/bin/ant.bat" property="ANT" else="${env.ANT_HOME}/bin/ant"> <os family="windows"/> </condition> </target>
<!-- all -->
<target name="all"> </target>
<!-- clean -->
-<target name="clean"> <delete dir="${test.dest}"/> </target>
<!-- compile -->
-<target name="compile" depends="init, clean"> -<delete quiet="true" includeemptydirs="true"> <fileset dir="${test.dest}" includes="**/*"/> </delete> <echo message="making directory..."/> <mkdir dir="${test.dest}"/> <echo message="classpath------: ${test.classpath}"/> <echo message="compiling..."/> <javac classpath="${test.classpath}" target="1.8" srcdir="${test.src}" destdir="${test.dest}" debug="true"> </javac> </target>
<!-- build -->
<target name="build" depends="init"> </target> -<target name="usage"> <echo> ant run will execute the test </echo> </target> -<path id="test.run"> <fileset dir="${ws.jars}" includes="**/*.jar"/> </path> -<target name="run"> -<delete quiet="true" includeemptydirs="true"> <fileset dir="${test.reportsDir}" includes="**/*"/> </delete> <java spawn="true" fork="true" jar="${ws.jars}"/> -<junit fork="yes" printsummary="yes" haltonfailure="no"> <classpath refid="test.run"/>
<!-- <classpath ="${test.classpath}"/> -->
-<batchtest fork="true" todir="${test.reportsDir}"> -<fileset dir="${test.dest}">
<!--include name="tests/LoginTest.class" /> <include name="tests/Parameterized_Test.class" /> <include name="tests/TestApplication.class" /-->
<include name="com/testing/GoogleTest.class"/> <include name="com/testing/YahooTest.class"/> </fileset> </batchtest> <formatter type="xml"/> <classpath refid="testcase.path"/> </junit> -<junitreport todir="${test.reportsDir}"> -<fileset dir="${test.reportsDir}"> <include name="TEST-*.xml"/> </fileset> <report todir="${test.reportsDir}"/> </junitreport> </target> </project>
[quote="muralikrishnapb@gmail.com":7bpmsye7]I think this issue is seen more frequently for others also
Can you please give detailed document of how to resolve this please?[/quote:7bpmsye7]
i am telling you how to solve the issue delete the .m2/repository and run pom.xml again so the jar files can be downloaded again and after that run build.xml
Sure Thankyou, i need to delete repository and do mvn package right to run pom.xml?
do a [color=#FF0000:1cg8qyvf]mvn test[/color:1cg8qyvf] it will run your project once and after that you can use ant and build.xml to run it.
I have done following steps but it didnt work
1) deleted .m2/repository folder
2)
mvn compile
mvn package
mvn test
mvn package and mvn tests were opening yahoo.com and google.com and working fine
then tried in ant
ant clean
ant compile
ant run
this time that multiple versions of ant detected path for junit is not seen
but I am seeing empty browsers and tests were failing
com.google.common.collect.Multimaps.transformValues(Lcom/google/common/collect/ListMultimap;Lcom/google/common/base/Function;)Lcom/google/common/collect/ListMultimap;
java.lang.NoSuchMethodError: com.google.common.collect.Multimaps.transformValues(Lcom/google/common/collect/ListMultimap;Lcom/google/common/base/Function;)Lcom/google/common/collect/ListMultimap;
at com.google.common.net.MediaType.computeToString(MediaType.java:751)
at com.google.common.net.MediaType.toString(MediaType.java:741)
at org.openqa.selenium.remote.http.JsonHttpCommandCodec.encode(JsonHttpCommandCodec.java:232)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:139)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.execute(NewProfileExtensionConnection.java:160)
at org.openqa.selenium.firefox.FirefoxDriver$LazyCommandExecutor.execute(FirefoxDriver.java:380)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:216)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:207)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
at com.testing.GoogleTest.testGoogle(GoogleTest.java:20)
try this
http://stackoverflow.com/questions/25088899/selenium-webdriver-throws-exception-when-trying-to-run-via-ant
Hi Ashish
I am not able to see any such duplicate jar files , Can you please help me resolve this?
If you need I can give access to my machine.
Thanks in Advance
Regards
Bala
Hi Ashish
Thanks for your quick reply
I am able to resolve the issue, but unable to run the ant file using mvn compile ( running build.xml from pom.xml)
I have deleted the below jar file from repsoitory
C:\Users\bpaithar.ORADEV\.m2\repository\com\google\collections\google-collections\1.0\google-collections-1.0.jar
and did ant clean compile run -> tests passed
on doing mvn compile -> maven is downloading the deleted jar file above in repository and hence tests are failing with same issue.
How do i tell maven(pom.xml) not to download that jar file? Can you please help on this
Regards
Bala
I am not able to do that , can you please tell me how to get rid of it, please
I too faced the same issue, even when adding the exclusion of google-collections in POM.xml and ran mvn compile it is again downloading it. Please help
Here is my pom.xml, please correct me if it is wrong i have added exclusion in each dependency and alsi individual exclusion:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.testing</groupId>
<artifactId>MyMavenProject1Kalyan</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MyMavenProject1Kalyan</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<exclusions>
<exclusion>
<artifactId>google-collections</artifactId>
<groupId>com.google.collections</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.52.0</version>
<exclusions>
<exclusion>
<artifactId>google-collections</artifactId>
<groupId>com.google.collections</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.collections</groupId>
<artifactId>google-collections</artifactId>
<version>1.0</version>
<exclusions>
<exclusion>
<artifactId>google-collections</artifactId>
<groupId>com.google.collections</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>