0

I've been trying many different things throughout various posts, but none of the solutions have helped me.

  1. Creating an artifact through Build -> Build artifacts..., selecting directory for META-INF/MANIFEST.MF as main\resources and running a generated jar file throws no main manifest attribute.

  2. <..>, selecting directory for META-INF/MANIFEST.MF as main\java and running a generated jar file returns Could not find or load main class.

My MANIFEST.MF:

Manifest-Version: 1.0
Main-Class: <package>.MainApplication

Also, in my build.gradle I have:

jar {
    manifest {
        attributes 'Main-Class': '<package>.MainApplication'
    }
}

I have tried creating a new project, but the problem persisted the same. I hope someone could help me. Thank you.

UPDATE:

Demo project example (FileMail), which produces my error.

Demo project example (MediaFire)

UPDATE 2:

Demo project 2 example

Captain Jacky
  • 888
  • 1
  • 12
  • 26
  • See https://stackoverflow.com/a/42660624/104891 and https://stackoverflow.com/a/42200519/104891. If the issue persists, please share the [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) (sample project on GitHub would work). – CrazyCoder Jan 19 '22 at 19:49
  • @CrazyCoder, please see attached at the bottom of my question. – Captain Jacky Jan 20 '22 at 12:51
  • Please use something to share your code where I do not have to register – Uwe Plonus Jan 20 '22 at 15:02
  • @UwePlonus, I've added link to `MediaFire`. I hope you can download now. – Captain Jacky Jan 20 '22 at 16:16
  • 1
    Your fat jar contains digital signatures, therefore it will not run: MANIFEST.MF SIGNINGC.RSA SIGNINGC.SF. These files were unpacked from one of your dependencies. They have to be removed from the fat jar. – CrazyCoder Jan 20 '22 at 22:51
  • @CrazyCoder, yes it did. Now I've created a new project without any dependencies and built a `jar` file again. It did not contain neither `SIGNINGC.RSA` nor `SIGNINGC.SF` but the error persisted the same. – Captain Jacky Jan 21 '22 at 15:54
  • Share your new project then. – CrazyCoder Jan 21 '22 at 16:17
  • @CrazyCoder, please see attached below update 2. Thank you. – Captain Jacky Jan 21 '22 at 16:36
  • 1
    It's not clear how the jar in this project was built. There is no artifact for this jar configuration and Gradle builds a different jar without dependencies. The problem with the jar you have in `out\artifacts` is that it has Manifest file included from some different library and this manifest doesn't specify the main class. If you build it with IntelliJ IDEA artifacts feature, reorder the manifest in the included files so that the correct one is used, see https://youtrack.jetbrains.com/issue/IDEA-116209#comment=27-656589 for more details. – CrazyCoder Jan 21 '22 at 16:40
  • @CrazyCoder, I've disabled alphabetical order but the problem persisted. Then I changed resources folder to `src` directory and now it throws `No auto configuration classes found in META-INF/spring.factories.`. But running `./gradlew build` works. – Captain Jacky Jan 21 '22 at 17:06
  • 1
    Yeah, packaging Spring apps in the fat jar can be a pain, use Gradle for that. – CrazyCoder Jan 21 '22 at 17:07
  • 1
    See if https://stackoverflow.com/a/33579556/104891 helps. – CrazyCoder Jan 21 '22 at 17:15

0 Answers0