Skip to content

Commit

Permalink
Reverting to maven-assembly-plugin 2.5.5, as 2.6 cause NULL Manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgrosso committed Oct 19, 2015
1 parent 6ad82ec commit 83ad860
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 34 deletions.
Expand Up @@ -42,15 +42,16 @@ public final class ConnectorBundleManifestParser {
private static final String ATT_BUNDLE_VERSION = BUNDLE_PREFIX + "Version";

private final String fileName;

private final Map<String, String> attributes;

public ConnectorBundleManifestParser(String fileName, Manifest manifest) {
public ConnectorBundleManifestParser(final String fileName, final Manifest manifest) {
this.fileName = fileName;
attributes = getAttributes(manifest);
}

private static Map<String, String> getAttributes(Manifest manifest) {
HashMap<String, String> rv = new HashMap<String, String>();
private static Map<String, String> getAttributes(final Manifest manifest) {
Map<String, String> rv = new HashMap<String, String>();
for (Map.Entry<Object, Object> entry : manifest.getMainAttributes().entrySet()) {
rv.put(String.valueOf(entry.getKey()), String.valueOf(entry.getValue()));
}
Expand All @@ -60,10 +61,9 @@ private static Map<String, String> getAttributes(Manifest manifest) {
/**
* Parses the manifest.
*
* @return The manifest. Note that the classes/classloaders will not be
* populated yet. That is to be done at a higher-level.
* @throws ConfigurationException
* If there were any structural problems.
* @return The manifest. Note that the classes/classloaders will not be populated yet. That is to be done at a
* higher-level.
* @throws ConfigurationException if there were any structural problems.
*/
public ConnectorBundleManifest parse() throws ConfigurationException {
String frameworkVersion = getRequiredAttribute(ATT_FRAMEWORK_VERSION);
Expand All @@ -73,8 +73,8 @@ public ConnectorBundleManifest parse() throws ConfigurationException {
if (FrameworkUtil.getFrameworkVersion().compareTo(Version.parse(frameworkVersion)) < 0) {
String message =
"Bundle " + fileName + " requests an unrecognized " + "framework version "
+ frameworkVersion + " but available is "
+ FrameworkUtil.getFrameworkVersion().getVersion();
+ frameworkVersion + " but available is "
+ FrameworkUtil.getFrameworkVersion().getVersion();
throw new ConfigurationException(message);
}

Expand Down
Expand Up @@ -194,13 +194,11 @@ private static WorkingBundleInfo processURL(final URL url, final boolean topLeve
try {
stream = new JarInputStream(url.openStream());
// only parse the manifest for top-level bundles
// other bundles may not be bundles - they might be
// jars instead
// other bundles may not be bundles - they might be jars instead
if (topLevel) {
final Manifest rawManifest = stream.getManifest();
final ConnectorBundleManifestParser parser =
new ConnectorBundleManifestParser(info.getOriginalLocation(),
rawManifest);
new ConnectorBundleManifestParser(info.getOriginalLocation(), rawManifest);
info.setManifest(parser.parse());
}

Expand Down Expand Up @@ -259,22 +257,26 @@ private static List<ConnectorInfo> createConnectorInfo(
// it might be from a bundle
// fragment ( a bundle only included by other bundles ).
// However, we should definitely warn
LOG.info(LOG.isOk() ?
e : null,
"Unable to load class {0} from bundle {1}. Class will be ignored and will not be listed in list of connectors.",
LOG.info(LOG.isOk() ? e : null,
"Unable to load class {0} from bundle {1}. Class will be ignored and will not be "
+ "listed in list of connectors.",
className, bundleInfo.getOriginalLocation());
}
if (connectorClass != null && options == null) {
for (Annotation annotation: connectorClass.getAnnotations()) {
if (ConnectorClass.class.getName().equals(annotation.annotationType().getName())) {
// Same class name as the annotation we are looking for. But the previous code haven't found it.
// So it looks like the annotation on this class is actually the correct one but it is loaded
// by wrong classloader.
// Note: This error is very difficult to diagnose. Therefore we are explicitly checking for it here.
throw new ConfigurationException("Class "+connectorClass.getName()+" has ConnectorClass annotation but it looks like it is " +
"loaded by a wrong classloader. Maybe the connector bundle contains the connector frameworks JAR? (it should NOT contain it).");
}
}
for (Annotation annotation : connectorClass.getAnnotations()) {
if (ConnectorClass.class.getName().equals(annotation.annotationType().getName())) {
// Same class name as the annotation we are looking for. But the previous code haven't
// found it.
// So it looks like the annotation on this class is actually the correct one but it is
// loaded by wrong classloader.
// Note: This error is very difficult to diagnose. Therefore we are explicitly checking
// for it here.
throw new ConfigurationException("Class " + connectorClass.getName()
+ " has ConnectorClass annotation but it looks like it is "
+ "loaded by a wrong classloader. Maybe the connector bundle contains the "
+ "connector frameworks JAR? (it should NOT contain it).");
}
}
}
}
if (connectorClass != null && options != null) {
Expand All @@ -299,14 +301,14 @@ private static List<ConnectorInfo> createConnectorInfo(
LOG.info("Add ConnectorInfo {0} to Local Connector Info Manager from {1}",
info.getConnectorKey(), bundleInfo.getOriginalLocation());
} catch (final NoClassDefFoundError e) {
LOG.info(LOG.isOk() ?
e : null,
"Unable to load configuration class of connector {0} from bundle {1}. Class will be ignored and will not be listed in list of connectors.",
LOG.info(LOG.isOk() ? e : null,
"Unable to load configuration class of connector {0} from bundle {1}. "
+ "Class will be ignored and will not be listed in list of connectors.",
connectorClass, bundleInfo.getOriginalLocation());
} catch (final TypeNotPresentException e) {
LOG.info(LOG.isOk() ?
e : null,
"Unable to load configuration class of connector {0} from bundle {1}. Class will be ignored and will not be listed in list of connectors.",
LOG.info(LOG.isOk() ? e : null,
"Unable to load configuration class of connector {0} from bundle {1}. "
+ "Class will be ignored and will not be listed in list of connectors.",
connectorClass, bundleInfo.getOriginalLocation());
}
}
Expand Down Expand Up @@ -415,7 +417,7 @@ private static String[] getBundleNamePrefixes(final Class<? extends Connector> c
if (paths == null || paths.length == 0) {
final String pkage = ReflectionUtil.getPackage(connector);
final String messageCatalog = pkage + ".Messages";
paths = new String[]{messageCatalog};
paths = new String[] { messageCatalog };
}
for (int i = 0; i < paths.length; i++) {
paths[i] = paths[i].replace('.', '/');
Expand Down
2 changes: 1 addition & 1 deletion java/pom.xml
Expand Up @@ -225,7 +225,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<version>2.5.5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down

0 comments on commit 83ad860

Please sign in to comment.