Java Package Conflict resolution method

Source: Internet
Author: User
Tags jboss

1. Diagnostic packet Conflict

Java.lang.nosuchmethoderror:org.apache.commons.io.output.deferredfileoutputstream.<init> (ILjava/lang/ String; ljava/lang/string; Ljava/io/file;) V


2. Solve

2.1 Visible Dependency Conflicts

Open the project in Eclipse, and in the dependency hierarchy of the Pom file, search the conflicting package Commons-io to see dependency information for each dependent package. If the package has a dependency conflict, there will be a conflict between the version of XXX and version xxx. Select the correct version and exclusion the remaining version under the corresponding reference package.

or use MVN dependency:tree > Tree.log to import the dependency information into the file Tree.log to see the dependency information for the package Commons-io.


2.2 Non-visible dependency conflicts

1) See if the server uses a different version of the JBoss path that contains the conflicting packages.

The path is: Jboss-x.x.x.ga/lib, and Jboss-x.x.x.ga/server/default/lib, if there is a conflicting version, then delete.


2) Check which package the JVM is loading when the exception occurs.

Add the JVM startup parameter-verbose:class to the program-initiated script, and then restart the app. In the startup log, you can see which package the loaded class came from.

[Loaded org.apache.velocity.runtime.parser.node.ASTTrue from File:/home/admin/app/.default/deploy/app.war/web-inf /lib/velocity-1.6.4.jar]

Trigger the action that caused the exception to view the package that contains the loaded class, compared to the correct package.

Add:

In this case, it is possible that the version of the package raised the error, the method being called is different from the implementation of the higher and lower versions, or there is a missing method in a version.

It is also possible that two different jar packages, containing classes of the same path, are then confused during the call. In this case, you can use shift+ctrl+t in eclipse to see how many of these classes are in the project and see the classpath information.

Java Package Conflict resolution method

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.