Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ artifact JAR file: Could not find or load main class

I created a JAR artifact in IntelliJ with option to extract JAR files to the target JAR. Look like this:

enter image description here

I filled the manifest information properly:

enter image description here

I checked the content of the JAR file with ZIP and it contains the jar files, the properly filled MANIFEST.MF and the .class files for my project.

But if I try to run it, it drops an error:

d:\Own_Tools\REF_Standalone\build>java -jar REF_Standalone.jar
Error: Could not find or load main class com.continental.ref.REFController

I am pretty sure it contains com\continental\ref\REFController.class.

Do you have any idea what went wrong with it?

Thanks: Levente

like image 767
Levente Avatar asked Feb 27 '19 15:02

Levente


1 Answers

apache-commons.jar is digitally signed (you can tell it by the FILETEST.DSA and FILETEST.SF in the META-INF directory).

When the artifact jar is packaged, these files are copied into the new jar, but they do not contain the signatures for other classes in your new jar.

This breaks the jar signature and JVM doesn't allow the execution of the jar for the security reasons.

See my another answer for the workaround (just delete *.SF and *.DSA files from apache-commons.jar and rebuild the artifact).

like image 106
CrazyCoder Avatar answered Nov 10 '22 12:11

CrazyCoder