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);
}
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());
}
}
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;
}
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);
}
}
}
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);
}
}
}
Aggregations