Search in sources :

Example 16 with ServiceConfigurationError

use of java.util.ServiceConfigurationError in project Payara by payara.

the class GlassFishRuntime method getRuntimeBuilder.

private static RuntimeBuilder getRuntimeBuilder(BootstrapProperties bootstrapProperties, ClassLoader cl) throws GlassFishException {
    // StringBuilder sb = new StringBuilder("Launcher Class Loader = " + cl);
    // if (cl instanceof URLClassLoader) {
    // sb.append("has following Class Path: ");
    // for (URL url : URLClassLoader.class.cast(cl).getURLs()) {
    // sb.append(url).append(", ");
    // }
    // }
    // System.out.println(sb);
    Iterator<RuntimeBuilder> runtimeBuilders = ServiceLoader.load(RuntimeBuilder.class, cl).iterator();
    while (runtimeBuilders.hasNext()) {
        try {
            RuntimeBuilder builder = runtimeBuilders.next();
            logger.logp(Level.FINE, "GlassFishRuntime", "getRuntimeBuilder", "builder = {0}", new Object[] { builder });
            if (builder.handles(bootstrapProperties)) {
                return builder;
            }
        } catch (ServiceConfigurationError sce) {
            // Ignore the exception and move ahead to the next builder.
            logger.logp(Level.FINE, "GlassFishRuntime", "getRuntimeBuilder", "Ignoring", sce);
        } catch (NoClassDefFoundError ncdfe) {
            // On IBM JDK, we seem to be getting NoClassDefFoundError instead of ServiceConfigurationError
            // when OSgiRuntimeBuilder is not able to be loaded in non-OSGi mode because of absence of
            // OSGi classes in classpath. So, we need to catch it and ignore.
            logger.logp(Level.FINE, "GlassFishRuntime", "getRuntimeBuilder", "Ignoring", ncdfe);
        }
    }
    throw new GlassFishException("No runtime builder available for this configuration: " + bootstrapProperties.getProperties(), null);
}
Also used : ServiceConfigurationError(java.util.ServiceConfigurationError) RuntimeBuilder(org.glassfish.embeddable.spi.RuntimeBuilder)

Example 17 with ServiceConfigurationError

use of java.util.ServiceConfigurationError in project Bytecoder by mirkosertic.

the class FtpClientProvider method loadProviderFromProperty.

private static boolean loadProviderFromProperty() {
    String cm = System.getProperty("sun.net.ftpClientProvider");
    if (cm == null) {
        return false;
    }
    try {
        @SuppressWarnings("deprecation") Object o = Class.forName(cm, true, null).newInstance();
        provider = (FtpClientProvider) o;
        return true;
    } catch (ClassNotFoundException | IllegalAccessException | InstantiationException | SecurityException x) {
        throw new ServiceConfigurationError(x.toString());
    }
}
Also used : ServiceConfigurationError(java.util.ServiceConfigurationError)

Example 18 with ServiceConfigurationError

use of java.util.ServiceConfigurationError in project Bytecoder by mirkosertic.

the class LoggerFinderLoader method loadLoggerFinder.

// Loads the LoggerFinder using ServiceLoader. If no LoggerFinder
// is found returns the default (possibly JUL based) implementation
private static System.LoggerFinder loadLoggerFinder() {
    System.LoggerFinder result;
    try {
        // Iterator iterates with the access control context stored
        // at ServiceLoader creation time.
        final Iterator<System.LoggerFinder> iterator = findLoggerFinderProviders();
        if (iterator.hasNext()) {
            result = iterator.next();
            if (iterator.hasNext() && ensureSingletonProvider()) {
                throw new ServiceConfigurationError("More than on LoggerFinder implementation");
            }
        } else {
            result = loadDefaultImplementation();
        }
    } catch (Error | RuntimeException x) {
        // next caller will get the plain default impl (not linked
        // to java.util.logging)
        service = result = new DefaultLoggerFinder();
        ErrorPolicy errorPolicy = configurationErrorPolicy();
        if (errorPolicy == ErrorPolicy.ERROR) {
            // rethrow any exception as a ServiceConfigurationError.
            if (x instanceof Error) {
                throw x;
            } else {
                throw new ServiceConfigurationError("Failed to instantiate LoggerFinder provider; Using default.", x);
            }
        } else if (errorPolicy != ErrorPolicy.QUIET) {
            // if QUIET just silently use the plain default impl
            // otherwise, log a warning, possibly adding the exception
            // stack trace (if DEBUG is specified).
            SimpleConsoleLogger logger = new SimpleConsoleLogger("jdk.internal.logger", false);
            logger.log(System.Logger.Level.WARNING, "Failed to instantiate LoggerFinder provider; Using default.");
            if (errorPolicy == ErrorPolicy.DEBUG) {
                logger.log(System.Logger.Level.WARNING, "Exception raised trying to instantiate LoggerFinder", x);
            }
        }
    }
    return result;
}
Also used : ServiceConfigurationError(java.util.ServiceConfigurationError) ServiceConfigurationError(java.util.ServiceConfigurationError)

Example 19 with ServiceConfigurationError

use of java.util.ServiceConfigurationError in project GreenHouse by utsanjan.

the class zzfn method zza.

