Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency conflict issue: Exception in thread "main" java.lang.NoSuchMethodError: caused by multiple versions of commons-io:commons-io:jar #816

Open
LeoAugust19 opened this issue Aug 1, 2018 · 3 comments

Comments

@LeoAugust19
Copy link

LeoAugust19 commented Aug 1, 2018

Hi, there are multiple versions of commons-io:commons-io:jar in us.codecraft:webmagic-selenium:jar:0.7.3. As shown in the following dependency tree, only
the older version commons-io:commons-io:jar:1.3.2 will be loaded and the newer versions are shadowed, according to "Maven's nearest wins strategy", during the packaging process.

However, the method <org.apache.commons.io.FileUtils: boolean deleteQuietly(java.io.File)> only included in >commons-io 2.x. As a result, an exception may be thrown when your project referencing the missing method.

Dependency tree

us.codecraft:webmagic-selenium:jar:0.7.3
+- org.seleniumhq.selenium:selenium-java:jar:2.41.0:compile
| +- org.seleniumhq.selenium:selenium-chrome-driver:jar:2.41.0:compile
| | - (org.seleniumhq.selenium:selenium-remote-driver:jar:2.41.0:compile - omitted for duplicate)
| +- org.seleniumhq.selenium:selenium-htmlunit-driver:jar:2.41.0:compile
| | +- (org.seleniumhq.selenium:selenium-remote-driver:jar:2.41.0:compile - omitted for duplicate)
| | +- net.sourceforge.htmlunit:htmlunit:jar:2.13:compile
| | | +- xalan:xalan:jar:2.7.1:compile
| | | +- net.sourceforge.cssparser:cssparser:jar:0.9.11:compile
| | | | - org.w3c.css:sac:jar:1.3:compile
| | | +- (commons-io:commons-io:jar:2.4:compile - omitted for conflict with 2.2)
| | | +- (commons-logging:commons-logging:jar:1.1.3:compile - omitted for conflict with 1.2)
| | | - org.eclipse.jetty:jetty-websocket:jar:8.1.12.v20130726:compile
| | | +- org.eclipse.jetty:jetty-util:jar:8.1.12.v20130726:compile
| | | +- org.eclipse.jetty:jetty-io:jar:8.1.12.v20130726:compile
| | | | - (org.eclipse.jetty:jetty-util:jar:8.1.12.v20130726:compile - omitted for duplicate)
| | | - org.eclipse.jetty:jetty-http:jar:8.1.12.v20130726:compile
| | | - (org.eclipse.jetty:jetty-io:jar:8.1.12.v20130726:compile - omitted for duplicate)
| | - (org.apache.httpcomponents:httpclient:jar:4.5.2:compile - version managed from 4.3.1; omitted for duplicate)
| +- org.seleniumhq.selenium:selenium-firefox-driver:jar:2.41.0:compile
| | +- (org.seleniumhq.selenium:selenium-remote-driver:jar:2.41.0:compile - omitted for duplicate)
| | +- (commons-io:commons-io:jar:2.2:compile - omitted for conflict with 1.3.2)
| | - org.apache.commons:commons-exec:jar:1.1:compile
| +- org.seleniumhq.selenium:selenium-support:jar:2.41.0:compile
| | - org.seleniumhq.selenium:selenium-api:jar:2.41.0:compile
| | +- (com.google.guava:guava:jar:15.0:compile - omitted for duplicate)
| | - (org.json:json:jar:20080701:compile - omitted for duplicate)
| - org.webbitserver:webbit:jar:0.4.14:compile
| - io.netty:netty:jar:3.5.2.Final:compile
+- us.codecraft:webmagic-core:jar:0.7.3:compile
| +- org.apache.httpcomponents:httpclient:jar:4.5.2:compile
| | +- org.apache.httpcomponents:httpcore:jar:4.4.4:compile
| | +- commons-logging:commons-logging:jar:1.2:compile
| | - commons-codec:commons-codec:jar:1.9:compile
| +- org.jsoup:jsoup:jar:1.10.3:compile
| +- commons-io:commons-io:jar:1.3.2:compile
| +- com.jayway.jsonpath:json-path:jar:2.4.0:compile
| | +- net.minidev:json-smart:jar:2.3:compile
| | | - net.minidev:accessors-smart:jar:1.2:compile
| | | - org.ow2.asm:asm:jar:5.0.4:compile
| | - (org.slf4j:slf4j-api:jar:1.7.6:compile - version managed from 1.7.25; omitted for duplicate)
| - com.alibaba:fastjson:jar:1.2.28:compile

Solution

Upgrade commons-io to 2.4.

Thanks,

Regards,
Leo

@LeoAugust19
Copy link
Author

LeoAugust19 commented Aug 9, 2018

Stack trace

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.commons.io.FileUtils.deleteQuietly(Ljava/io/File;)Z
at com.gargoylesoftware.htmlunit.DownloadedContent$OnFile.cleanUp(DownloadedContent.java:86)
at com.gargoylesoftware.htmlunit.WebResponseData.cleanUp(WebResponseData.java:184)
at com.gargoylesoftware.htmlunit.WebResponse.cleanUp(WebResponse.java:250)
at com.gargoylesoftware.htmlunit.SgmlPage.cleanUp(SgmlPage.java:62)
at com.gargoylesoftware.htmlunit.html.HtmlPage.cleanUp(HtmlPage.java:310)
at com.gargoylesoftware.htmlunit.TopLevelWindow.close(TopLevelWindow.java:121)
at com.gargoylesoftware.htmlunit.WebClient.closeAllWindows(WebClient.java:1707)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.quit(HtmlUnitDriver.java:571)
at us.codecraft.webmagic.downloader.selenium.WebDriverPool.closeAll(WebDriverPool.java:235)

@LeoAugust19
Copy link
Author

@ouyanghuangzheng, Hi, May pull a request to fix this issue?

@fendo8888
Copy link

	<dependency>
		<groupId>us.codecraft</groupId>
		<artifactId>webmagic-core</artifactId>
		<version>0.7.3</version>
		<exclusions>
			<exclusion>
				<artifactId>commons-io</artifactId>
				<groupId>org.apache.commons</groupId>
			</exclusion>
			<exclusion>
				<groupId>org.slf4j</groupId>
				<artifactId>slf4j-log4j12</artifactId>
			</exclusion>
		</exclusions>
	</dependency>

这样?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants