-1

When I'm running a executable .jar file created with maven build, I'm getting the below error:


Exception in thread "main" java.lang.SecurityException: no manifiest section 
for signature file entry 
org/bouncycastle/cms/CMSSignedDataStreamGenerator$TeeOutputStream.class
    at sun.security.util.SignatureFileVerifier.verifySection(Unknown Source)
    at sun.security.util.SignatureFileVerifier.processImpl(Unknown Source)
    at sun.security.util.SignatureFileVerifier.process(Unknown Source)
    at java.util.jar.JarVerifier.processEntry(Unknown Source)
    at java.util.jar.JarVerifier.update(Unknown Source)
    at java.util.jar.JarFile.initializeVerifier(Unknown Source)
    at java.util.jar.JarFile.getInputStream(Unknown Source)
    at sun.misc.URLClassPath$JarLoader$2.getInputStream(Unknown Source)
    at sun.misc.Resource.cachedInputStream(Unknown Source)

Points can be noted: I'm building a Java swing project with Maven 3.3. I'm targeting a maven shaded jar file, and when running the jar file with 'java -jar ' I'm getting the above error.

Any help is appreciated. Please let me know if anyone need any more information. I am stuck; please help.

tkruse
  • 10,222
  • 7
  • 53
  • 80
Krish
  • 19
  • 1
  • 2
  • 7
  • 1
    Possible duplicate [java.lang.SecurityException: no manifest section for signature file entry](https://stackoverflow.com/questions/20045744/java-lang-securityexception-no-manifest-section-for-signature-file-entry) (yes I know it's Ant based, but it might give you hint of what's going wrong); [Error while creating consolidated jar file - no manifiest section for signature file entry](https://stackoverflow.com/questions/9592057/error-while-creating-consolidated-jar-file-no-manifiest-section-for-signature/20522281) – MadProgrammer Feb 12 '18 at 21:29
  • 1
    Possible duplicate (maven base) [Maven shade jar throw exception](https://stackoverflow.com/questions/8302022/maven-shade-jar-throw-exception) – MadProgrammer Feb 12 '18 at 21:30
  • Based on looking through just those 3 questions, it would appear that you are repacking your dependencies into a single "fat jar", but you're including the certificates of the "signed" jars as well. Based on those 3 questions seems to basically be to filter out the certificate files when the "fat jar" is generated – MadProgrammer Feb 12 '18 at 21:31
  • First of all Thank you for your time and reply. :) @MadProgrammer one more help, can you please tell me how can I exclude (I'm very new to Maven) those certificates... so that I can try once again with this solutions. – Krish Feb 13 '18 at 07:24
  • Ok... I got some idea from your provided links, will try to exclude and update here if it works fine. Thanks @MadProgrammer – Krish Feb 13 '18 at 07:29
  • Worked... Thanks. @MadProgrammer – Krish Feb 13 '18 at 19:12
  • Fell free to provide you own answer, including any relevant maven code, as it may help others – MadProgrammer Feb 13 '18 at 19:31
  • @MadProgrammer I've done some cleanup for questions with this error message: https://stackoverflow.com/search?q=title%3Amanifiest. Feel free to close as duplicate some of them. – Cœur May 18 '18 at 06:35

1 Answers1

0

I have excluded the licence files from maven as suggested by @MadProgrammer. Used below codes in pom.xml

<filters>
<filter>    
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.RSA</exclude>
<exclude>META-INF/*.INF</exclude> <!-- This one may not be required -->
</excludes>
</filter>
</filters>
Krish
  • 19
  • 1
  • 2
  • 7
  • For example of using the above filter in pom refer: https://stackoverflow.com/questions/20045744/java-lang-securityexception-no-manifest-section-for-signature-file-entry – Nagarajan S R Dec 23 '20 at 12:57