From 83ad8606b76db4f3d9fa14811a783feb7aab29e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francesco=20Chicchiricc=C3=B2?= Date: Mon, 19 Oct 2015 18:06:37 +0200 Subject: [PATCH] Reverting to maven-assembly-plugin 2.5.5, as 2.6 cause NULL Manifest --- .../local/ConnectorBundleManifestParser.java | 18 +++---- .../local/LocalConnectorInfoManagerImpl.java | 50 ++++++++++--------- java/pom.xml | 2 +- 3 files changed, 36 insertions(+), 34 deletions(-) diff --git a/java/connector-framework-internal/src/main/java/org/identityconnectors/framework/impl/api/local/ConnectorBundleManifestParser.java b/java/connector-framework-internal/src/main/java/org/identityconnectors/framework/impl/api/local/ConnectorBundleManifestParser.java index 9529e3b2..52d25f3a 100644 --- a/java/connector-framework-internal/src/main/java/org/identityconnectors/framework/impl/api/local/ConnectorBundleManifestParser.java +++ b/java/connector-framework-internal/src/main/java/org/identityconnectors/framework/impl/api/local/ConnectorBundleManifestParser.java @@ -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 attributes; - public ConnectorBundleManifestParser(String fileName, Manifest manifest) { + public ConnectorBundleManifestParser(final String fileName, final Manifest manifest) { this.fileName = fileName; attributes = getAttributes(manifest); } - private static Map getAttributes(Manifest manifest) { - HashMap rv = new HashMap(); + private static Map getAttributes(final Manifest manifest) { + Map rv = new HashMap(); for (Map.Entry entry : manifest.getMainAttributes().entrySet()) { rv.put(String.valueOf(entry.getKey()), String.valueOf(entry.getValue())); } @@ -60,10 +61,9 @@ private static Map 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); @@ -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); } diff --git a/java/connector-framework-internal/src/main/java/org/identityconnectors/framework/impl/api/local/LocalConnectorInfoManagerImpl.java b/java/connector-framework-internal/src/main/java/org/identityconnectors/framework/impl/api/local/LocalConnectorInfoManagerImpl.java index bebd18d2..a28264d9 100644 --- a/java/connector-framework-internal/src/main/java/org/identityconnectors/framework/impl/api/local/LocalConnectorInfoManagerImpl.java +++ b/java/connector-framework-internal/src/main/java/org/identityconnectors/framework/impl/api/local/LocalConnectorInfoManagerImpl.java @@ -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()); } @@ -259,22 +257,26 @@ private static List 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) { @@ -299,14 +301,14 @@ private static List 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()); } } @@ -415,7 +417,7 @@ private static String[] getBundleNamePrefixes(final Class 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('.', '/'); diff --git a/java/pom.xml b/java/pom.xml index dc48a83f..71f7859f 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -225,7 +225,7 @@ org.apache.maven.plugins maven-assembly-plugin - 2.6 + 2.5.5 org.apache.maven.plugins