Bug #82046 Mysql connector java OSGi metadata broken
Submitted: 29 Jun 2016 8:41 Modified: 11 Jan 2020 17:03
Reporter: C S Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:6.0.3 OS:Any
Assigned to: CPU Architecture:Any
Tags: OSGI

[29 Jun 2016 8:41] C S
Description:
The mysql connector j bundle 6.0.3 can not be installed as it contains an invalid version in the Manifest.

The stacktrace is:
2016-06-29 10:31:13,007 | ERROR | nsole user karaf | ShellUtil                        | 44 - org.apache.karaf.shell.core - 4.0.5 | Exception caught while executing command
org.apache.karaf.shell.support.MultiException: Error installing bundles:
	Unable to install bundle mvn:mysql/mysql-connector-java/6.0.2
	at org.apache.karaf.shell.support.MultiException.throwIf(MultiException.java:61)
	at org.apache.karaf.bundle.command.Install.execute(Install.java:116)[24:org.apache.karaf.bundle.core:4.0.5]
	at org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:83)[44:org.apache.karaf.shell.core:4.0.5]
	at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:67)[44:org.apache.karaf.shell.core:4.0.5]
	at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:87)[44:org.apache.karaf.shell.core:4.0.5]
	at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:480)[44:org.apache.karaf.shell.core:4.0.5]
	at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:406)[44:org.apache.karaf.shell.core:4.0.5]
	at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[44:org.apache.karaf.shell.core:4.0.5]
	at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:182)[44:org.apache.karaf.shell.core:4.0.5]
	at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:119)[44:org.apache.karaf.shell.core:4.0.5]
	at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:94)[44:org.apache.karaf.shell.core:4.0.5]
	at org.apache.karaf.shell.impl.console.ConsoleSessionImpl.run(ConsoleSessionImpl.java:270)[44:org.apache.karaf.shell.core:4.0.5]
	at java.lang.Thread.run(Thread.java:745)[:1.8.0_92]
Caused by: java.lang.Exception: Unable to install bundle mvn:mysql/mysql-connector-java/6.0.2
	at org.apache.karaf.bundle.command.Install.execute(Install.java:79)[24:org.apache.karaf.bundle.core:4.0.5]
	... 11 more
Caused by: org.osgi.framework.BundleException: Could not create bundle object.
	at org.apache.felix.framework.Felix.installBundle(Felix.java:3057)[org.apache.felix.framework-5.4.0.jar:]
	at org.apache.felix.framework.BundleContextImpl.installBundle(BundleContextImpl.java:167)[org.apache.felix.framework-5.4.0.jar:]
	at org.apache.karaf.bundle.command.Install.execute(Install.java:77)[24:org.apache.karaf.bundle.core:4.0.5]
	... 11 more
Caused by: java.lang.IllegalArgumentException: invalid version "${osgid-version}": non-numeric "${osgid-version}"
	at org.osgi.framework.Version.parseInt(Version.java:170)[org.osgi.core-6.0.0.jar:]
	at org.osgi.framework.Version.<init>(Version.java:126)[org.osgi.core-6.0.0.jar:]
	at org.osgi.framework.Version.valueOf(Version.java:257)[org.osgi.core-6.0.0.jar:]
	at org.osgi.framework.Version.parseVersion(Version.java:228)[org.osgi.core-6.0.0.jar:]
	at org.apache.felix.framework.util.manifestparser.ManifestParser.normalizeExportClauses(ManifestParser.java:932)[org.apache.felix.framework-5.4.0.jar:]
	at org.apache.felix.framework.util.manifestparser.ManifestParser.<init>(ManifestParser.java:216)[org.apache.felix.framework-5.4.0.jar:]
	at org.apache.felix.framework.BundleRevisionImpl.<init>(BundleRevisionImpl.java:121)[org.apache.felix.framework-5.4.0.jar:]
	at org.apache.felix.framework.BundleImpl.createRevision(BundleImpl.java:1282)[org.apache.felix.framework-5.4.0.jar:]
	at org.apache.felix.framework.BundleImpl.<init>(BundleImpl.java:113)[org.apache.felix.framework-5.4.0.jar:]
	at org.apache.felix.framework.Felix.installBundle(Felix.java:3004)[org.apache.felix.framework-5.4.0.jar:]
	... 13 more
Caused by: java.lang.NumberFormatException: For input string: "${osgid-version}"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)[:1.8.0_92]
	at java.lang.Integer.parseInt(Integer.java:569)[:1.8.0_92]
	at java.lang.Integer.parseInt(Integer.java:615)[:1.8.0_92]
	at org.osgi.framework.Version.parseInt(Version.java:168)[org.osgi.core-6.0.0.jar:]
	... 22 more

How to repeat:
Download, extract and start apache-karaf 4.0.5.

In karaf shell do:
install -s mvn:mysql/mysql-connector-java/6.0.3
log:tail

The log will show the stacktrace above.

Suggested fix:
When looking into the Manifest you see this Export-Package Entry:
com.mysql.cj.fabric.jd
 bc;version="${osgid-version}";uses:="com.mysql.cj.jdbc"

It seems like the property is not resolved during the build. I guess the name of the property changed.

So the fix should be easy by just using the new property or a fixed version.
[5 Jul 2016 14:28] Chiranjeevi Battula
Hello C S,

Thank you for the bug report.
Verified based on internal discussion with dev's.

Thanks,
Chiranjeevi.