java.lang.NoSuchMethodError: org.apache.commons.io.FileUtils.copyInputStreamToFile(Ljava/io/InputStream;Ljava/io/File;)

Madhavi Mokkapati picture Madhavi Mokkapati · Apr 18, 2017 · Viewed 12.6k times · Source

While trying to launch firefox browser using selenium

Function:

     System.setProperty("webdriver.gecko.driver", Constants.PROJECT_PATH+Constants.MARIONETTE_FIREFOX);
     log.info("Marionette file path: "+Constants.PROJECT_PATH+Constants.MARIONETTE_FIREFOX);
     MarionetteDriverManager.getInstance().setup();

In the 3rd line i am getting the mentioned error message -

"java.lang.NoSuchMethodError: org.apache.commons.io.FileUtils.copyInputStreamToFile(Ljava/io/InputStream;Ljava/io/File;)"

Maven Dependency tags I am using is

   <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-io</artifactId>
        <version>1.3.2</version>
    </dependency>

New dependecy tags added following #Christian Lutz answer

    <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.5</version>
    </dependency>

How can I re-solve the issue?

Answer

Christian picture Christian · Apr 18, 2017

In version 1.3.2 the class FileUtilsdoesn't have a method copyInputStreamToFile you need at least version 2.0

Please see the javadoc for the current version 2.5. There you will find the method and a Sincetag.