question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CNFE for loading class using classLoader from JCommander due to wrong META-INF/MANIFEST.MF

See original GitHub issue

Jcommander Version

1.72

Description:

  • Run jar -xvf jcommander-1.73.jar
  • Check for META-INF/MANIFEST.MF content
  • This causes problem to load any class from jcommander using this.getClass().getClassLoader().loadClass(ParameterException.class.getName());

Reproducer Project https://github.com/dipak-pawar/jcommander-classloading/tree/jcommander_classloader

Actual output https://gist.githubusercontent.com/anonymous/de6198fe541a910fb2d6b2208ceede7d/raw/225cbffca7f9aba4c602a08f20afbd0aa0c0a44d/cnfe.log

Expected output Class should load fine.

Actual Content - META-INF/MANIFEST.MF

Manifest-Version: 1.0
Bundle-Description: A Java library to parse command line options
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0
Export-Package: com.beust.jcommander.converters;version="1.73",com.beu
 st.jcommander.defaultprovider;version="1.73",com.beust.jcommander;ver
 sion="1.73",com.beust.jcommander.internal;version="1.73",com.beust.jc
 ommander.validators;version="1.73"
Build-Date: 2018-02-23
Bundle-SymbolicName: jcommander
Bundle-Version: 1.73
Bundle-Name: com.beust.jcommander
Bundle-ManifestVersion: 2
Bnd-LastModified: 1519401535143
Created-By: 1.8.0_121 (Oracle Corporation)
Tool: Bnd-3.5.0.201709291849


Manifest-Version: 1.0
Bundle-Description: A Java library to parse command line options
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0
Export-Package: com.beust.jcommander.converters;version="1.73",com.beu
 st.jcommander.defaultprovider;version="1.73",com.beust.jcommander;ver
 sion="1.73",com.beust.jcommander.internal;version="1.73",com.beust.jc
 ommander.validators;version="1.73"
Build-Date: 2018-02-23
Bundle-SymbolicName: jcommander
Bundle-Version: 1.73
Bundle-Name: com.beust.jcommander
Bundle-ManifestVersion: 2
Bnd-LastModified: 1519401551333
Created-By: 1.8.0_121 (Oracle Corporation)
Tool: Bnd-3.5.0.201709291849

Expected Content - META-INF/MANIFEST.MF

Manifest-Version: 1.0
Bundle-Description: A Java library to parse command line options
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0
Export-Package: com.beust.jcommander.converters;version="1.73",com.beu
 st.jcommander.defaultprovider;version="1.73",com.beust.jcommander;ver
 sion="1.73",com.beust.jcommander.internal;version="1.73",com.beust.jc
 ommander.validators;version="1.73"
Build-Date: 2018-02-23
Bundle-SymbolicName: jcommander
Bundle-Version: 1.73
Bundle-Name: com.beust.jcommander
Bundle-ManifestVersion: 2
Bnd-LastModified: 1519401535143
Created-By: 1.8.0_121 (Oracle Corporation)
Tool: Bnd-3.5.0.201709291849

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
fknittelcommented, Apr 1, 2019

@cbeust Unfortunately, this seems to have reappeared for release 1.75:

Caused by: java.lang.ClassNotFoundException: com.beust.jcommander.JCommander
	at java.net.URLClassLoader$1.run(URLClassLoader.java:370)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 54 more
Caused by: java.io.IOException: invalid manifest format
	at java.util.jar.Manifest.read(Manifest.java:225)
	at java.util.jar.Manifest.<init>(Manifest.java:69)
	at java.util.jar.JarFile.getManifestFromReference(JarFile.java:194)
	at java.util.jar.JarFile.getManifest(JarFile.java:180)
	at sun.misc.URLClassPath$JarLoader$2.getManifest(URLClassPath.java:981)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:450)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
	... 60 more

Also mentioned here: https://github.com/cbeust/jcommander/commit/85cb6f7217e15f62225185ffd97491f34b7b49bb#commitcomment-32810824

0reactions
cbeustcommented, Aug 23, 2019

Fixed in 1.78.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Wrong resource url when using URLClassloader to load test ...
The Problem : This test reads a file using a ClassLoader.getSystemClassLoader().getResourceAsStream(), now the expected path of this file should ...
Read more >
ScrapResidentailProxies.jar - Hybrid Analysis
Contains ability to find and load resources of a specific module ... Remote Access Related ... Creates a writable file in a temporary...
Read more >
java-sig-commits - February 2015 - Fedora Mailing-Lists
[Bug 1144270] New: SBT doesn't start correctly in some 32-bit machines due to low memory. by Red Hat Bugzilla.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found