/* JADX INFO: Access modifiers changed from: package-private */
public static <T extends zzfb> T zza(Class<T> cls) {
    String str;
    ClassLoader classLoader = zzfn.class.getClassLoader();
    if (cls.equals(zzfb.class)) {
        str = zzb;
    } else if (cls.getPackage().equals(zzfn.class.getPackage())) {
        str = String.format("%s.BlazeGenerated%sLoader", cls.getPackage().getName(), cls.getSimpleName());
    } else {
        throw new IllegalArgumentException(cls.getName());
    }
    try {
        try {
            try {
                try {
                    try {
                        return cls.cast(((zzfn) Class.forName(str, true, classLoader).getConstructor(new Class[0]).newInstance(new Object[0])).zza());
                    } catch (NoSuchMethodException e) {
                        throw new IllegalStateException(e);
                    }
                } catch (IllegalAccessException e2) {
                    throw new IllegalStateException(e2);
                }
            } catch (InstantiationException e3) {
                throw new IllegalStateException(e3);
            }
        } catch (InvocationTargetException e4) {
            throw new IllegalStateException(e4);
        }
    } catch (ClassNotFoundException e5) {
        Iterator it = ServiceLoader.load(zzfn.class, classLoader).iterator();
        ArrayList arrayList = new ArrayList();
        while (it.hasNext()) {
            try {
                arrayList.add(cls.cast(((zzfn) it.next()).zza()));
            } catch (ServiceConfigurationError e6) {
                Logger logger = zza;
                Level level = Level.SEVERE;
                String valueOf = String.valueOf(cls.getSimpleName());
                logger.logp(level, "com.google.protobuf.GeneratedExtensionRegistryLoader", "load", valueOf.length() != 0 ? "Unable to load ".concat(valueOf) : new String("Unable to load "), (Throwable) e6);
            }
        }
        if (arrayList.size() == 1) {
            return (T) ((zzfb) arrayList.get(0));
        }
        if (arrayList.size() == 0) {
            return null;
        }
        try {
            return (T) ((zzfb) cls.getMethod("combine", Collection.class).invoke(null, arrayList));
        } catch (IllegalAccessException e7) {
            throw new IllegalStateException(e7);
        } catch (NoSuchMethodException e8) {
            throw new IllegalStateException(e8);
        } catch (InvocationTargetException e9) {
            throw new IllegalStateException(e9);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) ServiceConfigurationError(java.util.ServiceConfigurationError) Logger(java.util.logging.Logger) InvocationTargetException(java.lang.reflect.InvocationTargetException) Iterator(java.util.Iterator) Collection(java.util.Collection) Level(java.util.logging.Level)

Example 20 with ServiceConfigurationError

use of java.util.ServiceConfigurationError in project GreenHouse by utsanjan.

the class zzie method zza.

/* JADX INFO: Access modifiers changed from: package-private */
public static <T extends zzhs> T zza(Class<T> cls) {
    String str;
    ClassLoader classLoader = zzie.class.getClassLoader();
    if (cls.equals(zzhs.class)) {
        str = zzb;
    } else if (cls.getPackage().equals(zzie.class.getPackage())) {
        str = String.format("%s.BlazeGenerated%sLoader", cls.getPackage().getName(), cls.getSimpleName());
    } else {
        throw new IllegalArgumentException(cls.getName());
    }
    try {
        try {
            try {
                try {
                    try {
                        return cls.cast(((zzie) Class.forName(str, true, classLoader).getConstructor(new Class[0]).newInstance(new Object[0])).zza());
                    } catch (NoSuchMethodException e) {
                        throw new IllegalStateException(e);
                    }
                } catch (IllegalAccessException e2) {
                    throw new IllegalStateException(e2);
                }
            } catch (InstantiationException e3) {
                throw new IllegalStateException(e3);
            }
        } catch (InvocationTargetException e4) {
            throw new IllegalStateException(e4);
        }
    } catch (ClassNotFoundException e5) {
        Iterator it = ServiceLoader.load(zzie.class, classLoader).iterator();
        ArrayList arrayList = new ArrayList();
        while (it.hasNext()) {
            try {
                arrayList.add(cls.cast(((zzie) it.next()).zza()));
            } catch (ServiceConfigurationError e6) {
                Logger logger = zza;
                Level level = Level.SEVERE;
                String valueOf = String.valueOf(cls.getSimpleName());
                logger.logp(level, "com.google.protobuf.GeneratedExtensionRegistryLoader", "load", valueOf.length() != 0 ? "Unable to load ".concat(valueOf) : new String("Unable to load "), (Throwable) e6);
            }
        }
        if (arrayList.size() == 1) {
            return (T) ((zzhs) arrayList.get(0));
        }
        if (arrayList.size() == 0) {
            return null;
        }
        try {
            return (T) ((zzhs) cls.getMethod("combine", Collection.class).invoke(null, arrayList));
        } catch (IllegalAccessException e7) {
            throw new IllegalStateException(e7);
        } catch (NoSuchMethodException e8) {
            throw new IllegalStateException(e8);
        } catch (InvocationTargetException e9) {
            throw new IllegalStateException(e9);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) ServiceConfigurationError(java.util.ServiceConfigurationError) Logger(java.util.logging.Logger) InvocationTargetException(java.lang.reflect.InvocationTargetException) Iterator(java.util.Iterator) Collection(java.util.Collection) Level(java.util.logging.Level)

Aggregations

ServiceConfigurationError (java.util.ServiceConfigurationError)85 IOException (java.io.IOException)21 Iterator (java.util.Iterator)13 ArrayList (java.util.ArrayList)12 File (java.io.File)10 URL (java.net.URL)9 URLClassLoader (java.net.URLClassLoader)7 ServiceLoader (java.util.ServiceLoader)6 Test (org.junit.Test)6 BufferedReader (java.io.BufferedReader)5 InputStream (java.io.InputStream)5 InputStreamReader (java.io.InputStreamReader)5 HashMap (java.util.HashMap)5 NoSuchElementException (java.util.NoSuchElementException)5 FileInputStream (java.io.FileInputStream)4 CharsetProvider (java.nio.charset.spi.CharsetProvider)4 LinkedList (java.util.LinkedList)4 List (java.util.List)4 Set (java.util.Set)4 TableException (org.apache.flink.table.api.TableException)4