Search code examples
javamavenjarclassnotfoundexception

Class not found after maven package, but can see it in IDEA denpendies


My java application cast class not exception on class org.apache.htrace.shaded.commons.logging.impl.LogFactoryImpl, from IDEA I can see the class can be found in my dependency:

enter image description here

but when I get into the jar, only some class left in the package org.apache.htrace.shaded.commons.logging, and without impl package in it:

jar -tf GIS-1.0-SNAPSHOT.jar | fgrep org/apache/htrace/shaded/commons
org/apache/htrace/shaded/commons/
org/apache/htrace/shaded/commons/logging/
org/apache/htrace/shaded/commons/logging/Log.class
org/apache/htrace/shaded/commons/logging/LogConfigurationException.class
org/apache/htrace/shaded/commons/logging/LogFactory$1.class
org/apache/htrace/shaded/commons/logging/LogFactory$2.class
org/apache/htrace/shaded/commons/logging/LogFactory$3.class
org/apache/htrace/shaded/commons/logging/LogFactory$4.class
org/apache/htrace/shaded/commons/logging/LogFactory$5.class
org/apache/htrace/shaded/commons/logging/LogFactory$6.class
org/apache/htrace/shaded/commons/logging/LogFactory.class

Also, some and other class exists, which was not in the above picture. And the class I want LogFactoryImpl is not there, so the class not found exception occur.

I have analysis the Maven dependency, and make sure no conflict. What can I do to solve this problem?


Solution

  • I have fixed this.

    It's something due to the version of maven-shade-plugin.

    In my pom.xml I didn't set a version, so some strange happens. After I set the version, the problem solved.